Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.3.0
-
None
-
Mavericks 10.9.1; Xcode 5; Cordova 3.3.1-0.1.2
Description
It appears if `cordova build` doesn't execute properly a first time, then all subsequent times it does not finish with the desired behaviour. Let me be explain further and why I think this happens.
I started with a new project, first adding in a couple of cordova plugins (in order to replicate, it doesn't matter which). I then added in the iOS platform and performed `cordova build` which was fine and built as expected - all plugins installed fine.
I then altered a plugin and unbeknown to me at the time, I introduced an error to this plugin which meant a plugin could not compile (I was blindly coding at the time - silly of me, I know). Without knowing this, I executed `cordova build` again. It then failed, because presumably xcodebuild could not complete due to my source file which could not compile - and as a result, `cordova build` executed prematurely with an exit code something other than '0'. This is expected behaviour thus far.
So I altered my plugin, updated my project with the new plugin code and thought I was good to go again - I then executed `cordova build` again in order to fully build my Cordova project. The CLI said this executed fine, but in reality it did not since no plugins were loaded. I opened the root 'config.xml' (i.e. one under the Xcode project, not in www) and the <feature> tags had not been added (and so the app did not run) which is the indicator to say which plugins are in your project.
After digging around, to fix this I had to remove 'build' in ./platforms/ios/ - then after executing `cordova build` again, it started building fine - and the <feature> tags were being added back in for each of my installed plugins.
After doing some investigation, I have found the issue why (and it should be a fairly quick fix). These are the steps (with using a broken plugin) to replicate
1) As part of `cordova build` I think the build script will copy the default cordova www to all platforms temporarily (i.e. the index.html with no plugins except LocalStorage) which includes the basic config.xml with no plugins.
2) The iOS project is then compiled with xcodebuild and as a result, the config.xml from the default www is copied to the root of the Xcode project (remembering this is the basic ‘config.xml’ with no plugins).
3) It then attempts to compile the Xcode project - but with the broken plugin added, xcodebuild fails - and the basic config.xml is left there.
4) At some point, the ‘build’ folder is created in ./platforms/ios/ which contains a build of the cordova project.
5) Observe config.xml and notice that no <feature> tags are added.
After fixing the broken plugin, delete the build folder and execute `cordova build` again and you will see the <feature> tags are added back in.
After that extremely long-winded explanation, in short, I think `cordova build` needs to remove the ‘build’ folder as part of the cleanup step, as it seems to get some data from here - and if that contains a broken plugin, then it’s going to cause problems in future.
I think that the Cordova uses the build folder to get some necessary files without the expense of having to copy them from somewhere further down the directory structure (as an efficiency step). So hopefully this is clear why it might cause a problem doing this. If it's necessary to keep 'cordova build' the same, then maybe we can include, say, a -c flag which does a clean and build and deletes the 'build' folder and cleans up the project before building it from scratch again.
If you need further explanations, I’m happy to provide. I hope that makes sense!
Attachments
Issue Links
- duplicates
-
CB-5578 clean command for CLI
- Closed