将iOS应用程序从分发标识中分配给开发者标识

我使用持续集成工具,使用分发标识和Ad Hoc移动设备构build应用程序。 这个应用程序发送到一个网站进行临时部署,一切正常。

但是现在我想在构build工作stream中添加一个步骤来执行UI自动化testing。 仪器需要一个以开发人员身份签名的应用程序,因此,我希望/需要(QA团队实际需要)使用开发人员证书来退出之前创build的.ipa,而不是使用开发人员证书构build新版本的应用程序。 我使用以下命令来退出应用程序:

unzip "App.ipa" rm -rf "Payload/App.app/_CodeSignature" "Payload/App.app/CodeResources" cp "Dev.mobileprovision" "Payload/App.app/embedded.mobileprovision" /usr/bin/codesign -f -s "iPhone Developer: john doe" --resource-rules "Payload/App.app/ResourceRules.plist" "Payload/App.app" 

然后,我使用fruitstrap安装“Payload / App.app”(我试图用组织者安装它不会改变任何东西),我终于执行这样的仪器:

 instruments -w 5f9...3fd -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate "App" -e UIASCRIPT /Users/../automation-tests-scripts/test-instruments.js -e UIARESULTSPATH /Users/../test-reports/ 

仪器失败,出现以下错误:

 2013-11-28 14:32:56.679 instruments[68408:1007] Permission to debug com.company.App was denied. The app must be signed with a development identity (eg iOS Developer). 2013-11-28 14:32:56.681 instruments[68408:1007] Recording cancelled : At least one target failed to launch; aborting run Instruments Trace Error : Error Domain=com.apple.instruments Code=1 "Error Starting Recording" UserInfo=0x7fb15b290560 {NSLocalizedDescription=Error Starting Recording, NSLocalizedRecoverySuggestion=At least one target failed to launch; aborting run} Instruments Trace Error : Failed to start trace. 

这些命令适用于在iOS 6.x上运行的iOS设备,但仅在iOS 7.x上出现以前的错误(我尝试了2个iOS 6.x设备,iPhone 4S和5,以及运行iOS 7的4个设备。 X)。 所以这个问题与iOS 7有关。

如果应用程序是直接用开发人员身份构build的,那么效果很好,所以我猜测在签名阶段失败了。 我也对辞职的应用程序做了codesign -d -vvv,它显示了这个输出

 Executable=/Users/.../App.app/App Identifier=com.company.App Format=bundle with Mach-O universal (armv7 armv7s) CodeDirectory v=20100 size=8547 flags=0x0(none) hashes=420+3 location=embedded Hash type=sha1 size=20 CDHash=f00fac8eabf174e88042f2b875505a6cacdd6b0a Signature size=4326 Authority=iPhone Developer: john doe (BXX559V2VW) Authority=Apple Worldwide Developer Relations Certification Authority Authority=Apple Root CA Signed Time=28 nov. 2013 11:56:04 Info.plist entries=27 Sealed Resources version=2 rules=5 files=290 Internal requirements count=2 size=708 

我查看了Xcode签名过程,并输出了一个“CODESIGN_ALLOCATE”variables,我尝试了这个variables,并没有获得更多的成功。

PS:我读了一些关于“iOS开发者”的地方,可以replace证书标题中的“iPhone开发者”,但是我没有find更多关于这方面的信息。

如果你想调整你的原始权利,你可以这样做。

抢原始分配权利:

 /usr/libexec/PlistBuddy -x -c "print :Entitlements " /dev/stdin <<< $(security cms -D -i production.app/embedded.mobileprovision) > entitlements.plist 

把它们变成开发权利

 /usr/libexec/PlistBuddy -c 'Set :get-task-allow true' entitlements.plist 

并更新任何其他可能不同的权利,例如推送通知

 /usr/libexec/PlistBuddy -c'Set :aps-environment development' entitlements.plist 

PS不需要删除_CodeSignature,codesign codesign -f将replace为你。

我终于发现了这个问题,当构build过程中使用开发者身份时,Xcodeembedded了一个Entitlements.plist文件,其中包含一个get-task-allow => true,当身份是分布时,这个get-task-allow被设置为假。 当“发行”应用程序被“辞职”时,我没有将一个–entitlements选项传递给codesign,所以该应用程序仍然不是一个有效的“开发者”应用程序。

添加一个Entitlements.plist文件,在我的项目中将get-task-allow设置为true,并在Distributionconfiguration中引用它,解决了问题,现在,当构build应用程序时,它包含get-task-allow => true,已经辞职了,我把这个相同的Entitlements.plist传递给了codesign选项。

现在,我希望Xcode添加到Entitlements文件中的其他键不会错过(因为我在我的codeign命令调用中使用的键只包含get-task-allow键)。