Can't execute ionic platform add ios

I’m getting this error when I enter the command - ionic platform add ios. How to fix this?

/home/cath/.cordova/lib/ios/cordova/3.5.0/bin/create: 33: /home/cath/.cordova/lib/ios/cordova/3.5.0/bin/create: Syntax error: “(” unexpected
Error: /home/cath/.cordova/lib/ios/cordova/3.5.0/bin/create: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

Hi Cathy.

Have you created Cordova / Ionic apps with iOS before?

Have you followed the iOS Cordova platform guide and such? Link below:

http://cordova.apache.org/docs/en/3.3.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide

Nope, this is my first time. I follow the getting started and watch the ionic crash course video. I installed the node.js and npm then created myApp. When I input ionic platform add ios in the terminal, I’m getting that error.

Have you downloaded and configured XCode as required in the add platform instructions Cathy?

2 Likes

Hello,

If you have followed all the installation steps including installing XCode like ‘edwrede_ZA’ said and it still does not work you can try these steps:

1.Start another ionic project on another folder with ionic start anotherProject
2.Copy your project’s ‘www’ folder and replace it on your new ‘anotherProject’ folder.
3.Add the platforms to your new project using ionic platform add ios
4.Build the project to the selected platform using ionic build ios
5.Run your project using ionic run ios

I’ve got a similar error before and this worked.
Hope it works for you :slight_smile:

1 Like