Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

Archive for the ‘xcode’ Category

Xcode 5.1 and Cordova iOS

with 122 comments

cordova_botUPDATE: Cordova CLI  3.4.1-0.1.0 is out, which includes Cordova iOS 3.4.1 which incorporates all the fixes mentioned in this blog post. Update your Cordova CLI, and if you have an existing project, do a “cordova platform update ios“.

These issues have been fixed if you are running the latest dev code (slated for 3.5.0).

There are 3 issues related to Cordova iOS 3.4.0 running with Xcode 5.1 (and its command-line tools):

1. CB-6150 – objc_msgSend causes EXC_BAD_ACCESS with plugins on arm64
2. CB-6223 – Build/linker errors
3. ios-sim does not work anymore

For the first issue, you need to look at the two files mentioned in this commit and patch the two lines affected.

For the second issue, you will need to update the Build Settings in your project. The steps are mentioned in the issue and reproduced below:

  1. Select your Project icon
  2. Choose Build Settings.
  3. For “Architectures”, select $ARCHS_STANDARD – Standard architectures (armv7, armv7s, arm64)
  4. For “Valid Architectures”, add “arm64”
  5. Select your CordovaLib.xcodeproj icon
  6. In the Build Settings for the Project (not Target), delete *all* the conditional architecture settings (hover to see the minus sign). This is what is recommended by Apple in their Xcode 5.1 Release Notes.
  7. For “Architectures”, select $ARCHS_STANDARD – Standard architectures (armv7, armv7s, arm64)
  8. For “Valid Architectures”, add “arm64”
  9. Goto 6, but now do it for “Target

For the third issue, you will have to update your ios-sim to version 1.9.0:

npm install -g ios-sim

ios-sim --version

Written by shazron

March 12, 2014 at 5:32 am

Posted in cordova, phonegap, xcode

Cordova/PhoneGap and the new Apple App Store Requirements

with 4 comments

Beginning May 1st 2013, apps submitted to the Apple App Store…

1. must be built for iOS devices with Retina display and iPhone apps must also support the 4-inch display on iPhone 5

2. will no longer accept new apps or app updates that access UDIDs

Cordova/PhoneGap fulfills requirement (1) since version 2.5.0 and fulfills requirement (2) since version 1.7.0.

But what if my Cordova/PhoneGap app, which I am unwilling to upgrade, needs to be updated and submitted to the App Store?

You will have to manually update and patch your code. It’s not going to be an easy task, and I should warn you that upgrading will be easier. The main changes are to handle the iPhone 5 sized splashscreen, and the code to handle that is only in Cordova/PhoneGap 2.5.0. You can include the iPhone 5 sized asset and this will trigger the app to be the right size, but because of our splashscreen support it needs to match iOS showing the splashscreen after that splashscreen disappears. See our SplashScreen API for more details.

To be doubly sure – select your project icon in the Project Navigator in Xcode, then select the Summary tab. Select your project target then review the App Icons and Launch Images sections – you’ll see if you are missing anything or whether the assets are not the right sizes (denoted by the yellow triangle icon with an exclamation point in it).

Written by shazron

May 1, 2013 at 7:48 pm

Posted in cordova, phonegap, xcode

Improvements in Cordova 2.0.0 for iOS

with 46 comments

With the release of Apache Cordova 2.0.0 there are some significant changes for the iOS platform. We’ve removed the problematic Xcode templates, and updated our support to iOS 4.2 and greater only. Support for ARC (Automatic Reference Counting) was planned but pushed to a later release (tentatively scheduled for 2.1.0).

1. Removal of the Xcode Templates

Initially we had Xcode 3 template support, so when Xcode 4 rolled in, we updated our templates to support Xcode 4. However, because of Xcode 4’s template limitations, this resulted in a poor user experience when first creating a new Cordova-based Application. The Xcode 4 template format is undocumented – we couldn’t add a folder reference nor add a sub-project, so we had to include a pre-built Cordova.framework and also make the developer copy in the www folder manually.

A developer had to:

  1. Build once to copy in the “www” folder (from the Cordova.framework) into their project folder on disk
  2. Locate the “www” folder in their project folder on disk
  3. Drag in the “www” folder to their project icon in Xcode

This was very error-prone and did not lead to a good “first-run” user experience. Shipping a pre-built binary (Cordova.framework) also causes problems for certain systems (unreproducible crashes with Reachability) and problems with the inability to debug errors in the Cordova library itself.

The Xcode templates have been replaced by our new command-line utility to create a new project.

2. Create a new Cordova-based Application project from the command line

Install Cordova-2.0.0.pkg and then follow the Getting Started Guide, then see the procedure at

Consult this blog post “PhoneGap 2.0 Getting Started” as well for any errors you encounter.

This template creation method eliminates all the problems with the Xcode 4 template. Create the new project, and you are ready to go immediately. Your new project also links in CordovaLib as a sub-project now, so you have access to the Cordova source code for debugging if you need to.

Moving to a command-line interface also allows for greater flexibility in tooling and packaging.

3. Debug, emulate and view the console log of your Cordova project from the command line

When you create a new Cordova-based application project, you will notice that there is a new “cordova” folder included in your project folder. In there, there are three scripts: debug, emulate and log.

Navigate to the cordova folder from, and you can type the appropriate commands to use these scripts. Using these scripts, you will never need to launch Xcode again. Details on what these scripts do are at

4. Support of iOS 4.2 and greater only (and drop iOS 3 support)

What iOS 4 allows Cordova developers to do now is to include the usage of blocks in their plugins. Also, the iOS SDK API is switching to using blocks in most of the framework APIs, and it would be great for Cordova plugins to take advantage of them. JavaScript developers will be familiar with the power of using blocks, they are similar to how they are used in JavaScript (closures and callbacks).

