2013-11-28 37 views
3

我使用持续集成工具,该工具使用分发标识和Ad Hoc移动设置构建应用程序。这个应用程序发送到一个网站进行临时部署,一切正常。将iOS应用程序从分发标识移至开发人员标识

但是现在我想在构建工作流程中添加一个步骤来执行UI自动化测试。 Instruments需要一个以开发人员身份签名的应用程序,因此,我希望/需要(Q.A.团队实际需要)使用开发人员证书退出先前创建的.ipa,而不是使用开发人员证书构建新版本的应用程序。我用下面的命令辞职的应用:

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安装“有效载荷/ 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 (e.g. 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.x的4个设备)。所以这个问题与iOS 7有关。

如果应用程序是直接用开发人员身份构建的,那么效果很好,所以我猜测在签名阶段失败了。我还做了一个协同设计上辞职的应用-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”变量,我试过了,我并没有获得更多的成功。 PS:我读了一些关于“iOS开发者”的地方,它可能已经取代了证书标题中的“iPhone开发者”,但是我没有找到关于这方面的更多信息。

回答

1

我终于发现了这个问题,当在构建过程中使用开发人员身份时,Xcode嵌入一个Entitlements.plist文件,该文件包含get-task-allow => true,当身份为分布时,此get-task- allow设置为false。当“发行”应用程序“被辞职”时,我没有将--entitlements选项传递给codesign,因此该应用程序仍然不是适用于乐器的有效“开发者”应用程序。

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

它现在可以工作了,我希望Xcode添加到Entitlements文件中的其他键不会丢失(因为我在我的codesign命令调用中使用的键只包含get-task-allow键)。

+0

这个entitlements.plist文件位于哪里?我怎么编辑它? –

+0

Xcode为你创建它(在编译期间),除非你自己创建它并将它添加到你的xcode项目 – LiohAu

+0

我得到了Xcode将创建它,但它创建它在哪里,我的意思是我在哪里找到它? –

3

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

抓住原始的发行权利:

/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 

p.s.无需删除_CodeSignature,codesign -f将替代它。

+0

非常感谢这些信息。但是现在我不知道是否应该将我的答案标记为正确或者是你的答案,因为它们都是答案的一部分^^ – LiohAu

+0

感谢您的解决方案!我试图弄清楚为什么仪器会警告我,我的应用程序需要用开发标识进行签名,当所有事情都同意时,我就是这样。我必须更新我的辞职脚本才能在签名为开发版本时将get-task-allow设置为true。 – Seth

相关问题