New features in Xcode 8.2 Simulator
In the release notes of Xcode 8.2, Apple introduced features for their new version of Xcode. In this blog I will explain how to use these new features.
This are the two new features for the Xcode 8.2 Simulator:
- You can take videos and screenshots of Simulator using the
xcrunXcode command-line utility.
📷 To take a screenshot, run the command
xcrun simctl io booted screenshot.
📹 To take a video, run the command
xcrun simctl io booted recordVideo <filename>.<mp4|mov>(9887264)
- Dragging an app onto a Simulator window installs the app. (23387069)
The first feature, recording videos and taking screenshots, is pretty straightforward. You can start your Simulator, run your app on it and you can take a screenshot or start/stop a video.
This feature is pretty convenient for sending demo videos from your app.
Although the command is pretty long, it works very easy!
Drag and Drop
The second feature, dragging an app onto a Simulator window, was not so straightforward. At least, not for me 😉
What I thought was that when I have an app in .ipa format, I could simply drag this app onto a Simulator window which will install the app. Too bad, this is not the case.
But what would Apple mean with; “Dragging an app onto an Simulator” ? So, I searched the big interwebs and did a bit of research on Twitter, where I received this tweet from Brandon.
After he gave me this information, I tried to drag an Simulator app bundle (.app) onto a iOS 10.2 Simulator and with success, the app was installed!
The question that raised was; why is a .app working in the Simulator and a .ipa isn’t? This is because an iOS app in .ipa format is build for a different architecture(ARM) then where the Simulator works on(x86).
So, an iOS app in .ipa format can only be installed on a physical device and will never work on a Simulator!
Additional: Get the app bundle from DerivedData
Now we know how to drag and drop the app bundle onto the Simulator, I would also like to give some details about the app bundle.
The app bundle is located in the DerivedData folder and is compiled when the project is build for a device. This DerivedData folder contains all the intermediate build information, debug- and release-build targets, as well as your project’s index.
The specific location of the Simulator app bundle can be found here:
From Xcode you can go to the DerivedData folder via File → Workspace Settings. This will popup the following window.
Clicking on the arrow will open a Finder window with the DerivedData folder. Next, go to the <project name>/Build/Products/Debug-iphonesimulator/ folder. In this folder you will find the app bundle. Finally, drag the app bundle onto the iOS Simulator and the app will be installed!
Additional 2 (Feb. 2017): Get the app bundle from Products
After sharing this knowledge with my colleagues at Xebia, one colleague told me another way of getting the app bundle.
In a Xcode project, default there will also be a folder called “Products”. When a project is successfully build, the app bundle will also be linked in this folder. From this folder, you can drag the .app bundle to the simulator.
This way does not involve the cumbersome way of navigating to the DirevedData folder! So less steps are needed and you can be more productive.
Enjoy and thanks for reading!
Follow me on twitter to get updated about new blogs.
Originally published at blog.xebia.com.