简体   繁体   English

无法从cordova cli为iOS构建项目

[英]Cannot build project for iOS from cordova cli

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项目以添加Icon&splash屏幕后才会出现此问题,因为即使在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启动“serve”命令以进行调试。

Please guide me, thanks. 请指导我,谢谢。


SOLVED 解决了

Solved by renaming the project name using Xcode. 通过使用Xcode重命名项目名称解决。 Thanks Jason for the tips. 谢谢杰森的提示。

WWWWW

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

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: 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. 我做的第一件事是重命名有问题的plist和pch文件以匹配正确的大小写。 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. 因此,在您的情况下,如果它是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:error:项目'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. 由于我是iOS开发新手,我不知道如何描述如何到达那里。 I just finally stumbled upon it, made the change, and it worked! 我终于偶然发现了它,做出了改变,并且它奏效了!

Best of luck! 祝你好运!

What solved my problem was by doing the following 通过以下方式解决了我的问题

  1. Removing the ios platform; 删除ios平台; ionic platform remove ios 离子平台删除ios
  2. Removing the android platform; 删除android平台; ionic platform remove android 离子平台删除android
  3. Adding the Ios platform back; 添加Ios平台; ionic platform add ios 离子平台添加ios
  4. Adding the android platform back; 添加android平台; ionic platform add android 离子平台添加android
  5. Rebuild; 重建; ionic build 离子构建

Hope this helps anyone else. 希望这有助于其他任何人。

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>

This worked in Meteor 1.3.x Remove a particular platform and re-add again via meteor command via console. 这在Meteor 1.3.x中有效。删除特定平台并通过控制台通过meteor命令重新添加。

For ex. 对于前者

在此输入图像描述

meteor list-platforms
meteor remove-platform ios
meteor add-platform ios

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. 之所以发生这种情况,是因为我将xml中的名称从myapp更改为MyApp。 It worked again once i changed it back to the old name. 一旦我改回原来的名字,它再次起作用。 Renaming in xcode also worked so thanks for that. 在xcode中重命名也是如此,谢谢你。

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

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