Swift Package Manager setup for the Facebook SDK in Flutter
Last updated August 7, 2026
Both integration paths are supported
On iOS you can bring the Facebook SDK in with either CocoaPods or Swift Package Manager. The plugin supports both, and neither one changes the Dart API.
- CocoaPods is the Flutter default. There are no extra steps beyond the standard Facebook configuration: the podspec declares
FBSDKCoreKitand the pod install does the rest. - Swift Package Manager uses a package manifest the plugin bundles, at
ios/facebook_app_events/Package.swift.
What neither path does is fill in your Info.plist. The app id and client token keys are still yours to set, and if they are missing no integration path will save you: where the Facebook client token goes in a Flutter app covers them.
Facebook's own iOS SDK documents its Swift Package Manager support, and that page is linked at the end of this one. What it cannot document is the Flutter-specific part, which is the next section.
The product name uses hyphens, not underscores
This is the detail that costs an afternoon, and it is written down in exactly one place: the manifest itself.
The package is named facebook_app_events. The target is named facebook_app_events. The library product is named facebook-app-events, with hyphens.
products: [
// If the plugin name contains "_", the library name must use "-".
.library(name: "facebook-app-events", targets: ["facebook_app_events"])
],The comment is in the file, and it is the whole reason: if the plugin name contains an underscore, the library name has to use a hyphen. Underscores in the package and the target, hyphens in the product.
Which means that if you type the product name from memory, or copy it from the plugin's name on pub.dev, you will type the underscored form. Meta's documentation cannot warn you about this, because it is not about Meta's package. Ours can, and this page is it.
What the manifest declares
The whole file, so you can compare it against what your project is asking for:
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "facebook_app_events",
platforms: [
.iOS(.v13)
],
products: [
// If the plugin name contains "_", the library name must use "-".
.library(name: "facebook-app-events", targets: ["facebook_app_events"])
],
dependencies: [
.package(url: "https://github.com/facebook/facebook-ios-sdk.git", "18.0.0"..<"19.0.0")
],
targets: [
.target(
name: "facebook_app_events",
dependencies: [
.product(name: "FacebookCore", package: "facebook-ios-sdk"),
.product(name: "FacebookBasics", package: "facebook-ios-sdk")
]
)
]
)Four declarations in there decide whether resolution succeeds:
swift-tools-version: 5.9. Your toolchain has to understand 5.9.platforms: [.iOS(.v13)]. A project targeting an older iOS does not satisfy it.- The dependency range on
facebook-ios-sdk,"18.0.0"..<"19.0.0". That is the same major-only policy as the CocoaPods and Maven declarations, and which Facebook SDK version a Flutter app gets covers why it is written that way. - Two products from that dependency,
FacebookCoreandFacebookBasics. Those two, and nothing else.
That last line is a scope statement as much as a build detail. The plugin covers App Events. There is no Facebook Login and no sharing API in it, so those are not products the target asks for.
The iOS lifecycle requirement
This applies whichever integration path you pick, and it is the other thing that bites.
The plugin supports both the legacy UIApplicationDelegate lifecycle and the newer UIScene lifecycle, which is the default for apps built with Flutter 3.38 and later. It registers as both an application delegate and a scene delegate, so Facebook URL callbacks, meaning deep links and deferred app links, reach the SDK either way. No extra host-app configuration is required beyond the standard Facebook setup.
That is also why the plugin requires Flutter 3.38.0 or newer. It uses Flutter's scene-delegate plugin APIs, FlutterSceneLifeCycleDelegate and addSceneDelegate, which were added in 3.38. On an older Flutter those symbols are not there.
So if your Flutter is older than 3.38, fix that before you debug anything else on this page. The plugin's pubspec.yaml declares flutter: '>=3.38.0', so the package will not resolve for you at all.
When Swift Package Manager will not resolve
You will not find error strings quoted here. Swift Package Manager's messages vary by toolchain and by which part of the graph gave up, and a page that guesses at them sends you searching for text you will never see. What follows is what to check, cheapest first.
- The product name.
facebook-app-events, with hyphens. It is the first thing to check because it is the most common thing to get wrong. - Your iOS deployment target. The manifest declares
.iOS(.v13). Read the setting on your own target in Xcode, not the value you remember setting and not the example app's. - Your Flutter version. 3.38.0 or newer, per the section above.
- Another constraint on
facebook-ios-sdk. If something else in your project constrains it outside"18.0.0"..<"19.0.0"then the graph has no solution. Search your other package manifests forfacebook-ios-sdkbefore you suspect this one. - Two paths at once. Pick CocoaPods or Swift Package Manager per project, then check that the other one is not also supplying the Facebook SDK. Two sources for the same code is cheap to rule out and expensive to debug later.
Package.resolved. Read what was actually chosen instead of reasoning about what should have been. This is the file that ends the argument.
If all six check out and resolution still fails, that is a real bug report and we would like it. The useful contents are the resolver's own output, your Package.resolved, your deployment target and your Flutter version, in an issue on the repository.
If your events are not arriving, this is a different page
Resolving a package and delivering an event are separate problems. Once the package resolves and the app builds, an empty Events Manager is a configuration or transport question, and it has its own page: Facebook events not showing in Events Manager.
Verify your setup
- The Swift Package Manager product you added is spelled facebook-app-events, with hyphens
- Your Xcode target's iOS deployment target is 13.0 or higher
- Flutter is 3.38.0 or newer
- Package.resolved names facebook-ios-sdk at a version inside 18.x
- No other package in your project constrains facebook-ios-sdk outside 18.0.0 up to but not including 19.0.0
- The Facebook SDK reaches your app through one integration path, not through CocoaPods and Swift Package Manager at the same time
- The standard Facebook keys are in Info.plist, which no integration path fills in for you
Meta's reference documentation
Plugin API reference
Still stuck?
It is a plugin defect
If the plugin is doing something the native Facebook SDK does not, that is our bug. Open an issue and we fix it. Free, always, no conditions.
Open a GitHub issueIt is a usage question
Configuration and integration questions are best asked where other developers can find the answer later.
Ask on StackOverflowYour numbers are wrong and money is moving
If Meta install campaigns are spending and the attribution does not add up, that is a different problem from a broken build. One hour, 300 USD, credited against the audit if you go ahead.
See the diagnostic and audit