sudo xcode-select --switch /Applications/Xcode.app in Terminal to point to the active Xcode installation.Why this happens
The xcrun: error: SDK "iphoneos" cannot be located message appears when the xcrun tool cannot find the active iOS SDK. This usually means the Xcode command line tools path is either unset, pointing to a deleted Xcode version, or stale after an Xcode update. The error commonly surfaces during pod install, xcodebuild, or React Native iOS builds because those tools invoke xcrun internally to locate SDKs and compilers.
When you install or update Xcode, the command line tools symlink at /Library/Developer/CommandLineTools or the xcode-select path may not update automatically. If multiple Xcode versions exist (for example, /Applications/Xcode.app and /Applications/Xcode-15.0.app), the active developer directory can point to the wrong one.
How to fix it
1. Re-select Command Line Tools in Xcode Settings (most reliable)
This is the standard fix recommended by Apple and works even when the dropdown already appears correct.
- Open Xcode.
- Choose Xcode > Settings (or Preferences on older macOS).
- Click the Locations tab.
- In the Command Line Tools dropdown, click the current selection and choose the same Xcode version again.
- Enter your macOS login password when prompted.
Re-selecting forces Xcode to rewrite the active developer directory and refresh the SDK symlinks. After the password is accepted, close Settings and retry pod install or your build command.
2. Set the active developer directory from Terminal
If you prefer the command line or Xcode isn’t installed in the default location, use xcode-select:
sudo xcode-select --switch /Applications/Xcode.app
Replace the path if your Xcode lives elsewhere (for example, /Applications/Xcode-15.2.app). The command updates /var/db/xcode_select_link and makes the specified Xcode the system default for xcrun, xcodebuild, and related tools.
Verify the change:
xcrun --show-sdk-path --sdk iphoneos
You should see a path ending in iPhoneOS.sdk without errors.
3. Install standalone Command Line Tools (if Xcode isn’t installed)
On CI machines or minimal setups without the full Xcode app, install the standalone package:
xcode-select --install
A GUI prompt appears; confirm the install. After it finishes, the SDK error should disappear for command-line workflows.
How to prevent it
- Keep Xcode in the default
/Applications/Xcode.applocation; avoid renaming the app bundle. - After every Xcode update, open Xcode once and re-select the Command Line Tools dropdown.
- In CI/CD scripts, pin the Xcode version with
sudo xcode-select --switch /Applications/Xcode_<version>.appbefore any build step. - Do not delete old Xcode versions until the new one has been selected as the active developer directory.
FAQ
Why does the error appear even though the Command Line Tools dropdown shows the right version?
The dropdown can display a stale selection after an Xcode update or when multiple Xcode versions coexist. Re-selecting the same entry forces a refresh of the underlying symlinks and clears the cached SDK paths.
Can I fix this without opening Xcode?
Yes. Run sudo xcode-select --switch /Applications/Xcode.app (adjust the path if needed) in Terminal. This achieves the same result as re-selecting in Settings.
Does this affect simulator builds too?
The same xcrun mechanism resolves both iphoneos and iphonesimulator SDKs. Fixing the command line tools path resolves the error for device and simulator builds alike.\n
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
