Auraelius (2) [Avatar] Offline
#1
I'm enjoying the book, but ran into a problem.
Book version 3. epub version. section: "“2.2.5       Adding a platform to the project”
Xcode is installed.
When I run the command, I get an error
$ ionic platform add ios
Creating ios project...
Error: ~/Documents/pds/pds_rr does not exist. Please specify an existing parent folder.
Error: /Users/zim/.cordova/lib/npm_cache/cordova-ios/3.7.0/package/bin/create: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/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:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)


The folder
~/Documents/pds/pds_rr
does exist, but is not in my current directory tree. I'm not sure why it's in the error message

Here are some additional details:
$ pwd
/Users/zim/Dropbox/pcs/dev/ionic-temp/chapter2

[18:09][zim@kali:~/Dropbox/pcs/dev/ionic-temp/chapter2]
$ node -v
v0.10.34

[18:09][zim@kali:~/Dropbox/pcs/dev/ionic-temp/chapter2]
$ ionic -v
1.2.13

[18:09][zim@kali:~/Dropbox/pcs/dev/ionic-temp/chapter2]
$ cordova -v
4.1.2


and, from before,
[17:58][zim@kali:~/Dropbox/pcs/dev/ionic-temp]
$ ionic start chapter2
Creating Ionic app in folder /Users/zim/Dropbox/pcs/dev/ionic-temp/chapter2 based on tabs project

Downloading: https://github.com/driftyco/ionic-app-base/archive/master.zip
[=============================]  100%  0.0s

Downloading: https://github.com/driftyco/ionic-starter-tabs/archive/master.zip
[=============================]  100%  0.0s

Update config.xml
Initializing cordova project
Fetching plugin "org.apache.cordova.device" via plugin registry
npm http GET http://registry.cordova.io/org.apache.cordova.device
npm http 304 http://registry.cordova.io/org.apache.cordova.device
Fetching plugin "org.apache.cordova.console" via plugin registry
npm http GET http://registry.cordova.io/org.apache.cordova.console
npm http 304 http://registry.cordova.io/org.apache.cordova.console
Fetching plugin "com.ionic.keyboard" via plugin registry
npm http GET http://registry.cordova.io/com.ionic.keyboard
npm http 304 http://registry.cordova.io/com.ionic.keyboard

Your Ionic project is ready to go! Some quick tips:

 * cd into your project: $ cd chapter2

 * Setup this project to use Sass: ionic setup sass

 * Develop in the browser with live reload: ionic serve

 * Add a platform (ios or Android): ionic platform add ios [android]
   Note: iOS development requires OS X currently
   See the Android Platform Guide for full Android installation instructions:
   https://cordova.apache.org/docs/en/edge/guide_platforms_android_index.md.html

 * Build your app: ionic build <PLATFORM>

 * Simulate your app: ionic emulate <PLATFORM>

 * Run your app on a device: ionic run <PLATFORM>

 * Package an app using Ionic package service: ionic package <MODE> <PLATFORM>

For more help use ionic --help or visit the Ionic docs: http://ionicframework.com/docs


[17:59][zim@kali:~/Dropbox/pcs/dev/ionic-temp]
$ cd chapter2/



My question is: How to I proceed to debug this cordova problem? Is there a verbose mode? logs? I need to see more about what it's attempting to do. Where should I look? What cordova docs or source code should I examine?

I've tried googling/stack overflow searching the error message, but all I find are complaints about /platforms being missing in phonegap 3.4.0. I'm clearly barking up the wrong tree.

I've removed all my global node modules and reinstalled node, ionic, and cordova per your instructions from scratch. I'm using xcode to develop ios apps, so I'm sure it's installed correctly.

Any suggestions?
jeremy.wilken (208) [Avatar] Offline
#2
Hi there! I can't see anything from this that makes it clear that something is wrong until the error. The Ionic CLI utility is out of date, perhaps if you update that and recreate the project again it might work. Also, do you have the latest version of Xcode? Check for any updates in the AppStore.

Ok, let's take a look at a few things and see if we can't iron out some things. Navigate in the terminal to your project and run:

$ cordova info


