My Flutter App Has Two Package.resolved Files per Platform. One Said Firebase 13, the Other Said 12, and Nothing Failed.

Flutter resolves Swift packages twice, into two tracked lockfiles. Here is the one-line check that shows when they disagree.

On October 18 I committed a Firebase upgrade in which one lockfile pinned firebase-ios-sdk at 13.0.0 and its twin still said 12.19.0. No build, lint or check objected.

The timing matters beyond my app. Flutter's Swift Package Manager documentation says SwiftPM support has been on by default since the 3.44 release, and that the CocoaPods registry becomes read-only on December 2, 2026 (I read that page on November 13, 2026). That gives Flutter apps still on CocoaPods a reason to trade Podfile.lock for Package.resolved.

This article is about what I found in my own app after the SwiftPM build already worked: the lockfile exists twice per Apple platform, Flutter updates the two copies at different steps, and a dependency bump can be committed with one of them still pinning the old version.

Each Apple platform tracks two Package.resolved files

My app has no Podfile in ios/, but it has both an Xcode project and an Xcode workspace there. Each of them carries its own Package.resolved, and git tracks all of them:

git ls-files '*Package.resolved'
ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved
macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
macos/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved

The first path in each pair belongs to the project (Runner.xcodeproj has a workspace embedded inside it). The second belongs to the standalone Runner.xcworkspace. Neither is ignored by the .gitignore files in my ios/ and macos/ directories.

A Firebase upgrade committed only one of the pair

On October 18 I upgraded FlutterFire to the Firebase Apple SDK 13 line. The commit changed pubspec.yaml, pubspec.lock, and exactly one Package.resolved. Git still shows the result:

git ls-tree -r --abbrev=8 6c7df08 -- \
  ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm \
  ios/Runner.xcworkspace/xcshareddata/swiftpm
100644 blob d04a9d9f	ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
100644 blob df3bcb1e	ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved

The two files are different blobs. In that commit, the project-level file pins firebase-ios-sdk at 13.0.0, and the workspace file pins it at 12.19.0.

The same branch then migrated the macOS runner to SwiftPM, and that commit added only the project-level file for macOS. The workspace file for macOS did not exist at all.

