9
votes

I make release builds by calling:

xcodebuild -project HelloWorld -sdk iphoneos5.1 -configuration Release install

But for PhoneGap apps I get this error:

** BUILD FAILED **

The following build commands failed: CompileC build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/AppDelegate.o Phonefinch/Classes/AppDelegate.m normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure)

When I try:

xcodebuild -project HelloWorld -sdk iphoneos5.1 -configuration Release clean build

I get:

2012-10-04 22:51:52.776 xcodebuild[20016:4107] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-1559/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/SpecificationTypes/XCGccMakefileDependencies.m:87 Details: Failed to load dependencies output contents from ``/Users/camobap-mac/Projects/Phonefinch/build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/AppDelegate.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “AppDelegate.d” couldn’t be opened because there is no such file." UserInfo=0x400eabf40 {NSFilePath=/Users/camobap-mac/Projects/Phonefinch/build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/AppDelegate.d, NSUnderlyingError=0x40079c140 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/Users/camobap-mac/Projects/Phonefinch/build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/AppDelegate.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *, void (^)(NSString *)) Thread: {name = (null), num = 7} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. ** BUILD FAILED **

The following build commands failed: CompileC build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv7/AppDelegate.o Phonefinch/Classes/AppDelegate.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler CompileC build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/AppDelegate.o Phonefinch/Classes/AppDelegate.m normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler (2 failures) 2012-10-04 22:52:04.887 xcodebuild[20016:4f0f] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-1559/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/SpecificationTypes/XCGccMakefileDependencies.m:87 Details: Failed to load dependencies output contents from ``/Users/camobap-mac/Projects/Phonefinch/build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/MainViewController.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “MainViewController.d” couldn’t be opened because there is no such file." UserInfo=0x400ef6e40 {NSFilePath=/Users/camobap-mac/Projects/Phonefinch/build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/MainViewController.d, NSUnderlyingError=0x400ef24a0 "The operation couldn’t be completed. No such file or directory"}. User info: { NSFilePath = "/Users/camobap-mac/Projects/Phonefinch/build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/MainViewController.d"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; }. Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *, void (^)(NSString *)) Thread: {name = (null), num = 10} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide. ** BUILD FAILED **

The following build commands failed: CompileC build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/AppDelegate.o Phonefinch/Classes/AppDelegate.m normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler CompileC build/Phonefinch.build/Release-iphoneos/Phonefinch.build/Objects-normal/armv6/MainViewController.o Phonefinch/Classes/MainViewController.m normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler (2 failures)

If I call cordova/debug -> ** BUILD SUCCESS **, but my .app is compiled in Debug mode. How can I make a release build on the command line?

4
Can you elaborate on your question a little? Are you talking about generating an iPA? - Ben Clayton
No, just .app. But i we possible generating .ipa with it I will be interest too. - CAMOBAP
Ok. If your app is set up to use cordova, then the above command should work. What's the actual issue you're facing? - Ben Clayton
When I call cordova/debug I'm get app that builded in Debug mode, but i havent some cordova/release tool. Actual issue is: How can we build PhoneGap app in Release mode because xcodebuild -project HelloWorld -sdk iphoneos5.1 -configuration Release install don't work - CAMOBAP
When you say it doesn't work. What's the error message? - Just a coder

4 Answers

3
votes

I had the exact same issue. I dont know if my solution applies to your problem. However, here is how I solved it: I suppose you are using the cordova sub project from within your Xcode project. Check if you have the same configuration name for the cordova project.

For example: When your release configuration for your main project is called "ReleaseAdHoc", make sure your cordova subroject also has a configuration with this name. Furthermore, make sure that you select these configurations for the "Archive" process for both, your main project and the subproject.

Hope this helps.

1
votes

I have found solution - cordova utility is a key. But we need to do some steps to prepare it:

  1. add script to hooks/after_build/010_sign_ios.js

    #!/usr/bin/env node
    
    var app_name = "HelloWorld";
    var sign_crt_name = "iPhone Distribution: My company Group BV";
    var provision_path = "$PWD/Ad_Hock_Distribution_Helloworld.mobileprovision";
    
    var output_ipa_path = "$PWD/platforms/ios/build/device/" + app_name + ".ipa";
    var sys = require('sys');
    var exec = require('child_process').exec;
    
    var cliCommand = process.env.CORDOVA_CMDLINE;
    var isRelease = (cliCommand.indexOf('--release') > -1);
    var isDevice = (cliCommand.indexOf('--device') > -1);
    var platform = process.env.CORDOVA_PLATFORMS;
    
    if (platform === 'ios' && isDevice && isRelease) {
        function puts(error, stdout, stderr) {
            sys.puts(stdout)
        }
    
        exec("xcrun -sdk iphoneos PackageApplication " + 
             "-v \"$PWD/platforms/ios/build/device/" + app_name + ".app\" " +
             "-o \"" + output_ipa_path + "\" " + 
             "--sign \"" + sign_crt_name + "\" " + 
             "--embed \"" + provision_path + "\"", puts);
    }
    

    But fix app_name, sign_crt_name and provision_path variables according you needs

  2. Run cordova build ios --release --device

  3. Use $PWD/platforms/ios/build/device/HelloWorld.ipa to delivery or install via cmd by great ideviceinstaller tool

1
votes

It seems there are very fewer resources to guide how to automate phonegap build process for ios. After trying a lot of trial and error and research I settled with this approach. First create a file json file in the root folder as mentioned in cordova docs. Filename can be anything. If the file name is build.json you don't need to pass any parameters while building the app. For convenience the build.json for automatic signing which is recommended one looks like this:

{
    "ios": {
        "debug": {
            "codeSignIdentity": "iPhone Developer",
            "developmentTeam": "FG35JLLMXX4A",
            "packageType": "development",
            "automaticProvisioning": true,
            "buildFlag": [
                "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
                "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
                "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
            ]
        },
        "release": {
            "codeSignIdentity": "iPhone Developer",
            "developmentTeam": "FG35JLLMXX4A",
            "packageType": "app-store",
            "automaticProvisioning": true,
            "buildFlag": [
                "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
                "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
                "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
            ]
        }
    }
}

You can read more in the link mentioned above.

You can now build your app with:

phonegap build ios (if filename is build.json)
phonegap build ios --buildConfig path/xyz.json (if filename is other than build.json)

cd platforms/ios
xcodebuild archive -workspace app.xcworkspace -scheme scheme-name -configuration Release -archivePath IPA-name.xcarchive
xcodebuild -exportArchive -archivePath IPA-name.xcarchive -exportPath IPA-name.ipa -exportOptionsPlist exportOptions.plist
-1
votes

I was able to build from command line by using CONFIGURATION_BUILD_DIR parameter in xcodebuild command and specifying empty build directory. Seems files build by XCode conflicts with xcodebuild command