Wednesday, August 22, 2012

Gotcha of the Day: PhoneGap + iOS: Failing to build from the command line

Today I needed to setup my PhoneGap app to produce a iOS version. No problem, I figured, PhoneGap provides a super geeky command line guide for building on both Android and iOS. The steps worked perfectly on Android so I'd figure they would work just as well on iOS.

The first command, bin/create silently ran, which I took as a good sign.

The second command, cordova/debug produced quite a bit of noise and then a big 'ol error:

Build settings from command line:
    ARCHS = i386
    CONFIGURATION_BUILD_DIR = /Users/user1603/dt/bar/foo/app/ios/cordova/../build
    SDKROOT = iphonesimulator5.0
    VALID_ARCHS = i386

=== CLEAN NATIVE TARGET FooApp OF PROJECT FooApp WITH CONFIGURATION Debug ===
...trimmed...

** CLEAN SUCCEEDED **


=== BUILD NATIVE TARGET FooApp OF PROJECT FooApp WITH CONFIGURATION Debug ===
Check dependencies

ProcessInfoPlistFile cordova/../build/FooApp.app/Info.plist FooApp/FooApp-Info.plist
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    builtin-infoPlistUtility FooApp/FooApp-Info.plist -genpkginfo /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app/PkgInfo -expandbuildsettings -format binary -platform iphonesimulator -o /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app/Info.plist

PhaseScriptExecution "Touch www folder" build/FooApp.build/Debug-iphonesimulator/FooApp.build/Script-304B58A110DAC018002A0835.sh
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv ACTION build
    setenv ALTERNATE_GROUP _developer
    ...about 298 setenv's removed...
    setenv YACC /Developer/usr/bin/yacc
    /bin/sh -c /Users/user1603/dt/bar/foo/app/ios/build/FooApp.build/Debug-iphonesimulator/FooApp.build/Script-304B58A110DAC018002A0835.sh

CpResource /VERSION cordova/../build/FooApp.app/VERSION
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /VERSION /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app
error: /VERSION: No such file or directory

CpResource FooApp/Resources/icons/icon-72.png cordova/../build/FooApp.app/icon-72.png
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/user1603/dt/bar/foo/app/ios/FooApp/Resources/icons/icon-72.png /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app

CopyPlistFile cordova/../build/FooApp.app/Cordova.plist FooApp/Resources/../Cordova.plist
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    builtin-copyPlist --convert binary1 --outdir /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app -- FooApp/Resources/../Cordova.plist

CpResource www cordova/../build/FooApp.app/www
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/user1603/dt/bar/foo/app/ios/www /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app

CpResource FooApp/Resources/icons/icon.png cordova/../build/FooApp.app/icon.png
    cd /Users/user1603/dt/bar/foo/app/ios
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/user1603/dt/bar/foo/app/ios/FooApp/Resources/icons/icon.png /Users/user1603/dt/bar/foo/app/ios/cordova/../build/FooApp.app

Verify exit code of build task 'CpResource icon.png'
Build task failed without generating error messages.

Huh?

I poked around on the web, and for the life of me, couldn't find anyone else who had the same problem. I tried tracing the build scripts a bit, but that didn't go anywhere. Finally, I just went for a run.

While out on my run I thought of a new plan: I'd build the app first using the GUI tools and *then* switch to command line mode.

I went ahead and slowly and carefully walked through the iOS Getting Started guide. I knew I was on to something when went ahead and installed Cordova-2.0.0.pkg as the instructions outlined. I was also pleased to see that the instructions for starting a new project are to run the same create script as the command line utility calls for.

Once I installed the required pkg file and re-ran create my application effortlessly built.

In other words: to use the command line tools in Android, just follow the Command Line instructions. To use the command line tools in iOS, follow the Getting Started guide first, then switch over to the command line tool set.

Along with the PhoneGap docs, I also found this tutorial top be handy, even if it was a bit dated.

1 comment:

  1. Wow. Thanks. I'm gonna review my instruction guide for this.

    ReplyDelete