Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to generate release build of cordova ios app

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'
like image 516
Shashi Avatar asked Nov 05 '13 07:11

Shashi


2 Answers

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

like image 186
Juergen Klasen Avatar answered Oct 28 '22 03:10

Juergen Klasen


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

like image 1
Vizllx Avatar answered Oct 28 '22 05:10

Vizllx