This should spit out some information about the current project. That might provide some insight, such as the versions of things, configuration, and if any platforms or plugins are setup. If it says
Current working directory is not a Cordova-based project
then we've got a clue that Cordova isn't even setup for some reason. If it spits out some details, you can share them to provide some insights.
Auraelius (2) [Avatar] Offline
#3
Thank you so much for your reply! I cut the Gordian knot by creating a new account from scratch. your sequence in chapter two works fine (with one exception - see below). So, it must be something in my original account's configuration. I'll start comparing the two.

I verified that xcode was up to date and worked by creating a simple project, building it, and running the simulator.

When I went to your sequence, i needed to install ios-sim

kali:ionic zim1$ pwd
/Users/zim1/dev/ionic
kali:ionic zim1$ ls
chapter2
kali:ionic zim1$ cd chapter2/
kali:chapter2 zim1$ ionic platform add ios
npm http GET https://registry.npmjs.org/cordova-ios/3.7.0
npm http 200 https://registry.npmjs.org/cordova-ios/3.7.0
npm http GET https://registry.npmjs.org/cordova-ios/-/cordova-ios-3.7.0.tgz
npm http 200 https://registry.npmjs.org/cordova-ios/-/cordova-ios-3.7.0.tgz
Creating ios project...
Running command: /Users/zim1/dev/ionic/chapter2/hooks/after_prepare/010_add_platform_class.js /Users/zim1/dev/ionic/chapter2
add to body class: platform-ios
Installing "com.ionic.keyboard" for ios
Installing "org.apache.cordova.console" for ios
Installing "org.apache.cordova.device" for ios
kali:chapter2 zim1$ ionic emulate ios
Running command: /Users/zim1/dev/ionic/chapter2/hooks/after_prepare/010_add_platform_class.js /Users/zim1/dev/ionic/chapter2
add to body class: platform-ios
Running command: /Users/zim1/dev/ionic/chapter2/platforms/ios/cordova/run --emulator
Error: ios-sim was not found. Please download, build and install version 3.0 or greater from https://github.com/phonegap/ios-sim into your path. Or 'npm install -g ios-sim' using node.js: http://nodejs.org/
Error: /Users/zim1/dev/ionic/chapter2/platforms/ios/cordova/run: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/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:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)
kali:chapter2 zim1$ sudo npm install -g ios-sim

(a bunch of build messages.....)


** BUILD SUCCEEDED **

/usr/local/bin/ios-sim -> /usr/local/lib/node_modules/ios-sim/build/Release/ios-sim
ios-sim@3.1.1 /usr/local/lib/node_modules/ios-sim
kali:chapter2 zim1$ ionic emulate ios
Running command: /Users/zim1/dev/ionic/chapter2/hooks/after_prepare/010_add_platform_class.js /Users/zim1/dev/ionic/chapter2
add to body class: platform-ios
Running command: /Users/zim1/dev/ionic/chapter2/platforms/ios/cordova/run --emulator

(more build messages)


** BUILD SUCCEEDED **

2014-12-27 18:13:40.086 ios-sim[8716:439799] stderrPath: /Users/zim1/dev/ionic/chapter2/platforms/ios/cordova/console.log
2014-12-27 18:13:40.087 ios-sim[8716:439799] stdoutPath: /Users/zim1/dev/ionic/chapter2/platforms/ios/cordova/console.log
kali:chapter2 zim1$ 



and the ionic default app came up in the ios simulator.

As I figure out what's up with my old account, I'll use the new account to continue working through your book. I'll let you know what the problem is when I find out.

Thanks again for paying attention to the forums.

Al

jeremy.wilken (208) [Avatar] Offline
#4
Hi Al,

Glad that got it working, though these kinds of things can be caused by all kinds of troubles. I believe
ios-sim
is supposed to get installed by default when it is needed (Cordova installs packages as they are needed) but it might have trouble if your npm cache requires sudo to install node packages. Depending on how you've modified your environment there can be a lot of possible reasons. I would have to dig into the source code for the original error to see what may have been executing at that moment.

Did your path have any symlinks? This is where the error was happening in Cordova, so for some reason it was not able to determine your file path correctly. https://github.com/apache/cordova-ios/blob/master/bin/lib/create.js#L130

Jeremy