Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Simulator Camera: Test your app without a physical device

Camera testing in Xcode’s Simulator is possible, but I’m sure you’re now wondering: how?!

For years, this has not been possible. Literally, it never has been possible to test the camera on the Simulator. Crazy if you think about it. Android’s Simulator has a way of at least basic functionality, but on iOS, we’re always required to run on a physical device.

Since 2019, I’ve been developing a developer tool called RocketSim. My sole goal has always been to make you a more productive developer. One thing that I knew for sure would make developers more productive was testing the camera in the Simulator. So it began…

My journey towards building Simulator Camera support

Where do you start if you want to build the impossible?

For years, Apple’s Simulator remained unchanged. We got a few small improvements, but it’s clear that we would not receive large improvements like Simulator camera support. I figured it was for a reason, because how would you even make it work?

My plan was to use your Mac’s camera as input for the iOS camera. Makes sense, right?

After a multiple tries over the years, I’ve finally been able to make it work:

The first time this worked was magical, unbelievable, and I’m sure you’ll feel the same after trying it out.

Can’t wait? This feature is now available in the Mac App Store:

Download RocketSim

Plug & Play

If you’re a RocketSim user, you know that I want things to work smoothly.

  • No complex setups
  • No certificates or packages you need to keep in sync

The same had to count for this feature to be called a success.

I’ve already had the Network Monitoring feature working, allowing you to monitor all the URLSession network requests in a dedicated window. This feature requires you to link RocketSimConnect for debug builds only. It’s a bit of code that links to a framework bundled with RocketSim. If you update RocketSim, the package will automatically remain in sync.

I’m happy to share that RocketSim’s Simulator Camera feature works out of the box with all your existing AVCaptureSession APIs. Yes, you’re reading that right, you don’t need to adjust any of your camera logic or implement any in-between protocol states.

It works a little too good

Funny enough, I’ve made it work a little too good. The Simulator actually believes a hardware camera device exists. I’ve decided to call it RocketSimCaptureDevice, and if you print the manufacturer, it will say “SwiftLee”, ha!

As a result, the capture session attempts to connect to the hardware device. This is challenging, since I don’t actually have a way to ping back and say, “We’re connected.” Yet, you won’t notice this limitation, and I’ve found a way to make it all work seamlessly.

FREE 5-day email course: The Swift Concurrency Playbook by Antoine van der Lee

FREE 5-Day Email Course: The Swift Concurrency Playbook

A FREE 5-day email course revealing the 5 biggest mistakes iOS developers make with with async/await that lead to App Store rejections And migration projects taking months instead of days (even if you've been writing Swift for years)

Simulator Camera: Stream your Mac’s camera to the Simulator

After a few months of testing, I’m now ready to share it wide open. We’ve solved many edge cases and made it stable for several teams already. Common scenarios like barcode scanning or connection the Vision framework should work out of the box.

Simulator Camera allows you to use your macOS camera in Xcode’s Simulator.

It’s even possible to use your iPhone using Continuity Camera:

https://twitter.com/twannl/status/1928014373210972202

In other words, you could use the Simulator for quick builds and use your phone when you need it.

How to test the camera in Xcode’s Simulator

  1. Download RocketSim

    Download RocketSim for Free from the Mac App Store

  2. Complete RocketSim’s onboarding

    Since RocketSim is sandboxed for security, it will require you to provide a few permissions for common developer directories.

  3. Integrate RocketSim Connect

    Simulator Camera support requires you to integrate RocketSim Connect.

  4. Trigger your app’s camera functionality

    After setup, you can use your app as if it were running on a physical device.

And that’s it! In case you run into any unexpected scenarios, make sure to follow the troubleshooting guidelines.

Conclusion

Simulator Camera helps developers working on camera-enabled apps become more productive. It’s one of those features you’ve thought would never be possible, and it’s magical to see it working for the first time.

I can’t wait for you to give it a try and make sure to let me know how it works out for you!

Thanks

 
Antoine van der Lee

Written by

Antoine van der Lee

iOS Developer since 2010, former Staff iOS Engineer at WeTransfer and currently full-time Indie Developer & Founder at SwiftLee. Writing a new blog post every week related to Swift, iOS and Xcode. Regular speaker and workshop host.

Are you ready to

Turn your side projects into independence?

Learn my proven steps to transform your passion into profit.