Running your first ionic App on Android and iOS from mac

Though there are a lot of links on the internet to guide you through, some of the challenges that first time ionic developer like me face are un-documented.

Below are a few challenges that I faced and how I resolved them. These could be very trivial and obvious to experienced developers. I still thought its worth sharing.

Thanks to all fellow developers for having provided solutions on the internet.

The app development is on Adobe Brackets.

Refer here for a complete step-by-step walkthrough for running ionic on both platforms. The following sections only highlight resolutions to problems that you may encounter.

Running ionic on an iOS device:

  • First mistake: Installing every thing in “sudo” mode. Why I did it? I didn’t know this could cause problems. Believe me this could ruin your setup half way through.

Follow these steps from day 1. “How to use npm global without sudo on OS”. A good step-by-step walkthrough of how to install node packages without “sudo”.

I started the “sudo” way and bumped onto the following error, when adding the iOS platform to my ionic project.

$>ionic platform add iOS

Error: EPERM: operation not permitted, utime ‘/Users/<MAC-USER>/.cordova/lib/npm_cache/cordova-ios/3.9.2/package/.npmignore’

Even after re-installing as per the steps twice, I got the same error mentioned above. The NPM Cache clean ($> npm cache clean) did not help. I had to physically delete the cordova package from the iOS platform cache folder.

After that, I cleaned up all the node package installs and followed the steps from John Papa’s post. I was then able to build and run the code on an iOS simulator (use CTRL + C to exit simulator).

  • Running on an iOS device: You would be able to test it on the device. Don’t forget the “–device”. This is not mentioned in the ionic documentation. The “–device” flag is needed to launch the app on the device.

$>ionic run ios –device

  • Resolving security issues: XCode would be able to resolve the security requirements. Open the xCode project of your app that is located under the /platforms/iOS folder in xCode and build the project. It would prompt you for a “fix”which generates all the needed certificates (This cannot be distributed yet since it requires you to register in the Apple Developer Program for some additional signing). XCode would then deploy the build onto your iOS device. Before you When you are running it on your device you need to trust the app from the iOS Developer account. Goto Settings>General>Device Management> and verify the app that you want to run.

Finally, got it my running app on an Apple iPad (iOS 9.2.1).

Running ionic on an Android device:

This also many people claim to be straight forward. But this also has a few nuances that you need to take care. After you install the Android SDK, there are few dependencies that needs to be resolved.

  • Getting a successful build:

After installing the Android SDK, and adding the Android platform to your project, when you try to build, you may get the following error

$>Error: Please install Android target: “android-22”.

To resolve this, open the Android SDK (at terminal prompt type $>android) and install the Android API 5.1.1 (API 22).

Subsequent build may throw the following error

$>Could not find com.android.support:support-v4:23.0.1.

I was able to run past this by installing the Android Support Repository from the Android SDK, per this link . This step is not documented in any getting started guide.

  • Running it on the device:

Put your Android Device in DEBUG Mode

With the above tweaks, I got it running on an NEXUS 5, Android 6.0.1.

Hope this helps!