Mastering iOS Debugging for Ionic Apps on macOS with VS Code

Building on my previous guide, this blog post dives into setting up debugging for Ionic mobile apps on macOS, with a particular focus on iOS debugging using Visual Studio Code. I’ll walk you through the steps to configure breakpoints, leverage Safari’s Web Inspector, and run your app on both simulators and iPhones for a streamlined development experience.

Debug an Ionic App on iOS Device (from Mac)

In the steps below, I’ll walk you through the process of setting up a debugging environment for your Ionic app on macOS, using Visual Studio Code, Xcode, and Safari’s Web Inspector. You’ll learn how to build the app, connect it to an iOS simulator or physical device, and place breakpoints within your code to catch and resolve issues. By the end, you’ll have a reliable workflow for debugging your app on iPhones or simulators, ensuring a smoother development and testing experience.

1. Open the project in VS Code

Open the Ionic project (e.g., ThPokemonDemo) in Visual Studio Code.

2. Build the project

Run the following command to build your Ionic app using the Ionic CLI.

ionic build

3. Sync Capacitor and Open Xcode

Next, sync Capacitor and open the project using the following command (Reference link):

npx cap copy && npx cap sync && npx cap open ios

NOTE: npx cap open ios will open the project on XCode.

4. Run the app on a simulator or device

In Xcode, select an available simulator or connected iOS device, and run the app.

5. Enable Web Inspector in Safari

Open Safari and go Settings > Advanced. Make Sure to enable the “Show features for web developers” option.

6. Connect to your device in Safari

Go to the Develop tab. Select the device where the app is running. Tap your app name (e.g., ThDemo) to open the Web Inspector.

7. Set breakpoints in Safari

Safari will show the following screen where we can put breakpoints to debug the code.

We can see the home.page.ts is under src_app_home_home_module_ts.js.

8. Trigger the breakpoints

Let’s put some breakpoints in home.page.ts (Lines 30 and 32) and click Load Pokémons button.

We’ll see the values of results :)!

9. Debug additional pages

Let’s put another breakpoint in pokemon-detal.page.ts (Line 42).

10. Debug on an iPhone

If we want to debug on an iPhone. Select the iPhone on XCode like in step 4 and run the project.

11. Enable Web Inspector on the device

Enable Web Inspector (Settings > Safari > Advanced > Web Inspector).

12. Select the device

Select the iPhone and follow the steps 8 and 9.

Conclusion

By strengthening your debugging setup to support iOS devices and simulators on macOS, you enhance your ability to build reliable Ionic mobile apps. Leveraging VS Code alongside Xcode and Safari’s Web Inspector enables you to confidently address issues on iPhones and ensures a smoother development process, allowing you to deliver a more polished, stable apps.

At Trailhead, we are experts in building and debugging mobile applications using hybrid frameworks like Ionic. If you’d like to learn more, contact us to set up a free consultation.

Additional Reading

For more on Ionic debugging, check out this link from the Ionic team.

Picture of Junior Saravia

Junior Saravia

Junior Saravia earned his B.S. in Systems Engineering from the National University of Engineering in Lima, Peru. He has 5 years of experience in cross-platform Mobile Development using Xamarin and now .NET MAUI. He has been focused on keeping up-to-date with new technology trends such as IoT, microcontrollers, and various coding best practices. His strong collaboration and adaptability to face up to challenging projects have proven his ability to offer valuable solutions to clients through complex technologies. Beyond the realm of technology, Junior enjoys practicing soccer, swimming, and the freedom of biking outdoors.

Free Consultation

Sign up for a FREE consultation with one of Trailhead's experts.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Montage Portal

Montage Furniture Services provides furniture protection plans and claims processing services to a wide selection of furniture retailers and consumers.

Project Background

Montage was looking to build a new web portal for both Retailers and Consumers, which would integrate with Dynamics CRM and other legacy systems. The portal needed to be multi tenant and support branding and configuration for different Retailers. Trailhead architected the new Montage Platform, including the Portal and all of it’s back end integrations, did the UI/UX and then delivered the new system, along with enhancements to DevOps and processes.

Logistics

We’ve logged countless miles exploring the tech world. In doing so, we gained the experience that enables us to deliver your unique software and systems architecture needs. Our team of seasoned tech vets can provide you with:

Custom App and Software Development

We collaborate with you throughout the entire process because your customized tech should fit your needs, not just those of other clients.

Cloud and Mobile Applications

The modern world demands versatile technology, and this is exactly what your mobile and cloud-based apps will give you.

User Experience and Interface (UX/UI) Design

We want your end users to have optimal experiences with tech that is highly intuitive and responsive.

DevOps

This combination of Agile software development and IT operations provides you with high-quality software at reduced cost, time, and risk.

Trailhead stepped into a challenging project – building our new web architecture and redeveloping our portals at the same time the business was migrating from a legacy system to our new CRM solution. They were able to not only significantly improve our web development architecture but our development and deployment processes as well as the functionality and performance of our portals. The feedback from customers has been overwhelmingly positive. Trailhead has proven themselves to be a valuable partner.

– BOB DOERKSEN, Vice President of Technology Services
at Montage Furniture Services

Technologies Used

When you hit the trails, it is essential to bring appropriate gear. The same holds true for your digital technology needs. That’s why Trailhead builds custom solutions on trusted platforms like .NET, Angular, React, and Xamarin.

Expertise

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

  • Project Management
  • Architecture
  • Web App Development
  • Cloud Development
  • DevOps
  • Process Improvements
  • Legacy System Integration
  • UI Design
  • Manual QA
  • Back end/API/Database development

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

Our Gear Is Packed and We're Excited to Explore with You

Ready to come with us? 

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the contact form. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.