Nativescript-cli: XCode 9: Requires Provisioning Profile Error

Created on 25 Sep 2017  路  21Comments  路  Source: NativeScript/nativescript-cli

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes

Tell us about the problem

I upgraded the tools on my machine to xcode 9. i have updated cli and build the project and it runs in simulator. Now when i wanna run in phone, i am getting the error:

tns run ios
error: exportArchive: "IAMobileApp.app" requires a provisioning profile.

I selected the provisioning profile in xcode (after openning the .xcodeproj file) and it was working in xcode 8.
screen shot 2017-09-25 at 12 32 32 pm

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.2.0
  • Cross-platform modules: "nativescript": {
    "id": "org.nativescript.IA",
    "tns-android": {
    "version": "3.2.0"
    },
    "tns-ios": {
    "version": "3.2.0"
    }
    }

Please tell us how to recreate the issue in as much detail as possible.

build the project using tns build ios and then open the .xcodeproj file and select the provisioning profile and then type tns run ios

bug

Most helpful comment

@pap5508 Thanks. Then, your ios-project-service.js should be in
/usr/local/lib/node_modules/nativescript/lib/services.

All 21 comments

I had a similar issue yesterday night and I was able to solve it by avoiding the provisioning profile and by, instead, adding a development team. You can probably do the same with the provisioning profile.

To solve the issue, go to App_Resources/iOS/build.xcconfig and either add a provisioning profile or a development team.

I think there is an official GitHub post about this in the nativescript section.

@briosheje i tried, but didn't suceed. it has todo with xcode 9 and ios11. It was working in xcode 8...

@dotnetdreamer Were you able to find a solution to this problem? I'm facing exactly the same issue after an update of xcode to version 9.

@mfradcourt i didn't succeed. I had another mac machine with xcode 8, i am still using that...However i just tried (after upgrading nativescript and xocde) and it seems fine now in some cases...

@dotnetdreamer @mfradcourt : Are you able to find a solution to this problem ? I am facing the exactly same issue after updating to xcode version 9.

https://github.com/NativeScript/NativeScript/issues/5059(url)

@pap5508 I chose the lazy solution and did reinstall xcode 8, you can download it from https://developer.apple.com/download/more/

@pap5508 no. For me debugging works but when i try to do build as release it doesn't. So i use xcode 8...

Thank you @dotnetdreamer & @mfradcourt!!!
I was going crazy assuming something had gone wrong with my certs...but once downgrading to Xcode 8, it worked PERFECTLY!

i just tested on xcode 9, it seems that tns run ios --provision "My Provisioning Profile" works.

@dotnetdreamer : I am getting following error while running
tns run ios --provision "My Provisioning Profile"

