Skip to content

· 15 min read · Nadeera Silva

Mobile

The Sandbox Is Not in Sync With the Podfile.lock in Flutter

Xcode fails when ios/Podfile.lock and Pods/Manifest.lock differ. Here is why Flutter builds hit it, a tested pre-check script and CI fixes.

Two wooden metronomes on an oak desk with brass pendulums at different angles while a hand reaches to steady one, a laptop softly glowing teal behind them, standing for two lock files that are out of sync

"The sandbox is not in sync with the Podfile.lock" is an Xcode build error that stops a Flutter iOS build before a single file compiles. It shows up on a laptop after git pull, and in CI on GitHub Actions, Codemagic, Xcode Cloud or fastlane. On 3 December 2026 I read the CocoaPods and Flutter source behind it, reproduced the check, and wrote a pre-check script that catches it in seconds instead of ten minutes into a build.

Quick answer

Xcode compares ios/Podfile.lock with ios/Pods/Manifest.lock byte for byte, and fails if they differ or either file is missing. Run cd ios && pod install (not pod update, and not from the project root), then build the .xcworkspace. In CI, run pod install on every build before xcodebuild or fastlane, and key any Pods/ cache on hashFiles('ios/Podfile.lock').

What this means for your app or business

This error does not mean your app is broken. Your code and your live App Store version are fine. The machine that tried to build the app has a different set of iOS libraries installed than the project expects, so Xcode stops rather than ship a mix.

The cost is time. A developer who knows the cause fixes it in five to fifteen minutes. A team that doesn't can lose half a day deleting folders and retrying, and in CI every failed run burns paid macOS build minutes and delays a TestFlight build. The real risk is the "fix" people copy from search results: deleting Podfile.lock can quietly upgrade native SDKs such as Firebase or a payment SDK in a release you meant to keep small.

If your iOS release pipeline fails on this more than once, or someone already deleted the lock file and pushed it, it is worth an hour of a developer's time to set up the checks below.

What does "the sandbox is not in sync with the Podfile.lock" mean?

The exact error is:

error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

When CocoaPods integrates your project, it adds a build phase called [CP] Check Pods Manifest.lock to the front of the Runner target. In CocoaPods 1.17.0 (target_integrator.rb) that phase is this script:

diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [ $? != 0 ] ; then
    # print error to STDERR
    echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2
    exit 1
fi
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"

The "sandbox" is the ios/Pods/ folder. Every pod install writes the same lockfile twice (installer.rb, write_lockfiles): once to ios/Podfile.lock, which you commit, and once to ios/Pods/Manifest.lock, which stays on the machine because Flutter's iOS .gitignore ignores **/Pods/. If someone changes Podfile.lock and your Pods/ folder wasn't reinstalled, the two copies differ and the build stops.

Flow diagram: ios/Podfile goes into pod install, which writes the same lockfile to ios/Podfile.lock and ios/Pods/Manifest.lock; Xcode's Check Pods Manifest.lock phase diffs the two and either continues or fails, with four common CI causes listed below
How pod install and Xcode's Check Pods Manifest.lock phase fit together. Rendered by NX Dev from the CocoaPods 1.17.0 and Flutter 3.50.1 source, 3 Dec 2026.

Why does flutter run work but xcodebuild fail?

flutter build ios, flutter build ipa and flutter run check the lock files themselves. In Flutter 3.50.1 (cocoapods.dart), the tool runs pod install when plugins changed, when Podfile.lock or Pods/Manifest.lock is missing, when Podfile.lock is older than Podfile, or when the two lock files differ. flutter build ios --config-only does this too. flutter pub get does not.

Anything that calls Xcode directly skips that safety net: opening Runner in Xcode, xcodebuild, fastlane's build_app (gym), and Xcode Cloud, which only runs xcodebuild. That is why the error appears so often in CI and right after a git pull.

What causes it in Flutter projects?

CauseWhere you see itHow to tellFix
pod install never ranFresh clone, Xcode Cloud, xcodebuild or fastlane jobsLog shows diff: /Podfile.lock: No such file or directoryRun pod install in ios/ before the build
pod install run from the project rootLocal terminalNo 'Podfile' found in the project directorycd ios && pod install
Teammate changed Podfile.lockAfter git pull or a mergegit log ios/Podfile.lock shows a new commitcd ios && pod install
Stale Pods/ restored from a CI cacheGitHub Actions, self-hosted runnersCache key has no Podfile.lock hash, or restore-keys matchedKey the cache on hashFiles('ios/Podfile.lock') and always run pod install
Podfile.lock not committed or has conflict markersCI, new machinesgit status, grep '<<<<<<<' ios/Podfile.lockResolve, run pod install, commit the lock
CocoaPods version differs and --deployment is usedCI with a pinned lockCOCOAPODS: line differs from pod --version; error says "changes to the lockfile in deployment mode"Pin the same CocoaPods version everywhere
CocoaPods removed by hand after a Swift Package Manager switchAfter deleting Podfile and Pods/Runner still has the [CP] build phasesRun pod deintegrate as Flutter's guide says

