{"id":273,"date":"2018-10-03T17:15:15","date_gmt":"2018-10-03T17:15:15","guid":{"rendered":"https:\/\/www.xlsoft.com\/doc\/kudan\/?page_id=273"},"modified":"2020-10-09T00:38:03","modified_gmt":"2020-10-09T00:38:03","slug":"unity-building-the-app-for-ios","status":"publish","type":"page","link":"https:\/\/www.xlsoft.com\/doc\/kudan\/unity-building-the-app-for-ios\/","title":{"rendered":"Unity Building The App for iOS"},"content":{"rendered":"<p>This quick tutorial will show you how to set up your Unity project to build for the iOS platform.<\/p>\n<div class=\"excerpt\">\n<hr \/>\n<div class=\"magic-block-api-header\">\n<h1 class=\"header-scroll is-api-header\">Application Identifier<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>Make sure your Bundle\/Application Identifier is correct for the API Key you&#8217;re using. You can find your project&#8217;s Application Identifier by clicking the [<em>Set App\/Bundle ID<\/em>]\u00a0button on the\u00a0<code>Kudan Tracker<\/code>script, or by going to Edit -&gt; Project Settings -&gt; Player and open\u00a0<em>Other Settings<\/em>\u00a0in the iOS tab.<\/p>\n<p>The Application ID be either:<\/p>\n<ul>\n<li>The ID you entered when your free key was generated by XLsoft, in the format &#8220;com.companyName.productName&#8221;.<\/li>\n<li>If you are using the Development License Key,\u00a0<code>com.xlsoft.kudanar<\/code>.<br \/>\nClick <a href=\"https:\/\/www.xlsoft.com\/doc\/kudan\/en\/development-license-keys\/\">here<\/a> for the development license key.<\/li>\n<\/ul>\n<p>To see if the entered API Key is valid for the corresponding Application ID, run the app in Play Mode. View message in the console mentioning whether or not the API Key is valid. Or view in console log when building for iOS\/Android.<\/p>\n<p>If the Application Identifier is incorrect, the <strong>Tracker will not run<\/strong> and camera view will be blank\/black.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-309 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2018\/09\/894906b-BundleIDUnityiOS-193x300.png\" alt=\"\" width=\"394\" height=\"612\" srcset=\"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/894906b-BundleIDUnityiOS-193x300.png 193w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/894906b-BundleIDUnityiOS.png 497w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/p>\n<\/div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-311 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2018\/09\/4910774-APIKeyUnity-160x300.png\" alt=\"\" width=\"360\" height=\"675\" srcset=\"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/4910774-APIKeyUnity-160x300.png 160w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/4910774-APIKeyUnity.png 519w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"excerpt\">\n<div class=\"magic-block-textarea\">\n<div class=\"magic-block-api-header\">\n<h1 class=\"header-scroll is-api-header\">Camera Usage Description<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>Add a camera usage description in the appropriate field. Since Kudan uses the camera, the app will crash on iOS 10+ if an app does not contain a usage description.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-312 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2018\/09\/dcdfff0-CameraUsageDescriptionUnityiOS-124x300.png\" alt=\"\" width=\"324\" height=\"784\" \/><\/p>\n<\/div>\n<div class=\"magic-block-callout type-info \">\n<h3>Usage Descriptions<\/h3>\n<div class=\"callout-body\">\n<p>If you add any extra features to your app that require additional hardware components, such as GPS, remember to add usage descriptions for those to save yourself a headache later.<\/p>\n<\/div>\n<\/div>\n<div class=\"anchor waypoint\"><\/div>\n<h1>Add BuildHelper<\/h1>\n<p>Xcode projects, built with Unity 2019 and later, now includes the UnityFramework within the Standard iOS libraries. The Kudan framework supports fat binary, so builds cannot be compiled with Bitcode enabled. This UnityFramework also requires [Enable Bitcode] to be set to [No].<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-2425 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2.png\" alt=\"\" width=\"900\" srcset=\"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2.png 2954w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2-300x202.png 300w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2-1024x690.png 1024w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2-768x517.png 768w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2-1536x1035.png 1536w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-ios-xcode-unity-framework-bitcode2-2048x1380.png 2048w\" sizes=\"(max-width: 2954px) 100vw, 2954px\" \/><\/p>\n<p>Starting with Unity 2019, you can specify Xcode project settings from Unity by adding the BuildHelper.cs file to your Unity project. Following the steps below.<\/p>\n<p>In Project pane, create an <code>Editor<\/code> folder in the <code>Assets<\/code> folder by right-clicking and selecting [Create &gt; Folder]. Right-click on the <code>Editor<\/code> folder created, select [Create &gt; C # Script], and name the file <code>BuildHelper.cs<\/code>.<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-2426 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2020\/09\/unity2020-add-buildhelper.png\" alt=\"\" width=\"450\" srcset=\"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-add-buildhelper.png 1086w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-add-buildhelper-300x266.png 300w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-add-buildhelper-1024x907.png 1024w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2020\/09\/unity2020-add-buildhelper-768x680.png 768w\" sizes=\"(max-width: 1086px) 100vw, 1086px\" \/><\/p>\n<p>Open <code>BuildHelper.cs<\/code> with Visual Studio or other editor and replace it with the following code.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n#if UNITY_2019_1_OR_NEWER\r\n#if UNITY_IPHONE\r\n\r\nusing System.IO;\r\nusing UnityEditor;\r\nusing UnityEditor.Callbacks;\r\nusing UnityEditor.iOS.Xcode;\r\n\r\npublic class BuildHelper\r\n{\r\n    &#x5B;PostProcessBuildAttribute (1)]\r\n    public static void OnPostProcessBuild (BuildTarget target, string path)\r\n    {\r\n        if (target == BuildTarget.iOS)\r\n        {\r\n            var projectPath = PBXProject.GetPBXProjectPath (path);\r\n            var project = new PBXProject ();\r\n            project.ReadFromString (File.ReadAllText (projectPath));\r\n\r\n            var targetGUID = project.GetUnityFrameworkTargetGuid ();\r\n            project.SetBuildProperty (targetGUID, &quot;ENABLE_BITCODE&quot;, &quot;NO&quot;);\r\n            var iphoneGUID = project.GetUnityMainTargetGuid ();\r\n            project.SetBuildProperty (iphoneGUID, &quot;ENABLE_BITCODE&quot;, &quot;NO&quot;);\r\n\r\n            File.WriteAllText (projectPath, project.WriteToString ());\r\n        }\r\n    }\r\n}\r\n\r\n#endif\r\n#endif\r\n<\/pre>\n<div>BuildHelper sets Enable Bitcode to [No] in the generated Xcode project. Just click [Build And Run].<\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<p>&nbsp;<\/p>\n<div class=\"magic-block-api-header\">\n<div id=\"section-build-the-xcode-project\" class=\"anchor waypoint\"><\/div>\n<h1 class=\"header-scroll is-api-header\">Build the Xcode project<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>Build the app by going to File -&gt; Build Settings, selecting iOS and clicking Build. Unity will build the selected scenes and produce an XCode project in the selected folder.<\/p>\n<p>Depending on your versions of Unity and Xcode, you may be able to select Build and Run instead. In this instance, Unity will automatically open the built project in Xcode and run it on a connected device, if possible. This is not always the case, however, so it is usually safer to simply click Build and open the project yourself unless you know for a fact that your particular versions of Unity and Xcode are compatible.<\/p>\n<\/div>\n<div class=\"magic-block-api-header\">\n<div id=\"section-set-up-the-xcode-project\" class=\"anchor waypoint\"><\/div>\n<h1 class=\"header-scroll is-api-header\">Set up the Xcode project<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>In the Xcode project, there are two more things we need to set. If you created the BuildHelper script, skip the first step. First, select the project in the tree view on the left hand side and click the\u00a0<em>Build Settings<\/em>\u00a0tab. Scroll down to the\u00a0<em>Build Options<\/em>\u00a0section and find the entry marked\u00a0<em>Enable Bitcode<\/em>. Set it to\u00a0<strong>NO<\/strong>. Kudan&#8217;s framework is a fat binary and cannot be compiled in an app with bitcode enabled. Skip this step if you created the BuildHelper script.\n<\/div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-314 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2018\/09\/57eb259-XcodeDisableBitcode-300x158.png\" alt=\"\" width=\"651\" height=\"343\" srcset=\"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/57eb259-XcodeDisableBitcode-300x158.png 300w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/57eb259-XcodeDisableBitcode-768x404.png 768w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/57eb259-XcodeDisableBitcode-1024x539.png 1024w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/p>\n<\/div>\n<p>Next, check that you have a valid Provisioning Profile. With Xcode 8 and later, profiles will automatically be taken care of by signing into Apple, so all you should need to do is select a development team in the\u00a0<em>Signing<\/em>\u00a0section of the\u00a0<em>General<\/em>\u00a0tab. In older versions of Xcode, you&#8217;ll have to make sure that the correct profile has been selected, or that you are using a wildcard Provisioning Profile.<\/p>\n<\/div>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-315 aligncenter\" src=\"https:\/\/www.xlsoft.com\/doc\/kudan\/files\/2018\/09\/e84d93e-XcodeSigning-300x72.png\" alt=\"\" width=\"625\" height=\"150\" srcset=\"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/e84d93e-XcodeSigning-300x72.png 300w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/e84d93e-XcodeSigning-768x184.png 768w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/e84d93e-XcodeSigning-1024x245.png 1024w, https:\/\/www.xlsoft.com\/doc\/kudan\/wp-content\/uploads\/2018\/09\/e84d93e-XcodeSigning.png 1621w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>If everything has been set up, click the play button in the upper left corner of the screen and the app should build and run. If you have a device connected to your machine via USB, the app will run on that device once the build has finished.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This quick tutorial will show you how to set up your Unity project to build for the iOS platform. Application Identifier Make sure your Bundle\/Application Identifier is correct for the API Key you&#8217;re using. You can find your project&#8217;s Application Identifier by clicking the [Set App\/Bundle ID]\u00a0button on the\u00a0Kudan Trackerscript, or by going to Edit &#8230; <a title=\"Unity Building The App for iOS\" class=\"read-more\" href=\"https:\/\/www.xlsoft.com\/doc\/kudan\/unity-building-the-app-for-ios\/\">Read more<span class=\"screen-reader-text\">Unity Building The App for iOS<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"bekko_page_header":""},"_links":{"self":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages\/273"}],"collection":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":24,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages\/273\/revisions"}],"predecessor-version":[{"id":2469,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages\/273\/revisions\/2469"}],"wp:attachment":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/media?parent=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}