Failed to generate release build of cordova ios app

99封情书 提交于 2020-01-10 19:56:12

问题


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.

1) cordova build ios --release

Compiling app on platform "ios" via command "/Applications/MAMP/htdocs/MyTest/MyTestApp/platforms/ios/cordova/build" --release Platform "ios" compiled successfully.

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"

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

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 : []

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

Done checking the original app

Embedding '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'

回答1:


Hmmh, I'm having a similar problem like Shashi.

When running 'cordova buld ios [--release]' from shell and then doing a 'xcrun ...' afterwards it works for me okay.

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.

So - to me - it seems, as if cordova returns to shell while it isn't completely finished (?)

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 ???




回答2:


So, finally I got everything to work okay ... :D

The problem of Jenkins complaining about a failed 'codesign ...' run is a MacOS (configuration) issue

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 (!)

For now I realize this by running the unlock of the login.keychain within the Jenkins job before running my build script

like: in the Jenkins job for "execute 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

See as well: [1]: Keychain won't unlock from Jenkins script unless user logged in




回答3:


Meanwhile I found: Fact is, that - when cordova exits and returns to shell - cordova related activities are NOT completed yet!

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.

So I do in my script (which i call '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

/usr/bin/codesign --verify -vvvv [...] Program /usr/bin/codesign returned 1 : [...] code object is not signed at all

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 :)




回答4:


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.

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.*

To make an 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



来源:https://stackoverflow.com/questions/19783931/failed-to-generate-release-build-of-cordova-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!