Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap how to make a release build from the command-line

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?

like image 353
CAMOBAP Avatar asked Sep 30 '12 09:09

CAMOBAP


People also ask

What is the command to create a Phonegap HelloWorld application?

--id , -i package package name (default: "com. phonegap. hello-world")

What does cordova build command do?

cordova run commandPrepares, builds, and deploys app on specified platform devices/emulators. If a device is connected it will be used, unless an eligible emulator is already running.


2 Answers

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.

like image 156
DucatiNerd Avatar answered Nov 06 '22 05:11

DucatiNerd


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

like image 30
CAMOBAP Avatar answered Nov 06 '22 04:11

CAMOBAP