Skip to content

Instantly share code, notes, and snippets.

@revolunet
Last active August 10, 2022 22:44
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save revolunet/fdc0eefbcdf8cc58edea to your computer and use it in GitHub Desktop.
Save revolunet/fdc0eefbcdf8cc58edea to your computer and use it in GitHub Desktop.
Cordova iOS tips

General

  • create a single page javascript application
  • be as low-level as possible to be able to control performance (=minimize layers)
  • masterize your dev/build environnement so you can work/play nicely

Debug apps

  • Open safari console in development menu with simulator or attached devices (enable debug in ipad/safari dev options)
  • debug your app from xcode to get native debugger and performance metrics
  • use ios-deploy to inspect the device files, ex: ios-deploy --download=/Library/Caches/xxx --bundle_id x.y.z --to ./ios

Compilation

To prevent massive app recompilation and wasted time, build your app once with <content src="http://192.168.0.11:9888" /> in config.xml and point it to your computer dev server, in the platforms/ios/www folder.

Then use cordova prepare to update the sources and Cmd+R in Safari debugger to reload the new version, or... livereload :)

Or use this before_prepare hook : https://gist.github.com/revolunet/328193b350a056d730a5

Plugins

Define your plugin dependencies with commit-ish reference in config.xml : <plugin name="nl.x-services.plugins.socialsharing" spec="https://github.com/revolunet/SocialSharing-PhoneGap-Plugin.git#f7e938cf06e1705727b501b4e6e184b535445341" />

cordova prepare is supposed to reinstall missing plugins but can fail silently for some reasons...

if you download/install troubles, hard-reset your plugins : https://gist.github.com/revolunet/e19158a13df962a3df5e

Plugin dev

  • use cordova plugin add --link ../path/to/awesome-plugin/ to create a symbolic link to your project dev folder
  • plugins dependencies can have specs too plugin.xml : <dependency id="cordova-plugin-dialogs" url="https://github.com/revolunet/cordova-plugin-dialogs" commit="c70eb82adc8d11889ab47c01a686f692f60b1623"/>

Custom platforms

cordova platform add https://github.com/revolunet/cordova-android#custom-branch

Best practices

Performance

Distribution

  • You can use diawi.com to send demo apps to registered devices via a simple email link
  • Name your test builds with the git commit SHA so you can easily have the associated changelog on github/user/project/commits/SHA
  • Drop your builds with SHA names in a dropbox folder, use IFTTT to warn you in a slack channel with a link to IPA and to the changelog :)
  • Get connected devices UUID : system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/\1/p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment