Xcode
Xcode is the worst IDE of all time.
Terminology
- A Scheme is a runnable configuration that tells Xcode which target to build, which to run, which tests to execute, etc.
- A Target is a product within an Xcode project: an iOS app, a test bundle, extension, framework, Watch app, etc.
Running and debugging
Test changes to a Watch app on a physical Watch
For an Xcode project with an independent Watch target, you should select the Watch target.
- (Optional but recommended) Connect your phone to the Mac using a USB cable.
- In Xcode, select the watch app from the Scheme dropdown at the top of the IDE.
- Select the physical watch as the Destination.
- Click Run (or Cmd+R).
In-App Purchases
Troubleshooting IAPs
- First, use StoreKit in your app. Add the
.storekitfile to your Test target. - Use the StoreKit Transactions window to see and refund transactions.
Screenshots
Take a screenshot
To take a screenshot from a physical device:
- From Xcode, open Window > Devices & Simulators
- Select the device in question.
- Click Take Screenshot.
Troubleshooting
Cannot test target “APP_NAME” on “Any iOS Simulator Device”: Tests must be run on a concrete device
You can’t run tests on the Any iOS Simulator Device pseudo-device (which is usually found under the Build heading).
In the navigator bar at the top of Xcode, choose a specific iOS Simulator device (like “iPhone 16”), or a real physical device.
“A build only device cannot be used to run this target.” or “Tests must be run on a concrete device”
In the Scheme/Target Navigator at the top of Xcode, make sure you’ve selected a named make/model, under iOS Simulators.