Flutter with SwiftPM
Use spmx in Flutter projects that build their iOS or macOS plugins through Swift Package Manager.
Flutter generates an ephemeral Swift package, FlutterGeneratedPluginSwiftPackage, that pulls in your plugins' native dependencies. Each new worktree needs it regenerated and resolved before Xcode can build.
With the flutter shim active, flutter run and flutter build ios (or macos) do this for you:
- If
ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/Package.swiftis missing, the shim runsflutter pub getwith the real Flutter binary first. - It hydrates the
SourcePackagesofRunner.xcworkspacefrom the store, and restores a compatiblePackage.resolvedwhen the worktree has none. - It runs the real
flutter, which callsxcodebuild. Thexcodebuildshim seesSPMX_FLUTTER_SHIM_ACTIVE=1and does not hydrate a second time. - After the build, new packages are harvested into the store.
Both the ios/ and macos/ targets are supported.
git worktree add ../app-feature
cd ../app-feature
flutter run
spmx status ios/Runner.xcworkspace # how many pins were already cachedProjects that still use CocoaPods
spmx caches Swift Package Manager dependencies. A project that uses only a Podfile has nothing for it to manage in Pods/.
Flutter CLI build folders
The Flutter CLI can also keep a SourcePackages cache under build/<platform>/SourcePackages. spmx handles that location too, so flutter build and flutter run share the store the same way Xcode does.
puro and fvm
puro flutter ... invokes the Flutter SDK directly and bypasses the flutter shim, although the xcodebuild shim still applies. Run plain flutter to get the full behavior. spmx doctor reports how your setup resolves.