xcode 无法生成cordova ios应用程序的发布版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19783931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to generate release build of cordova ios app
提问by Shashi
I am using phonegap CLI 3.1 and XCode5. I am trying to generate the build for release mode through Phonegap CLI and Xcrun. I don't want to use Phonegap Build to upload the mobileprovision or whatever the process of them. I want to do it by xcrun to assign the mobileprovison to release build.
我正在使用 phonegap CLI 3.1 和 XCode5。我正在尝试通过 Phonegap CLI 和 Xcrun 生成发布模式的构建。我不想使用 Phonegap Build 上传 mobileprovision 或它们的任何过程。我想通过 xcrun 来分配 mobileprovison 来发布构建。
1) cordova build ios --release
1) 科尔多瓦构建 ios --release
Compiling app on platform "ios" via command "/Applications/MAMP/htdocs/MyTest/MyTestApp/platforms/ios/cordova/build" --release Platform "ios" compiled successfully.
通过命令“/Applications/MAMP/htdocs/MyTest/MyTestApp/platforms/ios/cordova/build”在平台“ios”上编译应用程序——发布平台“ios”编译成功。
2) sudo xcrun -sdk iphoneos PackageApplication -v "ios/build/emulator/MyTestApp.app" -o "/Users/mymac/Desktop/Testnew/MyTestApp.ipa" --sign "iPhone Distribution: NAME (TEAM_ID)" --embed "MyTestApp_Dis.mobileprovision"
2) sudo xcrun -sdk iphoneos PackageApplication -v "ios/build/emulator/MyTestApp.app" -o "/Users/mymac/Desktop/Testnew/MyTestApp.ipa" --sign "iPhone Distribution: NAME (TEAM_ID)" - - 嵌入“MyTestApp_Dis.mobileprovision”
Packaging application: 'ios/build/emulator/MyTestApp.app'
Arguments: embed=MyTestApp_Dis.mobileprovision verbose=1 output=/Users/mymac/Desktop/Testnew/MyTestApp.ipa sign=iPhone Distribution: NAME (TEAM_ID)
Environment variables:
HOME = /Users/mymac
SUDO_GID = 20
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
VERSIONER_PERL_PREFER_32_BIT = no
MAIL = /var/mail/root
SSH_AUTH_SOCK = /tmp/launch-zsBMC8/Listeners
LANG = en_US.UTF-8
USER = root
LOGNAME = root
__CF_USER_TEXT_ENCODING = 0x0:0:0
USERNAME = root
PATH = /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
SUDO_USER = mymac
SHELL = /bin/bash
TERM = xterm-256color
SUDO_COMMAND = /usr/bin/xcrun -sdk iphoneos PackageApplication -v ios/build/emulator/MyTestApp.app -o /Users/mymac/Desktop/Testnew/MyTestApp.ipa --sign iPhone Distribution: NAME (TEAM_ID) --embed MyTestApp_Dis.mobileprovision
SUDO_UID = 501
VERSIONER_PERL_VERSION = 5.12
打包应用程序:'ios/build/emulator/MyTestApp.app' 参数:embed=MyTestApp_Dis.mobileprovision verbose=1 output=/Users/mymac/Desktop/Testnew/MyTestApp.ipa sign=iPhone Distribution:NAME (TEAM_ID)
环境变量:
HOME = /Users/mymac
SUDO_GID = 20
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
VERSIONER_PERL_PREFER_32_BIT = no
MAIL = /var/mail/root
SSH_AUTH_SOCK /tmp/launch-zsBMC8/Listeners
LANG = en_US.UTF-8
USER = root
LOGNAME = root
__CF_USER_TEXT_ENCODING = 0x0:0:0
USERNAME = root
PATH = /usr/bin:/bin:/usr/sbin:/sbin:/ usr/local/bin:/usr/local/git/bin
SUDO_USER = mymac
SHELL = /bin/bash
TERM = xterm-256color
SUDO_COMMAND = /usr/bin/xcrun -sdk iphoneos PackageApplication -v ios/build/emulator/MyTestApp.app -o /Users/mymac/Desktop/Testnew/MyTestApp.ipa --签署 iPhone 分配:NAME (TEAM_ID) --embed MyTestApp_Dis.mobileprovision
SUDO_UID = 501
VERSIONER_PERL_VERSION = 5.12
Output directory: '/Users/mymac/Desktop/Testnew/MyTestApp.ipa'
Temporary Directory: '/tmp/W81FhZ9VAH' (will NOT be deleted on exit when verbose set)
+ /bin/cp -Rp ios/build/emulator/MyTestApp.app /tmp/W81FhZ9VAH/Payload
Program /bin/cp returned 0 : []
输出目录:'
/Users/mymac/Desktop/Testnew/ MyTestApp.ipa'临时目录:'/tmp/W81FhZ9VAH'(详细设置时不会在退出时删除)
+ /bin/cp -Rp ios/build/emulator/ MyTestApp.app /tmp/W81FhZ9VAH/Payload
Program /bin/cp 返回 0 : []
Checking original app
检查原始应用程序
- /usr/bin/codesign --verify -vvvv ios/build/emulator/MyTestApp.app
Program /usr/bin/codesign returned 1 : [ios/build/emulator/MyTestApp.app: code object is not signed at all
In architecture: i386
] Codesign check fails : ios/build/emulator/MyTestApp.app: code object is not signed at all In architecture: i386
- /usr/bin/codesign --verify -vvvv ios/build/emulator/MyTestApp.app
Program /usr/bin /codesign Returned 1 : [ios/build/emulator/MyTestApp.app: code object is not signed at all
in architecture :i386
] 代码设计检查失败:ios/build/emulator/MyTestApp.app:代码对象根本没有签名在架构中:i386
Done checking the original app
完成检查原始应用程序
Embedding 'MyTestApp_Dis.mobileprovision'
嵌入“MyTestApp_Dis.mobileprovision”
- /bin/rm -rf /tmp/W81FhZ9VAH/Payload/MyTestApp.app/embedded.mobileprovision Program /bin/rm returned 0 : []
- /bin/cp -rp MyTestApp_Dis.mobileprovision /tmp/W81FhZ9VAH/Payload/MyTestApp.app/embedded.mobileprovision Program /bin/cp returned 0 : []
- /usr/bin/codesign -d --entitlements /tmp/W81FhZ9VAH/entitlements_rawixGWnKhi /tmp/W81FhZ9VAH/Payload/MyTestApp.app
Program /usr/bin/codesign returned 1 : [/tmp/W81FhZ9VAH/Payload/MyTestApp.app: code object is not signed at all
]
error: Failed to read entitlements from '/tmp/W81FhZ9VAH/Payload/MyTestApp.app'
- /bin/rm -rf /tmp/W81FhZ9VAH/Payload/MyTestApp.app/embedded.mobileprovision 程序 /bin/rm 返回 0 : []
- /bin/cp -rp MyTestApp_Dis.mobileprovision /tmp/W81FhZ9VAH/Payload/MyTestApp.app/embedded.mobileprovision 程序 /bin/cp 返回 0 : []
- /usr/bin/codesign -d --entitlements /tmp/W81FhZ9VAH/entitlements_rawixGWnKhi /tmp/W81FhZ9VAH/Payload/MyTestApp.app 程序 /usr/bin/codesign 返回 1 : [/tmp/W81FhZ9VAH/Payload/MyTestApp.app: 代码对象根本没有签名]
错误:无法从“/tmp/W81FhZ9VAH/Payload/MyTestApp.app”读取权利
回答by Juergen Klasen
Hmmh, I'm having a similar problem like Shashi.
嗯,我遇到了和 Shashi 类似的问题。
When running 'cordova buld ios [--release]' from shell and then doing a 'xcrun ...' afterwards it works for me okay.
当从 shell 运行 'cordova buld ios [--release]' 然后执行 'xcrun ...' 时,它对我有用。
BUT: When running this sequence from within a script, I receive a "Codesign check fails ..." error too ...
但是:从脚本中运行此序列时,我也收到“代码设计检查失败...”错误...
If I insert (like) a "wait"cycle inside my script between the cordova and the xcrun call, it works.
如果我在我的脚本中在cordova 和xcrun 调用之间插入(比如)一个“等待”循环,它就可以工作。
So - to me - it seems, as if cordova returns to shell while it isn't completely finished (?)
所以 - 对我来说 - 似乎cordova在它没有完全完成的时候返回到shell(?)
Fact is if I code my script like
事实是,如果我像这样编写脚本
#!/bin/bash
cordova build ios --release
sleep 5
sh -c "xcrun ..."
it's working for me. Question:Is it a bug in cordova/phonegap ???
它对我有用。 问题:这是cordova/phonegap 中的错误吗???
回答by Juergen Klasen
Meanwhile I found: Fact is, that - when cordova exits and returns to shell - cordova related activities are NOT completed yet!
同时我发现:事实是-当cordova退出并返回shell时-cordova相关活动尚未完成!
It takes a while after the cordova exit, for the 'platforms/ios/AppName/_CodeSignature/CodeResources' file to show up. This file obviously is essential for the 'codesign' which is started by xcrun command to succeed.
在cordova 退出后需要一段时间才能显示“platforms/ios/AppName/_CodeSignature/CodeResources”文件。这个文件显然对于 xcrun 命令启动的“代码设计”是必不可少的。
So I do in my script (which i call 'buildit.sh')
所以我在我的脚本中做(我称之为'buildit.sh')
#!/bin/bash
[...]
cordova build ios --release
signaturefile="platforms/ios/build/device/$appname/_CodeSignature/CodeResources"
echo DEBUG:signatur file is $signaturefile
while [ ! -f $signaturefile ]
do
echo waiting
sleep 1
done
xcrun ...
Then the whole build/packaging process in one script succeeds.
然后在一个脚本中的整个构建/打包过程成功。
However: Running the script from my ContinuousIntegration server Jenkins, I observe that this criteria may be essential, but not enough. From the CI I still get a
但是:从我的 ContinuousIntegration 服务器 Jenkins 运行脚本,我观察到这个标准可能是必不可少的,但还不够。从 CI 中我仍然得到一个
/usr/bin/codesign --verify -vvvv [...] Program /usr/bin/codesign returned 1 : [...] code object is not signed at all
/usr/bin/codesign --verify -vvvv [...] 程序 /usr/bin/codesign 返回 1 : [...] 代码对象根本没有签名
error!??
错误!??
EDIT (05.12.2013):This is due to the fact that the Jenkins service couldn't access the keychain. E.g. doing in the Jenkins job an unlock of the keychain prior running the build script sorts it. (May not be the most elegant solution, but at least it prooves the problem not to be in the scripting :)
编辑 (05.12.2013):这是因为 Jenkins 服务无法访问钥匙串。例如,在 Jenkins 工作中,在运行构建脚本之前解锁钥匙串对其进行排序。(可能不是最优雅的解决方案,但至少它证明了问题不在脚本中:)
回答by Juergen Klasen
So, finally I got everything to work okay ... :D
所以,最后我让一切正常工作......:D
The problem of Jenkins complaining about a failed 'codesign ...'run is a MacOS (configuration) issue
Jenkins 抱怨“代码设计……”运行失败的问题是 MacOS(配置)问题
The crucial thing is to allow the Jenkins access to the keychain of the system. The allowed access for the Login-shell of the Jenkins user is different from the Jenkins server process running under the Jenkins user account (!)
关键是允许 Jenkins 访问系统的钥匙串。Jenkins 用户的 Login-shell 的允许访问与在 Jenkins 用户帐户下运行的 Jenkins 服务器进程不同(!)
For now I realize this by running the unlock of the login.keychain within the Jenkins job before running my build script
现在我通过在运行我的构建脚本之前在 Jenkins 作业中运行 login.keychain 的解锁来实现这一点
like: in the Jenkins job for "execute shell"
像:在 Jenkins 的“执行 shell”工作中
security unlock-keychain -p password /Users/Shared/Jenkins/Library/Keychains/login.keychain
echo ##### building now ######################
./buildit.sh ios --release -v
This may not be the 100% nicest solution - but for now it works :P
这可能不是 100% 最好的解决方案 - 但现在它有效:P
See as well: [1]: Keychain won't unlock from Jenkins script unless user logged in
另请参阅:[1]:除非用户登录,否则钥匙串不会从 Jenkins 脚本解锁
回答by Vizllx
In order to skip the code signing you can perform a manual build from the console like this:
为了跳过代码签名,您可以从控制台执行手动构建,如下所示:
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO Use additionally the -configuration, -target and -sdk parameters in order to define your build settings.
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO 另外使用 -configuration、-target 和 -sdk 参数来定义您的构建设置。
To Disable Code Signing:
禁用代码签名:
*Go to /Applications. Right click on XCode and select 'Show Package Contents'. Copy Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist to your desktop. (Make sure to actually copy and paste. No drag and drop) Open it and under DefaultProperties set CODE_SIGNING_REQUIRED to NO. Copy it back and replace the original file. Restart XCode. Open your project. In Project Navigator select your project and open Build Settings section of your porject (and not any particular target) Under Code Signing find Code Signing Identity and for both Debug and Release modes set Any iOS SKD to Don't Code Sign. Now you should be able to build your project without any errors.*
*转到/应用程序。右键单击 XCode 并选择“显示包内容”。将 Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist 复制到您的桌面。(确保实际复制和粘贴。不要拖放)打开它并在 DefaultProperties 下将 CODE_SIGNING_REQUIRED 设置为 NO。将其复制回来并替换原始文件。重新启动 XCode。打开您的项目。在 Project Navigator 中选择您的项目并打开您的项目的 Build Settings 部分(而不是任何特定目标)在 Code Signing 下找到 Code Signing Identity,对于调试和发布模式,将 Any iOS SKD 设置为 Don't Code Sign。现在您应该能够在没有任何错误的情况下构建您的项目。*
To make an IPA:
制作 IPA:
In 'Project Navigator' select Products Right click on [NameOfYourProject].app and select 'Show in Finder'. Create a folder and name it Payload Move [NameOfYourProject].app to Payload. Compress Payload and rename it to [NameOfYourProject].ipa
在“项目导航器”中选择“产品”右键单击 [NameOfYourProject].app 并选择“在 Finder 中显示”。创建一个文件夹并将其命名为 Payload 将 [NameOfYourProject].app 移动到 Payload。压缩 Payload 并将其重命名为 [NameOfYourProject].ipa