The version row needs a word of care. A different CocoaPods version alone doesn't trigger the error, because pod install rewrites both files with its own COCOAPODS: line. It matters when Pods/ comes from a machine or cache with another version, and with pod install --deployment, which compares the whole lockfile, version line included (Lockfile#==) and fails on any change.

Is it safe to delete Podfile.lock and Pods?

Deleting Pods/ is safe. It's a build folder and pod install recreates it. Deleting Podfile.lock is not the same thing. The CocoaPods guide explains that pod install keeps every version already listed in Podfile.lock and only resolves pods that aren't in it. Delete the lock and every pod is resolved again, so any native dependency without an exact pin, such as a Firebase or payment SDK pulled in by a plugin, can jump to a newer version in a build you thought only fixed CI.

The order I use:

  1. cd ios && pod install. This fixes the error in most cases.
  2. If CocoaPods says it can't find a version, run pod install --repo-update.
  3. If one pod is stuck, run pod update ThatPodName, not a full pod update.
  4. Only then delete Pods/, and delete Podfile.lock only as a deliberate upgrade.

How do I fix it locally?

cd ios
pod install          # not 'pod update'
cd ..
open ios/Runner.xcworkspace   # the workspace, never Runner.xcodeproj

If pod isn't found (zsh: command not found: pod), install CocoaPods first. Flutter 3.50.1 treats 1.10.0 as the minimum and recommends 1.16.2 or later; 1.17.0 is current. If pod install fails after a Flutter upgrade, run flutter clean, flutter pub get, then pod install: pub get regenerates the .symlinks folder the Podfile reads plugins from.

How do I stop it in CI?

Step 1: Add a pre-check script

Xcode only tells you about the mismatch after the build starts. This script runs the same diff up front, prints the COCOAPODS: versions from both files and from the machine, and with --fix runs pod install (through Bundler if you have a Gemfile) and checks again. Save it as scripts/check_pods_sync.sh and commit it executable with git add --chmod=+x.

#!/usr/bin/env bash
# check_pods_sync.sh: run the same check as Xcode's "[CP] Check Pods Manifest.lock"
# build phase before you build, and optionally fix it.
# Usage: scripts/check_pods_sync.sh [ios_dir] [--fix]
set -euo pipefail

IOS_DIR="${1:-ios}"
FIX="${2:-}"
LOCK="$IOS_DIR/Podfile.lock"
MANIFEST="$IOS_DIR/Pods/Manifest.lock"

cocoapods_line() {
  # Prints the version from the "COCOAPODS: x.y.z" line, or "none".
  if [ -f "$1" ]; then
    awk '/^COCOAPODS:/ {print $2; found=1} END {if (!found) print "none"}' "$1"
  else
    echo "none"
  fi
}

pod_cmd() {
  # Use the CocoaPods version pinned in Gemfile.lock when there is one.
  if [ -f "$IOS_DIR/Gemfile" ] || [ -f Gemfile ]; then
    echo "bundle exec pod"
  else
    echo "pod"
  fi
}

check() {
  if [ ! -f "$IOS_DIR/Podfile" ]; then
    echo "No $IOS_DIR/Podfile: this app does not use CocoaPods (Swift Package Manager only, or no iOS plugins). Nothing to check."
    return 0
  fi
  if [ ! -f "$LOCK" ]; then
    echo "FAIL: $LOCK is missing. Run 'pod install' once and commit Podfile.lock."
    return 2
  fi
  if grep -qE '^(<<<<<<<|>>>>>>>|=======)' "$LOCK"; then
    echo "FAIL: $LOCK contains merge conflict markers. Resolve them, then run 'pod install'."
    return 2
  fi

  local installed="not installed"
  if command -v pod >/dev/null 2>&1; then
    installed="$(pod --version 2>/dev/null || echo unknown)"
  fi
  echo "CocoaPods in Podfile.lock:   $(cocoapods_line "$LOCK")"
  echo "CocoaPods in Manifest.lock:  $(cocoapods_line "$MANIFEST")"
  echo "CocoaPods on this machine:   $installed"

  if [ ! -f "$MANIFEST" ]; then
    echo "FAIL: $MANIFEST is missing. Pods/ was never installed on this machine (or the cache restored an empty folder)."
    return 1
  fi
  # This is the exact comparison Xcode runs in the build phase.
  if diff "$LOCK" "$MANIFEST" >/dev/null; then
    echo "OK: Podfile.lock and Pods/Manifest.lock are identical. Xcode's check will pass."
    return 0
  fi
  echo "FAIL: Podfile.lock and Pods/Manifest.lock differ. Xcode will stop with 'The sandbox is not in sync with the Podfile.lock'."
  diff -u "$MANIFEST" "$LOCK" | sed -n '3,40p' || true
  return 1
}

status=0
check || status=$?

if [ "$status" -eq 1 ] && [ "$FIX" = "--fix" ]; then
  echo "Running pod install in $IOS_DIR ..."
  # Plain 'pod install' keeps the versions in Podfile.lock. It never upgrades them.
  (cd "$IOS_DIR" && $(pod_cmd) install)
  status=0
  check || status=$?
fi
exit "$status"

I tested it on Linux against fake ios/ folders, with a stub pod that writes Manifest.lock the way CocoaPods does. Case 9 runs the literal Xcode phase script with Pods/ missing. Part of the output:

--- 2. out of sync (stale cached Pods from CocoaPods 1.16.2)
CocoaPods in Podfile.lock:   1.17.0
CocoaPods in Manifest.lock:  1.16.2
CocoaPods on this machine:   1.17.0
FAIL: Podfile.lock and Pods/Manifest.lock differ. Xcode will stop with 'The sandbox is not in sync with the Podfile.lock'.
-COCOAPODS: 1.16.2
+COCOAPODS: 1.17.0
exit code: 1
--- 5. Pods/Manifest.lock missing, with --fix
CocoaPods in Podfile.lock:   1.17.0
CocoaPods in Manifest.lock:  none
CocoaPods on this machine:   1.17.0
FAIL: ios/Pods/Manifest.lock is missing. Pods/ was never installed on this machine (or the cache restored an empty folder).
Running pod install in ios ...
Pod installation complete! (stub)
CocoaPods in Podfile.lock:   1.17.0
CocoaPods in Manifest.lock:  1.17.0
CocoaPods on this machine:   1.17.0
OK: Podfile.lock and Pods/Manifest.lock are identical. Xcode's check will pass.
exit code: 0
--- 6. Podfile.lock missing (not committed)
FAIL: ios/Podfile.lock is missing. Run 'pod install' once and commit Podfile.lock.
exit code: 2
--- 9. Xcode phase when Pods/ is missing (Pods xcconfig not found, so both variables are empty)
diff: /Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
exit code: 1

Exit code 1 means "run pod install", which --fix does. Exit code 2 means a human has to commit or repair Podfile.lock, so the script never guesses there.

Step 2: GitHub Actions

Two caches, two rules. Downloaded pod sources are safe to restore from an older key. The installed ios/Pods folder is only valid for one exact Podfile.lock, so it gets an exact key and no restore-keys. GitHub's dependency caching reference explains that restore-keys restores the most recent partial match, which for Pods/ means a stale Manifest.lock.

name: iOS build

on:
  push:
    branches: [main]
  pull_request:

