xcode 无法从cordova cli为iOS构建项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25282293/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot build project for iOS from cordova cli
提问by Amir Fazwan
I've created a project using Cordova CLI, version 3.5.0.
我使用 Cordova CLI 版本 3.5.0 创建了一个项目。
I've successfully deployed the project for Android platform by using the CLI.
我已经使用 CLI 成功地为 Android 平台部署了项目。
cordova run android
However, I'm having problem to deploy the project for iOS.
但是,我在为 iOS 部署项目时遇到问题。
cordova run ios
I encountered this error:
我遇到了这个错误:
mv: dest file already exists: /Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MyPKS-Info.plist mv: dest file already exists: /Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MyPKS-Prefix.pch shell.js: internal error Error: EINVAL, invalid argument '/Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS.xcodeproj' at Object.fs.renameSync (fs.js:543:18) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:495:8 at Array.forEach (native) at Object._mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:471:11) at Object.mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:1491:23) at pbxProject. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:126:27) at pbxProject.EventEmitter.emit (events.js:98:17) at pbxProject. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/xcode/lib/pbxProject.js:30:18) at ChildProcess.EventEmitter.emit (events.js:98:17) at handleMessage (child_process.js:322:10)
This problem only occur after I access the Xcode project manually to add the Icon & splash screen since the icon & splash screens are not automatically added to the project even though declared in config.xml.
仅在我手动访问 Xcode 项目以添加图标和启动画面后才会出现此问题,因为即使在 config.xml 中声明图标和启动画面也不会自动添加到项目中。
I've tried to remove the Info.plist & Prefix.pch file, but then this error appeared.
我试图删除 Info.plist & Prefix.pch 文件,但随后出现此错误。
Error: ENOENT, no such file or directory '/Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MYPKS-Info.plist' at Object.fs.openSync (fs.js:427:18) at Object.fs.readFileSync (fs.js:284:15) at Object.exports.parseFileSync (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/plist-with-patches/lib/plist.js:18:19) at Object.module.exports.update_from_config (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:66:31) at Object.module.exports.update_project (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:189:21) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:113:31 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
The project works just fine if launched from Xcode, but I no longer can build the project from CLI or launch the "serve" command from CLI for debugging purpose.
如果从 Xcode 启动,该项目工作正常,但我不再可以从 CLI 构建项目或从 CLI 启动“服务”命令以进行调试。
Please guide me, thanks.
请指导我,谢谢。
SOLVED
解决了
Solved by renaming the project name using Xcode. Thanks Jason for the tips.
通过使用 Xcode 重命名项目名称来解决。感谢杰森的提示。
回答by Chris S
Just remove the platforms and then add them again.
只需删除平台,然后再次添加它们。
cordova platform rm ios
cordova platform rm android
cordova platform add ios
cordova platform add android
回答by Jason Cox
EDIT: Try this other solution first! It works for most issues: https://stackoverflow.com/a/28300528/1250444
编辑:首先尝试其他解决方案!它适用于大多数问题:https: //stackoverflow.com/a/28300528/1250444
I struggled with this as well. Finally found a solution by trial and error. D:
我也为此苦苦挣扎。经过反复试验,终于找到了解决办法。乙:
What happened for me was renaming the project name to have capitals. This caused all sorts of confusion for Cordova.
发生在我身上的是将项目名称重命名为大写。这给科尔多瓦造成了各种各样的困惑。
The first thing I did was rename the problematic plist and pch files to match the correct capitalization. So, in your case, if it was myPKS, but now is MyPKS, you'd need to rename the files to be MyPKS-Info.plist and MyPKS-Prefix.pch.
我做的第一件事是重命名有问题的 plist 和 pch 文件以匹配正确的大小写。因此,在您的情况下,如果它是 myPKS,但现在是 MyPKS,您需要将文件重命名为 MyPKS-Info.plist 和 MyPKS-Prefix.pch。
I then had to rename the .xcodproj to match capitalization.
然后我不得不重命名 .xcodproj 以匹配大小写。
After that, another issue happened: xcodebuild: error: The project 'NewName.xcodeproj' does not contain a target named 'NewName'.
之后,另一个问题发生了:xcodebuild:错误:项目“NewName.xcodeproj”不包含名为“NewName”的目标。
To solve this, I had to rename the target to have the proper capitalization as well. Since I'm new to iOS dev, I have not idea how to describe how to get there. I just finally stumbled upon it, made the change, and it worked!
为了解决这个问题,我必须重命名目标以具有正确的大小写。由于我是 iOS 开发新手,我不知道如何描述如何到达那里。我终于偶然发现了它,做出了改变,它奏效了!
Best of luck!
祝你好运!
回答by Vinchenzo
What solved my problem was by doing the following
通过执行以下操作解决了我的问题
- Removing the ios platform; ionic platform remove ios
- Removing the android platform; ionic platform remove android
- Adding the Ios platform back; ionic platform add ios
- Adding the android platform back; ionic platform add android
- Rebuild; ionic build
- 移除ios平台;离子平台删除ios
- 移除安卓平台;离子平台删除android
- 重新添加 Ios 平台;离子平台添加ios
- 重新添加android平台;离子平台添加android
- 重建; 离子构建
Hope this helps anyone else.
希望这对其他人有帮助。
回答by Gerfried
Jason Cox's answer helped me - but I did not rename any files, I just had to change the name of the app in my config.xml
Jason Cox 的回答帮助了我 - 但我没有重命名任何文件,我只需要在我的 config.xml 中更改应用程序的名称
<name>myApp</name>
to
到
<name>MyApp</name>
回答by Gajen Sunthara
回答by Phrenesis
I got this same error. The reason why this happen to me was because i changed the name in the xml from myapp to MyApp. It worked again once i changed it back to the old name. Renaming in xcode also worked so thanks for that.
我遇到了同样的错误。这发生在我身上的原因是因为我将 xml 中的名称从 myapp 更改为 MyApp。一旦我将它改回旧名称,它就再次起作用了。在 xcode 中重命名也有效,因此感谢。