Search code examples
iosnativescripttelerik-appbuilder

NativeScript: How to deploy iOS app to physical device?


I created an account with Telerik, signed a certificate with Apple Dev Centre and got a mobile provisioning. I used Appbuilder to import the certificate and the provision to my laptop. But I still cannot deploy my app on iOS using

tns deploy ios

The warning says:

IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system.

But when I do "appbuilder provision" and "appbuilder certificate", the commands show me they have been successfully imported. I also tried:

appbuilder deploy ios --provision '<name>' --certificate '<title>'

It says no project found at or above path and neither was a --path specified. But I am in the project folder. :/


Solution

  • For me, I used:

    $ tns deploy ios --device <device-udid>

    Now, beforehand I...

    1. Registered my device with Apple

      • Link: developer.apple.com/account/ios/device
    2. Created an explicit Bundle ID with Apple that matches the one that Native Script places in the package.json. This is what mine looked like.

      "nativescript": {
          "id": "org.nativescript.<app-name>",
          "tns-ios": {
              "version": "3.0.1"
          },
          "tns-android": {
              "version": "3.0.1"
          }
        }
      
      • Link: developer.apple.com/account/ios/identifier/bundle
    3. I then made provisioning profile with Apple https://developer.apple.com/account/ios/profile/ that then included the device and Bundle ID that I just made.

    4. Then in the file /app/App_Resources/iOS/build.xcconfig

      • Link: developer.apple.com/account/ios/identifier/bundle

    ie.

        DEVELOPMENT_TEAM = <Apple-dev-team-name>
        PROVISIONING_PROFILE = <provision-profile-id>
    
    • The provison profile is found in User/Library/MobileDevice/Provisioning\ Profiles/

    • If there is more than one, sort be creation date and grab the first one

    • Then ctrl-click and choose "Rename" copy the ID and paste it into the build.xcconfig file from earlier.

      1. To get the device UDID, you could use iTunes, but {N} makes it easy by running this in the terminal:

    $ tns device ios --available-devices

    • It shows up at the bottom under all the different emulators

    i.e.

        │#│Device Name│Platform│Device Identifier│ Type │  Status │
        │1│  iPhone   │ iOS    │  <device-udid>  │Device│Connected│
    
    1. After all that, run:

    $ tns deploy ios --device <device-name>

    P.S. : Let me know if this works.