简体   繁体   中英

How to edit a Phonegap/Cordova-project in XCode?

I built a Phonegap/Cordova iOS-app using the command line. I can run it with the CLI.

After that I'm using XCode to compile and run the project that was created in ' platforms/ios ' on the iOS simulator. This works too.

Now I would like to use XCode to make changes to the app. XCode does display a www -folder and config.xml but these are the top ones in the project folder , not in platforms/ios .

So if I change the files that are displayed in XCode, no changes appear when I run the project.

So, how can you edit a files of a Phonegap/Cordova project and run it with XCode ? (and still being able to use the CLI, would be nice as well).

You always need to modify the project_folder/www files. You can edit this files using Xcode, notepad++ or even with a simple notepad. Use what ever you like.

Then run the command using CLI

cordova build ios

Your project is now completely built. You can see the changes you made inside platform/ios/.../www files too. Now you can run the project using CLI or Xcode as wish. To run in CLI

cordova run ios

Or to emulate in emulator

cordova emulate ios

You are doing it right, you have to edit the root www folder. Your problem is you have to do a cordova prepare ios to copy the changes from the root www folder to the platform/ios/www folder

You can do it from the cordova CLI or you can add a build script to you project (on build phases -> new Run Script phase) that runs the cordova prepare ios every time you run the project from xcode The code you need on the scrip is

PATH=${PATH}:/usr/local/lib/node_modules/cordova/bin/:/usr/local/bin
cordova prepare ios

Put it the first one

If you really want to edit the patform/ios/www folder, on xcode you will see a staging folder, there you have the www folder and the changes you do there are applied to the project, but when you do a cordova prepare ios that files will be replaced by the ones on the root www folder and you will lose all your work, so don't do that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM