Can't generate release build for Cordova iOS App
Asked Answered
T

2

11

I am using Phonegap CLI 3.1 and XCode5. I want to generate the release build for iPhone Application through command line, I have valid distribution certificate and mobile provisioning profile. I want to generate the release build totally through command and don't want to use XCode GUI or Phonegap Build. I have tried too much with xcodebuild, xcrun and even corodva build command but none of them provide me the release build file (either in .app format or .ipa).

Method 1 (Use xcodebuild)

a) xcodebuild -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release

** BUILD FAILED **
The following build commands failed:

CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MainViewController.o MyApp/Classes/MainViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7s/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7s objective-c com.apple.compilers.llvm.clang.1_0.compiler
(3 failures)


Method 2 (Use corodova build and xcrun to sign the app)
a) cordova build ios -release

Compiling app on platform "ios" via command "/Users/Macuser/Desktop/MyApp/platforms/ios/cordova/build" --release Platform "ios" compiled successfully.

b) xcrun -sdk iphoneos PackageApplication -v "build/Release-iphoneos/MyApp.app" -o "build/Release-iphoneos/MyApp.ipa" --sign "iPhone Distribution: NAME (ID)" --embed "PROFILE_UUID.mobileprovision"

error: Failed to read entitlements from '/tmp/iyibGn3aUv/Payload/MyApp.app

Therein answered 6/11, 2013 at 14:0 Comment(0)
G
10

The problem is that you do not have proper schemes. When phonegap project is generated it does not contain any schemes and thus linking to the phonegap files is incorrect.

Go to the phonegap generated project in console and put 'xcodebuild -list' in the output you will get that there is no schemes in the project.

Open generated by phonegap project in the xcode - this will generate schemes.

Now you can build this using xcodebuild(Remember to fill up the proper scheme name):

xcodebuild -scheme YOURSCHEMENAME -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release

For continous integration this is bad solution because you have to launch the xcode GUI to generate the schemes but I did not found any other solution for this problem. If someone know how to generate scheme using command line it would be nice of him to write it down.

Gutsy answered 15/11, 2013 at 17:13 Comment(7)
did you figure out a solution for this ?. I am facing the same issue. Any help is highly appreciated.Sillsby
@Gutsy is there a way to generate the schemes using commandline? I'm trying to automate the building so i can't really do something like 'open en close xcode'..Suspensoid
You can generate the schemes automatically by using the xcodeproj Ruby gem (ie: gem install xcodeproj) and the following tiny script gist.github.com/shanesmith/8b88720c19b910cc9900Leukemia
here a longer more detailed answerStuder
I have project where the schemes are created from GUI and shared, when I run the xcodebuild command its not working showing the coredova is not found.Is there any solution for coredova projects?Thekla
I wasted HOURS of my life realising the xcodebuild process is stuck in my jenkins just because I didn't open it up to generate the schemes. Thank you, and @Leukemia !Reese
Apparently you can't use -alltargets when specifying a -scheme on the command line.Jariah
H
-3

First, you need to create your app in iTunes Connect (This is in the member center of your iOS developer account). If you've already created your profiles and certificates, then you can select the correct one in iTunes Connect. Here is where you name your app, set a price, write a description, and upload screen shots and a large icon. Make sure you fill in all information and upload all images for your app. You will know when you are done the status of your app changes to 'Waiting for Upload".

After you've created your app successfully in iTunes Connect, to generate an .IPA file for distribution (either for the AppStore or Ad-Hoc) in Xcode you need to select your Project in the file tree (at the top of the tree). Then make sure your 'Targets' is selected to the right.

Choose 'Build Settings". Then go to the section where is says Code Signing. For 'Release', make sure that the correct iPhone Distribution identity or profile is selected.

Below 'Release' it should say 'Any iOS SDK'. Make sure that it says 'IOS Distribution' next to it.

If you have the correct certificates and profiles in the keychain, you can now in the menu at the top choose Product > Archive.

If it doesn't build, then press the run button to build your project. Xcode should say that it is archiving.

After it archive's successfully, go to the Organizer. In the menu at the top choose Window > Organizer. Now click Archives.

If your project successfully archived you will see it here. First you need to Validate your project with iTunes Connect. You will need to enter your iOS Developer login info. Xcode 5 does a pretty good job of detecting the correct profiles so you should see it in there.

If your app validates then you can then distribute either to the App Store or as an Ad-Hoc distribution. Depending on which profile you have.

This is the process for distributing apps either Native or Phonegap. It doesn't matter, I've built both.

I would suggest doing it this way, in case your app doesn't validate. Xcode will then tell you what you need to do to fix. Then once you fix everything. Create a new archive and try until it validates.

Hephaestus answered 12/11, 2013 at 6:56 Comment(1)
As i have mentioned already i don't want to use xcode gui features. I know how to build app for release and Adhoc using XCode GUI. I don't want to open the xcode. I want to do the same using command line. like use xcodebuild, xcrun or cordova build command.Therein

© 2022 - 2024 — McMap. All rights reserved.