Book Image

Ionic 2 Cookbook - Second Edition

By : Hoc Phan
Book Image

Ionic 2 Cookbook - Second Edition

By: Hoc Phan

Overview of this book

Developing real-time apps is the need of the hour, and apps that deal with humongous amounts of user data and real-time information that needs to be updated frequently are in high demand. Currently, one of the most popular frameworks for this task is Ionic Framework, which is undergoing a major makeover. This book will get you started with Ionic and help you create Angular 2 components that interact with templates. From there, you’ll work with Ionic components and find out how to share data efficiently between them. You’ll discover how to make the best use of the REST API to handle back-end services and then move on to animating the application to make it look pretty. You’ll learn to add in a local push notification in order to test the app. You’ll work with Cordova to support native functionalities on both iOS and Android. From there, you’ll get to grips with using the default themes for each platform as well as customizing your own. Finally, you’ll see how best to deploy your app to different platforms. This book will solve all your Ionic-related issues through dedicated recipes that will help you get the best out of Ionic.
Table of Contents (16 chapters)
Ionic 2 Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Viewing the app using Xcode for iOS


You could run the app using Xcode (in Mac) as well.

How to do it…

  1. Go to the /platforms/ios folder.

  2. Look for the folder with .xcodeproj and open it in Xcode.

  3. Click on the iOS Device icon and select your choice of iOS simulator:

  4. Click on the run button and you should be able to see the app running in the simulator.

There's more…

You can connect a physical device via a USB port and it will show up in the iOS Device list for you to pick. Then, you can deploy the app directly on your device. Note that iOS developer membership is required for this. This method is more complex than just viewing the app via a web browser.

However, it's a must when you want to test out your code related to device features, such as camera or maps. If you change code in the /app folder and want to again run it in Xcode, you have to do ionic build ios first, because the running code is in the Staging folder of your Xcode project, as illustrated:

For debugging, the Xcode Console can output JavaScript logs as well. However, you could use the more advanced features of Safari's Web Inspector (which is similar to Google Chrome's Developer Tools) to debug your app. Note that only Safari can debug a web app running on a connected physical iOS device because Chrome does not support this on a Mac. It's easy to enable this capability, and it can be done with the following steps:

  1. Allow remote debugging for iOS device by navigating to Settings | Safari | Advanced and enabling Web Inspector:

  2. Connect the physical iOS device to your Mac via USB and run the app.

  3. Open the Safari browser.

  4. Select Develop | your device's name (or iOS Simulator) | index.html, as shown:

    Note

    If you don't see the Develop menu in Safari, you need to navigate to Preferences > Advanced and check on Show Develop menu in menu bar

Safari will open a new console just for that specific device just as it's running within the computer's Safari.