简体   繁体   中英

Cannot build project for iOS from cordova cli

I've created a project using Cordova CLI, version 3.5.0.

I've successfully deployed the project for Android platform by using the CLI.

cordova run android

However, I'm having problem to deploy the project for 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.

I've tried to remove the Info.plist & Prefix.pch file, but then this error appeared.

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.

Please guide me, thanks.


SOLVED

Solved by renaming the project name using 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

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.

I then had to rename the .xcodproj to match capitalization.

After that, another issue happened: xcodebuild: error: The project 'NewName.xcodeproj' does not contain a target named '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!

Best of luck!

What solved my problem was by doing the following

  1. Removing the ios platform; ionic platform remove ios
  2. Removing the android platform; ionic platform remove android
  3. Adding the Ios platform back; ionic platform add ios
  4. Adding the android platform back; ionic platform add 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

<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.

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. It worked again once i changed it back to the old name. Renaming in xcode also worked so thanks for 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