My notes from that day say the workspace files changed only after I ran the app. A follow-up commit, 23 minutes after the first one, recorded the Firebase 13 pins in the iOS workspace file and added the missing macOS one. It went into the same pull request (#110) before I opened it, so the mismatch never reached a release. The two mismatched commits are still in main's history, though, and no tool complained about either of them.

Why there are two, and who writes which

I read this in the Flutter tool source, first at 3.47.7 (the version I was on in October) and again at 3.50.0 stable for this article.

The tool's build, build-settings and project-info calls to xcodebuild go through fetchDependenciesAndGenerateXcodebuildArgs in packages/flutter_tools/lib/src/ios/xcodeproj.dart. Its first step is a package prefetch, and the comment above it explains why:

// All `xcodebuild` project commands will download and resolve Swift packages.
// We should always prefetch Swift packages before running any `xcodebuild` project command
// to control the output.
await prefetchSwiftPackagesForProject(xcodeProject, buildDirectory: buildDirectory);

The prefetch itself is in xcode_project.dart:

final command = <String>[...xcodebuildProjectCommandArguments, '-resolvePackageDependencies'];

The arguments in front of that flag are the xcodebuild invocation and -clonedSourcePackagesDirPath <cache>. There is no -workspace and no -project, and the process starts in the host app directory. A bare xcodebuild there picks up the project, so this resolution writes the file under Runner.xcodeproj. That last step is Xcode's behavior, not Flutter's: I am inferring it from which file changed, not from source.

The real build is a second xcodebuild call, and in lib/src/ios/mac.dart it names the workspace when one exists:

final Directory? workspacePath = app.project.xcodeWorkspace;
if (workspacePath != null) {
  buildCommands.addAll(<String>['-workspace', workspacePath.basename]);
} else {
  buildCommands.addAll(<String>['-project', app.project.xcodeProject.basename]);
}

That resolution writes the file under Runner.xcworkspace. This is again Xcode's behavior, inferred from the follow-up commit, which changed only the workspace files after the app had run.

Between the two calls sits this, in the same function:

if (configOnly) {
  return XcodeBuildResult(success: true);
}

So the order is: prefetch, then an early return for --config-only, then the workspace build. A flutter build ios --config-only reaches the prefetch and stops before the workspace build. A flutter run or a full flutter build reaches both. The macOS path in lib/src/macos/build_macos.dart has the same shape: its project-info call prefetches, the configOnly return follows, and the workspace build comes last.

That matches what I saw. I did not record the exact command that produced the one-file commit, but its diff is what a project-only resolution would leave behind.

Synced files are byte-identical, so cmp is the check

When the two files are in sync, they are not merely equivalent. They are the same bytes. Thirteen commits in my repository touch these files (as of November 27, 2026), and in every one except the two from October 18, git stores each pair as a single blob. So the check is cmp:

cmp ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved \
    ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved; echo "ios exit $?"
cmp macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved \
    macos/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved; echo "macos exit $?"

On my current main (November 13):

ios exit 0
macos exit 0

cmp prints the first differing byte and exits 1 when the files differ, and exits 2 when one is missing, which covers the macOS case above.

To bring all four up to date without a full build, I resolve each container explicitly. These are the four lines from my project's task runner:

xcodebuild -workspace ios/Runner.xcworkspace -scheme production -resolvePackageDependencies
xcodebuild -project ios/Runner.xcodeproj -scheme production -resolvePackageDependencies
xcodebuild -workspace macos/Runner.xcworkspace -scheme production -resolvePackageDependencies
xcodebuild -project macos/Runner.xcodeproj -scheme production -resolvePackageDependencies

production is one of my flavor schemes; use your own scheme name. The order in my project notes is: these four after a plugin or Flutter upgrade, then cmp, then the commit.

Convention or CI gate

There are two decisions here, and I can see a reasonable person landing differently on both.

Track both files, or ignore one. I track both. Each one is read by a step Flutter actually runs, and a lockfile that is not in git is not a lockfile. The case for ignoring one is real: two files that must be identical is a duplicate, and duplicates drift. If you go that way, the workspace file is the one to keep, because the build that produces your binary names the workspace. I have not tested what the prefetch does on a clean checkout with the project-level file missing, so I am not recommending it.

A convention, or a CI check. Today the check is the convention above: four commands, cmp, commit. There is no CI job for it in my repository. The strongest argument against that is my own history. On October 18 the gap closed 23 minutes later because the app was run before the pull request was opened, not because anything checked the files. A cmp step costs two lines and needs no macOS runner, because it only compares files already in the checkout.

The caveat for a gate is that byte equality is something I observed, not something Xcode promises. It has held for every synced commit in one app with no Podfile. If a workspace legitimately contains more than the Runner project, its file could differ for good reasons, and a red CI job that is wrong teaches people to ignore it. For an app shaped like mine, I think the gate is the better choice.

Limits

The mechanism was read in Flutter 3.47.7 and 3.50.0 tool source, and other versions may order these steps differently. The evidence is one app, two platforms, and ten commits between October 3 and November 13, 2026.

In 3.50.0, build_macos.dart notes that the .xcworkspace "may not exist (e.g. a project using Swift Package Manager without CocoaPods)" and falls back to building the project. An app with no workspace would have one file per platform, not two. Mine has both, and I have not tested the single-container layout.

Which file a bare xcodebuild writes is inferred from one commit's diff and from the xcodebuild manual, which requires -project only when a directory holds several projects.

I did not test what a clean release build resolves when the two files disagree. In my case the stale pin was a whole major version behind, and the next app run rewrote it. A stale pin that still satisfies the plugin's version range might simply be used, which is the case a lockfile exists to prevent, but I have not reproduced that.

If you finished a SwiftPM migration recently, the git ls-files line at the top tells you in a second whether you have this pair. If you do, run cmp before your next dependency commit.