Also, iOS 4.2 specifically has built-in support in JavaScript for WebSockets, the DeviceOrientation API (accelerometer, gyroscope), new JavaScript data types, XHR-2 support, and others. See this blog post for more details.

5. Xcode 4 and Lion & Mountain Lion support only

Some developers are still using Snow Leopard (10.6) – which only has Xcode 4.2 (iOS 5.0 SDK). With the upcoming release of the iOS 6 SDK, there doesn’t seem to be any Snow Leopard support for it. A SDK release is always coupled with a version of Xcode, and all the newer versions of Xcode are for Lion (10.7) and Mountain Lion (10.8) only. The Apple App Store will only accept apps that are built using the latest version of the iOS SDK. When iOS 6 is released, this will preclude Snow Leopard (10.6).

Next steps:

Currently there is still a GUI based installer that installs CordovaLib into your home folder’s Documents sub-folder, and it also updates the $(CORDOVALIB) Xcode variable. The GUI installer will be removed in a future release, and installation will be through the command-line as well. This will allow us to version and package Cordova iOS through homebrew, for example.

Written by shazron

July 20, 2012 at 6:38 am

Posted in cordova, phonegap, xcode

PhoneGap Xcode 4 Template (beta)

with 37 comments

UPDATE: PhoneGap includes the Xcode 4 template now, download it from
View the screencast below (best in full-screen, in HD).
Also, you can read the wiki article.

Xcode 4 template specs are undocumented and buggy. So, there are issues:

    • We cannot automatically include the “www” folder in the template – the user has to add it in manually (a quick drag and drop). I added in checks and warnings if users try to run the app without adding this in.
    • Some files, like .h and the -Info.plist file, are included in the ‘Copy Bundle Resources’ build phase by the template. No biggie during run-time, but for those with OCD they will want to remove these from the Build Phase (if only to get rid of the warning).
    • Because Xcode 4 does not expand tildes (~), I cannot add a reference to the PhoneGap.framework in the user’s home folder, so I added it to a shared location /Users/Shared which has r+w permissions for everyone (the common folder /Library/Frameworks needs admin privileges). It was added here so users without admin privileges can still use PhoneGap.framework, and by extension, the Xcode 4 Template.


    • beta1 – Initial release
    • beta1.1 – Bug fix for issue #81 (moved framework from /Users/Shared/Library to /Users/Shared/PhoneGap)
    • beta1.2 – Made /Users/Shared/PhoneGap writable to everyone
    • beta1.3 – Fixed Template not copying over the ‘www’ directory from the framework location (happened only for users that only installed beta1.3 and didn’t migrate from an earlier beta version). This version was tested on a clean Mac OS X 10.7 Lion DP3 system running Xcode 4.1 DP5, and works great.
    • beta2 – (UPCOMING) add AppleScript in the project Run Script build phase to get Xcode to automatically add the ‘www’ folder for you

Written by shazron

May 5, 2011 at 11:57 pm

Posted in phonegap, xcode

Creating a PhoneGap project from the command line (for Xcode 4)

with 66 comments

UPDATE: PhoneGap includes the Xcode 4 template now, download it from

Currently the PhoneGap installer for iOS does not create an Xcode 4 template. The issue is tracked here.

I’ve created a shell script to create a PhoneGap project from the command line. You will still need PhoneGapLib installed – download the installer from and run it first.

Instructions are in the shell script itself (open it up in a text editor). View the script, then File -> Save As… to save it. [For Cordova – replace occurrences of ‘PhoneGap’ in the value for the path with ‘Cordova’:]

Cameron Perry has a good post about using PhoneGap with Xcode 4 that might solve some problems users might have.

Written by shazron

March 16, 2011 at 1:06 am

Posted in phonegap, xcode

Running your iPhone app in the Simulator without Xcode (with log support)

with 9 comments

I started writing this shell script because Xcode 4 keeps crashing, so I ended up editing my code in TextMate, and had iTerm open so I can build, then deploy the app automatically in iPhone Simulator.

The script takes three arguments, the first is the name of the project (here the limitation is that it has to be the name of the .xcodeproj and the .app name), and the second is the configuration (Debug/Release – defaults to Debug), and the third is an optional argument, the name of the log file that the log will be written to (defaults to stderror.log).

Also, you will need the latest code of ios-sim. I could have added a step to check whether you have it installed and download, build and install it for you, but maybe next time 😉 Make sure you download the latest source, and not one of the packages.

One you download it and build it, copy the ios-sim binary to somewhere in your path – /usr/bin is a good location.

Download the script. It is WTFPL licensed. Run it without arguments to see the help text.

Run chmod 755 on the script to give it exec privileges.

The script builds your project, launches the project in the iPhone Simulator, activates the iPhone Simulator (brings it to front), logs the output to a file, and also displays the contents of the logfile as it is written to. On each run, it writes to a fresh log file, and the previous log file is backed up.

Written by shazron

February 23, 2011 at 10:16 pm

Posted in xcode

Xcode shell build phase, reporting of errors

with 6 comments

Found this useful information, regarding Xcode error reporting for shell build phases. For example, if we were to include JSLint in PhoneGap iPhone, we could format the errors this way below so code where the errors occur are easily editable:

In shell build phases you can write to stderr using the following format:
<filename>:<linenumber>: error | warn | note : <message>\n
It’s the same format gcc uses to show errors. The filename:linenumber part can be omitted. Depending on the mode (error, warn, note), Xcode will show your message with a red or yellow badge.
If you include an absolute file path and a line number (if the error occurred in a file), double clicking the error in the build log lets Xcode open the file and jumps to the line, even if it is not part of the project. Very handy.

Written by shazron

December 4, 2010 at 2:00 am

Posted in xcode

%d bloggers like this: