React Native

React Native iOS Build Failed "Podfile.lock Is Out of Date"

"Podfile.lock is out of date" means the currently installed CocoaPods dependencies don't match what your project's Podfile currently requires — almost always because JavaScript dependencies changed (via npm/yarn) without a corresponding pod install being run afterward to sync the native side.

The Problem

Building for iOS fails before compilation even begins:

[!] The sandbox is not in sync with the Podfile.lock. Run 'pod install' or 'pod update' to update your sandbox.

error: The Podfile.lock is out of date. Please run pod install/update.

This often appears right after adding a new npm package (particularly one including native iOS code), pulling changes from a teammate, or switching branches with different dependencies.

Why It Happens

React Native projects have two parallel dependency systems that need to stay in sync: package.json/node_modules for JavaScript, and the Podfile/Podfile.lock for native iOS dependencies managed by CocoaPods. Common causes of them falling out of sync:

  • Installing a new npm package that includes native iOS code (many React Native libraries do) without running pod install afterward, so CocoaPods never learns about the new native dependency
  • Pulling changes from version control that modified package.json (and therefore implicitly the required native pods) without running pod install after the pull, since Git doesn't automatically trigger this the way npm install alone might for pure-JS changes
  • Switching between branches with genuinely different dependency sets, where the currently installed pods reflect an old branch's requirements rather than the one you just switched to
  • A CocoaPods cache or lock file becoming stale or corrupted after an interrupted previous pod install run

The Fix

The direct fix, matching exactly what the error message itself suggests, is running pod install from the ios directory:

cd ios
pod install
cd ..

This reads your current Podfile (which is generated based on your project's actual JavaScript dependencies through React Native's autolinking) and updates Podfile.lock and the installed pods to match.

To make this less likely to be forgotten going forward, build the habit of running pod install as a standard step any time you install a new npm package or pull changes affecting package.json — some teams add this as an explicit step in their README's "getting started" instructions, or automate it via a post-install script:

// package.json
"scripts": {
  "postinstall": "cd ios && pod install"
}

This automatically triggers pod install whenever npm install runs, keeping the two dependency systems in sync without requiring anyone to remember the manual step separately.

If a plain pod install doesn't resolve the issue, or reports its own separate errors, try a more thorough clean before reinstalling:

cd ios
rm -rf Pods Podfile.lock
pod install
cd ..

This removes the existing installed pods and lock file entirely, forcing a completely fresh resolution and installation based on the current Podfile, which resolves cases where the existing state is corrupted or inconsistent in a way a normal pod install alone doesn't fully repair.

If you're working across a team with different CocoaPods versions installed locally, confirm everyone is using a compatible version, since significant CocoaPods version differences can occasionally produce subtly different lock file formats or resolution behavior:

pod --version

Still Not Working?

If pod install completes successfully but the build still fails with a related error, clear Xcode's own derived data, which can hold onto stale build artifacts referencing the old pod configuration even after CocoaPods itself has been correctly updated:

rm -rf ~/Library/Developer/Xcode/DerivedData

Combined with a fresh pod install and a clean rebuild, clearing derived data resolves most remaining cases where Xcode's own build cache — separate from CocoaPods' own state — is the actual source of a persisting, seemingly unrelated build failure after the Podfile sync itself has genuinely already been fixed.