Fix 'iphoneos cannot be located' in React Native
By Flavio Copes
Learn how to fix the SDK iphoneos cannot be located error when running pod install for React Native on macOS, using sudo xcode-select to set Xcode.
If pod install fails with SDK "iphoneos" cannot be located, the fix is to point your command line tools at the full Xcode app with sudo xcode-select --switch /Applications/Xcode.app.
Here’s how I ran into it, and why that command works.
While installing React Native to run a project on iOS, I run into a problem.
I went into the project’s ios folder to run pod install as I was instructed to do.
But as I ran that command, I got a long error message back:


From this error I read the error: SDK "iphoneos" cannot be located.
That looked suspicious, right?
Why does this error happen?
macOS has two separate sets of developer tools. There’s the Command Line Tools package, a small standalone install with compilers and Git. And there’s the full Xcode app, which is the only one that ships the iOS SDK, named iphoneos.
The xcode-select utility decides which of the two your terminal commands use. You can check the current setting:
xcode-select -p
If it prints /Library/Developer/CommandLineTools, your system is using the standalone tools. Those don’t include the iOS SDK, so anything that needs it will fail.
That’s exactly what happens with pod install. While analyzing dependencies, CocoaPods calls xcodebuild behind the scenes, xcodebuild looks for the iphoneos SDK in the active developer directory, and it’s not there.
The fix
So I researched a bit and what fixed the problem was running the command
sudo xcode-select --switch /Applications/Xcode.app
This switches the active developer directory to the full Xcode install, where the iOS SDK lives. Running xcode-select -p again now prints /Applications/Xcode.app/Contents/Developer.
Then running pod install again worked fine!

One thing to check first
The command only works if Xcode is actually installed in /Applications. If you never installed it, get it from the Mac App Store first. It’s a big download.
And if you installed it but never opened it, launch it once. Xcode asks you to accept the license and installs some extra components on first run, and command line builds can fail until that’s done.
Related posts about react-native: