Xcode 8升级到Xcode 9,构建Cordova App报requires a provisioning profile错误
Xcode 8升级到Xcode 9,重新构建Cordova app,报错:
error: exportArchive: "App Name.app" requires a provisioning profile.
Error Domain=IDEProvisioningErrorDomain Code=9 ""App Name.app" requires a provisioning profile." UserInfo={NSLocalizedDescription="App Name.app" requires a provisioning profile., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}
** EXPORT FAILED **
Error: Error code 70 for command: xcodebuild with args: -exportArchive,-archivePath,App Name.xcarchive,-exportOptionsPlist,/Users/Shared/Workspace/github/AppName/platforms/ios/exportOptions.plist,-exportPath,/Users/Shared/Workspace/github/AppName/platforms/ios/build/device
解决方法
这个错误主要是Cordova生成的ExportOptions.plist缺失Xcode 9所需要的key。
这个bug已经在cordova-ios 4.5.1修复,修复内容为CB-13315: (ios) fixed bug building for ios using Xcode 9。
Cordova的build.json文件可以添加iCloudContainerEnvironment配置项 。iCloudContainerEnvironment = Production/Development只有在通知推送时需要。
build.json类似于:
"ios": {
"debug": {
"codeSignIdentitiy": "iPhone Developer",
"developmentTeam":"MYTEAMID",
"provisioningProfile": "provisioning profile name or UUID",
"packageType": "developer",
"iCloudContainerEnvironment": "Development"
},
"release": {
"codeSignIdentitiy": "iPhone Distribution",
"developmentTeam":"MYTEAMID",
"provisioningProfile": "provisioning profile name or UUID",
"packageType": "ad-hoc",
"iCloudContainerEnvironment": "Production"
}
}
其中,provisioningProfile可以为名称或者是UUID。