jobs:
  ios:
    runs-on: macos-26
    steps:
      - uses: actions/checkout@v7

      - uses: subosito/flutter-action@v2
        with:
          channel: stable
          flutter-version: 3.50.1
          cache: true

      # Downloaded pod sources: safe to restore from an older key.
      - name: Cache CocoaPods downloads
        uses: actions/cache@v6
        with:
          path: ~/Library/Caches/CocoaPods
          key: ${{ runner.os }}-pod-downloads-${{ hashFiles('ios/Podfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-pod-downloads-

      # Installed Pods/ folder: exact key only, no restore-keys.
      - name: Cache ios/Pods
        uses: actions/cache@v6
        with:
          path: ios/Pods
          key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}

      - name: Get Flutter packages
        run: flutter pub get

      # Always run it, even on a cache hit. With a warm cache it takes seconds.
      - name: pod install
        working-directory: ios
        run: pod install

      - name: Check Podfile.lock matches Pods/Manifest.lock
        run: ./scripts/check_pods_sync.sh ios

      - name: Build
        run: flutter build ios --release --no-codesign

Signing is a separate step; I covered it in Flutter iOS on GitHub Actions: no signing certificate.

Step 3: Codemagic

Codemagic lets you pin the CocoaPods version in environment, and its caching docs suggest caching $HOME/Library/Caches/CocoaPods, the download cache, not Pods/.

workflows:
  ios-release:
    name: iOS release
    instance_type: mac_mini_m2
    environment:
      flutter: stable
      xcode: latest
      cocoapods: 1.17.0
    cache:
      cache_paths:
        - $HOME/Library/Caches/CocoaPods
    scripts:
      - name: Get Flutter packages
        script: flutter pub get
      - name: Install pods
        script: |
          cd ios && pod install
      - name: Check Podfile.lock matches Pods/Manifest.lock
        script: ./scripts/check_pods_sync.sh ios
      - name: Build ipa
        script: |
          flutter build ipa --release \
            --export-options-plist=/Users/builder/export_options.plist
    artifacts:
      - build/ios/ipa/*.ipa

If the build then fails on profiles, see Codemagic "No matching profiles found".

Step 4: Xcode Cloud

Xcode Cloud clones the repo and runs xcodebuild, so Flutter never gets the chance to run pod install. Apple's dependency guide says CocoaPods is preinstalled and that, when Pods/ is not committed, you install pods in a post-clone script. Flutter's CD guide adds installing Flutter and running flutter pub get first. Save this as ios/ci_scripts/ci_post_clone.sh and make it executable:

#!/bin/sh
# ios/ci_scripts/ci_post_clone.sh for Xcode Cloud.
# Xcode Cloud builds the workspace with xcodebuild, so 'flutter build' never runs
# and nothing installs Pods/ unless this script does.
set -e

cd "$CI_PRIMARY_REPOSITORY_PATH"

# Install Flutter (pin the version your team uses).
git clone https://github.com/flutter/flutter.git --depth 1 -b 3.50.1 "$HOME/flutter"
export PATH="$PATH:$HOME/flutter/bin"

flutter precache --ios
flutter pub get   # creates ios/Flutter/Generated.xcconfig and ios/.symlinks

# Apple's image ships CocoaPods; install it only if it is missing.
if ! command -v pod >/dev/null 2>&1; then
  HOMEBREW_NO_AUTO_UPDATE=1 brew install cocoapods
fi

cd ios && pod install

# Fail here, with a clear message, instead of deep inside xcodebuild.
cd "$CI_PRIMARY_REPOSITORY_PATH" && ./scripts/check_pods_sync.sh ios

exit 0

Step 5: fastlane

fastlane's build_app calls xcodebuild directly, so run the cocoapods action first. Actions run from ios/, while plain Ruby and sh in a Fastfile run from ios/fastlane (fastlane docs), which is why the paths differ below.

default_platform(:ios)

platform :ios do
  desc "Build a release ipa after making sure Pods/ matches Podfile.lock"
  lane :release_build do
    # fastlane runs from ios/fastlane, so paths are relative to ios/.
    Dir.chdir("../..") { sh("flutter", "pub", "get") }

    # Same as 'cd ios && pod install'. Never runs 'pod update'.
    cocoapods(podfile: "Podfile", try_repo_update_on_error: true)

    Dir.chdir("../..") { sh("./scripts/check_pods_sync.sh", "ios") }

    build_app(
      workspace: "Runner.xcworkspace", # the workspace, not Runner.xcodeproj
      scheme: "Runner",
      export_method: "app-store"
    )
  end
end

All five files passed bash -n, ShellCheck 0.11.0, actionlint 1.7.12, a YAML parse and ruby -c on 3 December 2026. I could not run them on real macOS runners from this machine.

Does Swift Package Manager make this go away?

Partly. Flutter 3.44 and later use Swift Package Manager by default and fall back to CocoaPods only for plugins that don't support it, as I explained in CocoaPods read-only: moving Flutter iOS to Swift Package Manager. While a single plugin still needs CocoaPods, the Podfile, both lock files and this build phase stay. Once every plugin supports Swift Package Manager, follow Flutter's removal steps: run pod deintegrate in ios/, then delete Podfile, Podfile.lock, Pods/ and .symlinks/. Deleting the files without pod deintegrate leaves the [CP] phase in the Runner project, and with no Pods/ folder left it fails with this exact error.

How do I verify the fix?

  • ./scripts/check_pods_sync.sh ios prints OK and exits 0.
  • git status ios/Podfile.lock shows no change after pod install. If it does change, someone used a different CocoaPods version or edited the Podfile, so commit or fix that on purpose.
  • In the Xcode or CI log, the [CP] Check Pods Manifest.lock step passes and the build reaches compiling.

How do I prevent it?

  • Commit ios/Podfile and ios/Podfile.lock. Never add Podfile.lock to .gitignore.
  • Keep ios/Pods/ out of git, as Flutter's template does, and always run pod install in CI.
  • Use pod install for day-to-day work and pod update <Name> only for a planned upgrade.
  • Pin one CocoaPods version for the team (Gemfile with bundle exec pod, or Codemagic's cocoapods: field) and check the COCOAPODS: line in review.
  • Key any ios/Pods cache on hashFiles('ios/Podfile.lock') with no restore-keys.
  • Run the pre-check script before xcodebuild, fastlane or Xcode Cloud builds.
  • Build Runner.xcworkspace, never Runner.xcodeproj.

Frequently asked questions

What does the sandbox is not in sync with the Podfile.lock mean?

Xcode's Check Pods Manifest.lock build phase compared ios/Podfile.lock with ios/Pods/Manifest.lock and found they differ or that one is missing. The Pods folder on that machine does not match the dependency versions the project expects, so running pod install in the ios folder fixes it.

What does the diff PODS_PODFILE_DIR_PATH Podfile.lock PODS_ROOT Manifest.lock build phase do?

It is the script CocoaPods adds as the first build phase of your app target. It runs diff on the two lock files and stops the build with this error if they are not identical, so you never build against the wrong pods.

Should Podfile.lock be in .gitignore in a Flutter project?

No. CocoaPods says the Podfile and Podfile.lock should always be under version control. Flutter's iOS template ignores only the Pods folder, which pod install recreates from the lock file.

Is it safe to delete Podfile.lock?

Deleting the Pods folder is safe, but deleting Podfile.lock makes pod install resolve every pod again, which can upgrade native SDKs without anyone reviewing it. Run pod install first and treat deleting the lock as a planned upgrade.

Why do I get command not found: pod on CI or my Mac?

CocoaPods is not installed or not on the PATH. Flutter 3.50.1 needs at least CocoaPods 1.10.0 and recommends 1.16.2 or later; GitHub's macOS 15 and 26 runners ship 1.17.0, and on a Mac you can install it with Homebrew or gem install cocoapods.

Why does flutter build ios work but xcodebuild or fastlane fails?

flutter build and flutter run run pod install automatically when the lock files differ. xcodebuild, fastlane build_app and Xcode Cloud call Xcode directly, so you must run pod install yourself before them.

Does Swift Package Manager fix this error?

Only once CocoaPods is fully removed. Flutter 3.44 and later use Swift Package Manager by default but keep CocoaPods for plugins that need it, and if you delete the Podfile without running pod deintegrate the old build phase can still fail.

Sources

  1. target_integrator.rb: [CP] Check Pods Manifest.lock build phase (CocoaPods on GitHub)
  2. installer.rb: write_lockfiles and deployment checks (CocoaPods on GitHub)
  3. lockfile.rb: Lockfile equality and COCOAPODS version (CocoaPods Core on GitHub)
  4. CocoaPods 1.17.0 release (CocoaPods on GitHub, 2026-07-06)
  5. pod install vs. pod update (CocoaPods Guides)
  6. Using CocoaPods: what is Podfile.lock (CocoaPods Guides)
  7. CocoaPods Trunk Read-only Plan (CocoaPods Blog, 2024-11-30)
  8. flutter_tools cocoapods.dart (stable) (flutter/flutter on GitHub)
  9. flutter_tools mac.dart: buildXcodeProject runs processPodsIfNeeded (flutter/flutter on GitHub)
  10. Flutter iOS app template .gitignore (flutter/flutter on GitHub)
  11. Flutter SDK releases (3.50.1 stable) (Flutter, 2026-11-20)
  12. Swift Package Manager for app developers (Flutter docs)
  13. Continuous delivery with Flutter (Xcode Cloud) (Flutter docs)
  14. Improve error message for The sandbox is not in sync with the Podfile.lock (issue 16422) (flutter/flutter on GitHub, 2018-04-10)
  15. Dependency caching reference (GitHub Docs)
  16. macOS 26 arm64 runner image readme (CocoaPods 1.17.0) (actions/runner-images on GitHub)
  17. Codemagic caching (Codemagic docs)
  18. Codemagic YAML getting started (build machine versions) (Codemagic docs)
  19. Making dependencies available to Xcode Cloud (Apple Developer)
  20. Writing custom build scripts (Xcode Cloud) (Apple Developer)
SharePost on XLinkedIn

Comments

Share a question or note about this article.

Loading comments…

Sandbox Not in Sync With the Podfile.lock: Flutter Fix | Nadeera Silva