Legacy Cordova code

It’s very common for freelancers to receive legacy code at some point of their career. It could be GitHub repository with last updated date stated as couple years ago or .zip archive sent via e-mail. Sharing the code will likely come with note from client ‘make it work’ (good scenario) or ‘we need to fix this because it stopped working with new OS update’ (you are more or less screwed scenario). Both cases mean build problems and it will never be just fix around one requested feature.

While with native code you will likely to succeed quickly (it could be downloading older XCode version, updating couple build settings, use suggested API names changes) the hybrid code gives much more problems.

Many developers will commit everything to repository and since they will be only person working on code, it will work fine. Artifacts (ipa, apk) generated on their computers will work just fine.

However when using code that has content of /build or /platforms folders commited to repo it will never work correctly, sometimes even code builds and runs just fine.

If you stumble upon situation when you try to use some functionality of Cordova written app and you are stuck or blank screen or loading indicator, open Safari and use Develop tab to see console for errors. Often you will see some cordova plugins failing.

When something like that happens for me I don’t even try to fix that single plugin issue. I run chain of commands to go back to clear state of project.

cordova platform remove ios

cordova platform add ios

cordova prepare ios

After that project is regenerated, provisioning likely needs to be set up again. But there is a chance that plugin errors go away. But often they won’t. Then most sensible way is to list all plugins and remove/add each one again.

cordova plugin list

cordova plugin remove name-of-plugin

cordova plugin add name-of-plugin

Then remove, add, prepare as before. This can either work or give build problems with some of the plugins. This is…good. Because at least now it prevents you from building and it gives you native language reason of why plugin code can’t be build.

With that information you go plugin repository and check if there is a new version of plugin or if your issue has been reported. If there is no activity in plugin releases or author responses just fork it and fix it according to XCode suggestion. There is also a chance that someone already did that for you and shared link to his fork in opened issue topic.

Leave a Reply

Your email address will not be published. Required fields are marked *