Xcode build...
2017-11-16 10:14:40.119 xcodebuild[2374:15698] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/7g/tp4sm6_n0dxcvs3zg3d7nwx80000gn/T/Hieber_2017-11-16_10-14-40.118.xcdistributionlogs'.
2017-11-16 10:16:22.099 xcodebuild[2374:15698] [MT] IDEDistribution: Step failed: <IDEDistributionPackagingStep: 0x7fbb6adfa8c0>: Error Domain=IDEFoundationErrorDomain Code=1 "ipatool failed with an exception: #<NoMethodError: undefined method `toolsPath' for nil:NilClass>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:812:in `rawLoadCommands'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:828:in `rpaths'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:259:in `resolveLoadedDylibs'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1423:in `block (2 levels) in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `block in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `new'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2940:in `<main>'" UserInfo={NSLocalizedDescription=ipatool failed with an exception: #<NoMethodError: undefined method `toolsPath' for nil:NilClass>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:812:in `rawLoadCommands'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:828:in `rpaths'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:259:in `resolveLoadedDylibs'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1423:in `block (2 levels) in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `block in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `new'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2940:in `<main>'}
error: exportArchive: ipatool failed with an exception: #<NoMethodError: undefined method `toolsPath' for nil:NilClass>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:812:in `rawLoadCommands'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:828:in `rpaths'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:259:in `resolveLoadedDylibs'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1423:in `block (2 levels) in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `block in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `new'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2940:in `<main>'

Error Domain=IDEFoundationErrorDomain Code=1 "ipatool failed with an exception: #<NoMethodError: undefined method `toolsPath' for nil:NilClass>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:812:in `rawLoadCommands'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:828:in `rpaths'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:259:in `resolveLoadedDylibs'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1423:in `block (2 levels) in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `block in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `new'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2940:in `<main>'" UserInfo={NSLocalizedDescription=ipatool failed with an exception: #<NoMethodError: undefined method `toolsPath' for nil:NilClass>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:812:in `rawLoadCommands'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:828:in `rpaths'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:259:in `resolveLoadedDylibs'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1423:in `block (2 levels) in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1422:in `block in initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1421:in `initialize'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `new'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2289:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2940:in `<main>'}

** EXPORT FAILED **

Getting the same error as @pap5508 after
tns run ios --provision <prov id>

At the same time project can be successfully built with an XCode.

Same problem here, with xcode 9.2. My friend build with xcode 9.1, same project

Just had this issue trying to get the NativeScript Hello World (spinning apple) project up and running on my device.

I fixed it by changing the id value in package.json. _(for me was on line 7)_

Change from "id": "org.nativescript.HelloWorld" to "id": "your.domain.HelloWorld"

Hey @pap5508 ,
The error error: exportArchive: ipatool failed with an exception: #<NoMethodError: undefined methodtoolsPath' for nil:NilClass>` is caused by mismatch of Xcode and some xcodebuild tools. I've seen it on some El Capitan and Sierra machiens with latest Xcode (latest available for both machines). In my case the solution was to update to High Sierra and update to latest Xcode and Xcode build tools.
Can you give it a try?

@rosen-vladimirov : I have tried after updating all.. still getting the same error..

@pap5508 Getting the same `error: exportArchive: ipatool failed with an exception: #`` as @pap5508 on High Sierra and XCode9.2.

As a temporary solution, I need to add "compileBitcode: false" to export options plist as this thread says: https://github.com/fastlane/fastlane/issues/9642

For NativeScript,

1) Find and open ios-project-service.js globally installed in your environment.
If you are using nodebrew, it is found in the following path:
~/.nodebrew/current/lib/node_modules/nativescript/lib/services

2) Find "exportDevelopmentArchive" method.
3) Add following lines to the plistTemplate defined in the method.

<key>compileBitcode</key>
<false/>

4) plistTemplate should be like this:

let plistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>${exportOptionsMethod}</string>`;
            if (options && options.provision) {
                plistTemplate += `    <key>provisioningProfiles</key>
<dict>
    <key>${projectData.projectId}</key>
    <string>${options.provision}</string>
</dict>`;
            }
            plistTemplate += `
    <key>uploadBitcode</key>
    <false/>

    <key>compileBitcode</key>  <!--- Added --->
    <false/>   <!--- Added --->
</dict>
</plist>`;

I know this is a hacky solution and don't think a best solution. If there is more elegant way, please let me know.

@hosikiti : I am using Nativescript Angular project. I am not able to find ios-project-service.js
Could please let me know that how can I find it.. ??

@pap5508 Check where your tns command is. You can find the location by command: which tns. Tell me the result.

@hosikiti :

admin$ which tns
/usr/local/bin/tns

When I write command open /usr/local/bin/

screen shot 2018-03-13 at 16 38 35

@pap5508 Thanks. Then, your ios-project-service.js should be in
/usr/local/lib/node_modules/nativescript/lib/services.

Hey guys, we've applied the mentioned change in ios-project-service, so you will no longer have to modify the source code of your CLI. The fix will be included in the next official release.

Was this page helpful?
0 / 5 - 0 ratings