While the previous article focussed on installing Cordova, this one has some usefull tip and tricks. A lot of possible issues and solutions to keep in mind while trying to get your app functional again.
Read it on stackoverflow here.
I have several apps that currently rely on PhoneGap Build to create native apps for Andriod and iOS. It seems that Adobe is about to abandon iOS compatibility by failing to upgrade to the latest Cordova iOS version to meet Apple’s requirements. It’s time to move to CLI. I’m hoping that someone who’d done this before can provide some tips on how they did this. In particular, changes to workflow, handling keys and config.xml, etc.
Update 1: I’ve been making progress with an automated workflow and here’s what I’ve learned so far (on MacOS):
- Loading Cordova is fragile. I had to search the internet several times to overcome problems in getting it all loaded.
- When creating a Cordova project directory, you should populate config.xml, res and www with your stuff before adding the ios and android platforms. Otherwise “cordova clean” breaks.
- If you use build.json, you must “cordova clean” if you change it before it will be used.
- Build for iOS, then open {cordovaDir}/platforms/ios/{proj}.xcworkspace in XCode, then load your certificates and provisioning profiles (select the top-level directory to get the General setting page). You’ll have to turn off “Automatically manage signing” to set everything up.
- I could not get “Automatic” signing to work (see Cordova CLI 9.X docs). I used the manual process. Get the UUID by editing the provisioning profiles with a text editor and searching for “UUID”.
- During the Cordova CLI build process, the code signer will ask you for your password multiple times. So much for automation. Is there any way around this?
Please let me know if I got anything wrong.
Update 2:
- When setting up iOS (manual) signing on a new project. You need to turn off “Automatically manage signing”, set up your provisioning profiles, then quit XCode. Then reopen the xcworkspace file and turn on “Automatically manage signing”. You need this last step in order for manual signing to work. You need to quit in between because, otherwise, XCode will not remember your provisioning profiles when you go back to “Automatically manage signing”. Weird.
- When building an apk and ipa I found I had to enter my password manually 4 times. You have to give keychain access permission to automatically let the codesigner use your key in order to avoid this.
Update 3:
- I can’t build a proper distribution build using “cordova build”. It seemed to work, but Apple rejected the binary, citing the wrong profile. Fortunately, I can submit through XCode (using the exact same profiles and certificates set up manually in XCode) and Apple accepted it. This works for me right now. I like to record each ipa I send in, but I can export those through XCode. BTW, when building for distribution, uncheck including symbols. That seems to cause it to upload 1000’s of MBs.
Update 4:
- The issue that prevented me from building a proper .ipa was that you need to specify both –release and –device on the cordova build command line. You’d think –release would do the right thing by itself, but no.
I can now submit properly. Thanks for the help!
An answer supplied was:
These are the steps I followed:
Requirements
- IOS: MacOS running, XCode, XCode command line tools
- Android: Windows/MacOS, Android Studio and SDK, JDK
Setting up
- You have to install the tools NPM and Cordova CLI.
- I recommend create a new cordova project using
cordova create
and moving your files to this folder - There’s no much difference on the config.xml used on phonegap and cordova, basically I copied everything
- If you are upgrading your cordova platform version (as most of us are upgrading from cordova-ios-5.x to cordova-ios-6.x), probably some of your plugins will fail to build, so you have to check each one of the plugins, if there are compatible versions to your platform, if not you will have to remove it (eg: cordova-plugin-console).
- Try to add your platform using
cordova platform add [android/ios]
, check the current iOS version on cordova website, Apple won’t accept builds made on old platforms. It’s likely you may need to inform the cordova iOS version (eg:cordova platform add ios@6.1.0
)
Building
- Try to build using
cordova platform build [android/ios]
- If you succeded, at this point you may be able to debug opening the project inside the platform folder (using XCode or Android Studio depending which platform you are building)
- If you yet cannot build, check the possible error message carefully, most of errors are on config.xml or plugins, if you don’t know the problem try to remove all plugins, build and add one by one. When you get some error and you fix it (it will be mostly on config or plugins), I recommend removing the platform using
cordova platform rm [ios/android]
andcordova clean
, then adding the platform again (see Setting up step 5)
Signing the app
- Building release versions for iOS/Android requires signing your apps
- I recommend the use of the build.json, where you can set up the team names, certificates and others, then you won’t need to open the IDE to sign the App or insert the password everytime
Link to check more details about using build.json on cordova: https://cordova.apache.org/docs/en/latest/guide/platforms/ios/index.html#signing-an-app https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#signing-an-app
So…
Have a nice day!