Search code examples
javascriptxcode4

xcode 4 + phonegap ... not update JS upon build?


I've run into a weird issue that has had me scratching my head for the past hour.

I'm working on an iPad app using Xcode 4 and PhoneGap. It's using jQuery. I've put all my JS into a scripts.js file.

Things are working well.

I spend about an hour doing a lot of CSS tweaking. I'd update the CSS file, stop the app, rebuild, and push to the iPad simulator or my iPad. That's been working fine. Every update to the CSS file is reflected on the new build.

I then needed to update the JS file. I couldn't get things to work and then I finally realized none of my JS changes were actually be put into the build. I finally blanked out my JS file completely, rebuilt, and it's still not updating.

The file I'm updated is being updated in the finder in the project folder (I can right-click 'view in finder' and that file is, indeed, updated).

So I'm stumped. Is the xcode compiler caching the JS file somehow instead of grabbing the updated file? Is there a way to force it to grab the updated JS?


Solution

  • Well, after some more googling, this seems to be a common problem. Xcode seems to cache files even after you've edited them.

    One option appears to be to run the 'clean' command before a new build. I tried that, no luck.

    Other solutions appear to involve rebuilding the .plist file each time. I don't fully understand that (yet) in terms of how to do that automatically, but did find this workaround:

    • Open your .plist file
    • change something (in my case, I rename one of the app icon files each time)
    • save and build

    Doing that magically forces xcode to FINALLY grab all the updated files and do a proper build.

    I can't explain why Xcode seems perfectly happy grabbing my updated .css file each and every time but won't update the .html or or .js files without first doing this .plist file edit.

    Seems as if Apple still has a few bugs to work out. I guess we'll have to wait patiently for the next 4gig .x relase of it. ;)