Best Practice for customizing Cordova Xcode project - ios

I'm working on a Cordova project that requires me to replace my main.m file with a .mm file and - along with adding a custom build phase script. When I do this I can no longer use the cordova cli commands or cleanly upgrade my cordova project when new versions are released.
I can't seem to find any documentation on editing things at this level. Can anyone point me in the right direction? I've looked into the cordova hooks but I'm not sure whether that would work or where to hook my code to ensure a proper build.

Fork the Cordova-iOS and maintain your changes there. Merge commits from the original apache repo from time to time.
Use cordova platform add your-fork-git-url#branch-or-tag to add platform
I hope it can help

Related

Xcode 10 build 10A255 requires clean build folder for all changes

After updating Xcode 10 from AppStore, when i add something even one single line, it doesn't apply change to build while i clean project. Is there any trick to prevent this or is it bug.
edit: i'm developing cocoapod, changes in Example app is applied to compile perfect but changes in development pod is require to clean to apply changes.
This is a known issue with the new build system of Xcode 10.
There are radars about this and cocoapods developers are aware of the issue.
In the meantime (because it is not gonna be fixed anytime soon), you can indeed switch to the legacy build system (or clean your build folder each time you want to recompile your example app).
Another option might be to disable cocoapods input/output paths, but it is not recommended.
Please note that switching the Compilation Mode build setting from Incremental to Whole Module will in fact not work as intended.
For more information about this you can check the following issues :
https://github.com/CocoaPods/CocoaPods/issues/7966
https://github.com/CocoaPods/CocoaPods/issues/8073

How to update a Cordova iOS platform project with only iOS source code

I have got a job to reform a Cordova iOS project to the newest version. However the only source code I have received is the iOS platform. The folder's structure is like this
-ios (root folder)
--cordova (folder)
--CordovaLib (folder)
--icon
--icon#2x.png
--AppName (folder)
--AppName.xcodeproj
--RandomSDK (folder)
--Versioning.txt
--www(folder)
So as you can imagine, it must be just a sub-folder under the platform folder in a complete Cordova project. And the Cordova version of this iOS project indicated by the file under path .\CodovaLib\VERSION is 2.7.0
My question is, is there any whether "dirty" or "clean" way one can build it up to the newest Cordova platform as well as the newest iOS version? I even don't have to recover the original Cordova project. The only thing need to be cared here is the iOS project.
I have read some of the post like Upgrade Cordova Version of an iOS app (which I called it a "dirty" way). I just want to do something like that, with only www folder, plugin folder and config file in the iOS platform, but that post only tells how to do it with the original Cordova project.
For the "clean" way I mean do something like this: https://cordova.apache.org/docs/en/latest/guide/platforms/ios/upgrade.html .
OK, After some struggles, I finally make it work and compiled. Here are the steps I do in a high level of view.
First, I have created a brand new Helloworld template Cordova project and name the project name and bundle identity exactly same as the old one. Second I copy the www folder to from the old iOS project to the new Cordova project. (Yes, the www folder in both iOS platform and Cordova are the same), and then base on what I need, I change the settings such as content src to the one I want manually. Third I built the iOS platform, then copied all the files that are missing from the old iOS project, use the old xcode project covered the new one, and manually changed all the config files manually to make it consist both to the newest Cordova and the old iOS project. Last I exclude all the old plugin from the xcode project, and remove any old plugin from the project, then reinstall them via the latest Cordova. And miraculously it work!
In general, what I did is mostly like what this post have done, except first you need to set up all the config manually, second after you build up the iOS platform you still have to copy everything and confiure them again since the Cordova project here is no more than a Helloworld template with the html, js and css files you need.
Actually this is my first time maintaining a Cordova project at work. I think the idea is really neat, but somehow it is really hard to make it work due to the hardware support vary from device to device, which is unfortunately. Hopefully later on people can use the design pattern that separate the UI and core of the mobile app so that at least things like Cordova can do the UI work all together.

Add Today Extension to Cordova project

I have a directory of "Today Extension" project.
I want to add the project to my Cordova project, one may know the platform directory in the Cordova project when I run the command
CLI: "cordova platform add ios"
is automatically generated and couldn't be added through Xcode.
Adding a target to an existing XCode project is something that can be done using node with the xcode package or through ruby using xcodeproj. The exact method on how to do so, however, is something I haven't figured out yet and I'm also very interested in.
So far, I have found one resource where they actually add a watchkit extension, but I haven't had the time to look into this in much depth. Also I think I myself lack the skill to generalize this into a plugin.

iOS Cordova first plugin - plugin.xml to inject a feature

I'm creating my first Cordova plugin and I'm confused to the structure of building it. I have a fresh Cordova project and I've added the iOS platform. I was looking at this for guidance (specifically the Echo iOS plugin example part):
https://cordova.apache.org/docs/en/5.1.1/guide/platforms/ios/plugin.html
but I'm quite new to this and I'm a little bamboozled by what I'm actually supposed to be doing. It tells me to use plugin.xml to inject a feature specification to the local platform's config.xml file. Is the plugin.xml a file I need to create or is it the one in project> plugins> cordova-plugin-whitelist > plugin.xml? Either way how do I use it to inject this feature? I presume it's something it reads from when it builds the project but I'm still unsure how to do it.
Thanks.
As far as i know to create custom plugins, you gotta create a plugin folder as per the specifications and ensure that the plugin is referred in the fetch.json file under plugins folder. Then removing and re-adding the platform should take care of plugin installation in respective folder. You can refer any of the existing plugins to replicate the same folder structure.
The detailed info on custom plugin creation is available in cordova official documentation.Hope it helps

Ionic2: Update modified plugins

I've imported a plug-in into my Ionic 2 project and made some changes to it to see if that would solve a problem I had with it. Is there a way to update that plug-in's implementation in the added platforms?
on that note, is there a way to make my own plug-in without having to publish it on Cordova?

Resources