简体   繁体   English

如何在XCode中编辑Phonegap / Cordova项目?

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

I built a Phonegap/Cordova iOS-app using the command line. 我使用命令行构建了一个Phonegap / Cordova iOS应用程序。 I can run it with the CLI. 我可以用CLI运行它。

After that I'm using XCode to compile and run the project that was created in ' platforms/ios ' on the iOS simulator. 之后我使用XCode编译并运行在iOS模拟器上的' platforms/ios '中创建的项目。 This works too. 这也有效。

Now I would like to use XCode to make changes to the app. 现在我想使用XCode对应用程序进行更改。 XCode does display a www -folder and config.xml but these are the top ones in the project folder , not in platforms/ios . XCode确实显示了www -folder和config.xml但这些是项目文件夹中的顶级文件夹,而不是platforms/ios

So if I change the files that are displayed in XCode, no changes appear when I run the project. 因此,如果我更改XCode中显示的文件,则在运行项目时不会显示任何更改。

So, how can you edit a files of a Phonegap/Cordova project and run it with XCode ? 那么,如何编辑Phonegap / Cordova项目的文件并使用XCode运行它? (and still being able to use the CLI, would be nice as well). (并且仍然能够使用CLI,也会很好)。

You always need to modify the project_folder/www files. 您始终需要修改project_folder/www文件。 You can edit this files using Xcode, notepad++ or even with a simple notepad. 您可以使用Xcode,notepad ++或简单的记事本编辑此文件。 Use what ever you like. 使用你喜欢的任何东西。

Then run the command using CLI 然后使用CLI运行该命令

cordova build ios

Your project is now completely built. 您的项目现已完全构建。 You can see the changes you made inside platform/ios/.../www files too. 您也可以在platform/ios/.../www文件中看到所做的更改。 Now you can run the project using CLI or Xcode as wish. 现在您可以根据需要使用CLI或Xcode运行项目。 To run in CLI 在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. 你做得对,你必须编辑根www文件夹。 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 你的问题是你必须做一个cordova prepare ios将更改从根www文件夹复制到platform/ios/www文件夹

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 您可以从cordova CLI执行此操作,或者您可以向项目添加构建脚本(在构建阶段 - >新的运行脚本阶段),每次从xcode运行项目时运行cordova prepare ios脚本上需要的代码是

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 如果你真的想编辑patform / ios / www文件夹,在xcode上你会看到一个暂存文件夹,你有www文件夹,你在那里做的更改都应用于项目,但当你做一个cordova prepare ios文件将被根www文件夹中的文件替换,您将失去所有工作,所以不要这样做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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