Skip to content

Adds ‎google_mobile_ads support for Swift Package Manager#1395

Open
stuartmorgan-g wants to merge 9 commits intogoogleads:mainfrom
stuartmorgan-g:swift-package-manager
Open

Adds ‎google_mobile_ads support for Swift Package Manager#1395
stuartmorgan-g wants to merge 9 commits intogoogleads:mainfrom
stuartmorgan-g:swift-package-manager

Conversation

@stuartmorgan-g
Copy link

@stuartmorgan-g stuartmorgan-g commented Jan 26, 2026

Description

Adds Swift Package Manager support to google_mobile_ads:

  • Updates the file structure to follow Swift Package structure (see docs).
  • Adjusts the podspec for the new file layout, so that non-SwiftPM builds will continue to work.
  • Adds the Swift.package definition.
  • Updates the example app to add SwiftPM compatibility (the auto-migration does not work for this example project; I'm not sure what changes caused that).
  • Updates the example app to import the module, as a real client app would do, instead of having duplicate reference versions of all of the source embedded directly in the project, which causes duplicate definition compilation issues with SwiftPM. (I'm surprised it didn't already cause them with CocoaPods.)

Related Issues

Fixes #1239

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>13.0</string>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an auto-migration from running with a recent version of Flutter; I can revert if you prefer, as it's unrelated, but it will be re-deleted on every run.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file is the result of following the instructions for manually adding SwiftPM support to the example app.

**/Flutter/flutter_assets/
ServiceDefinitions.json
xcuserdata/
xcshareddata/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this was ignored in the first place, but the scheme details are a necessary part of the project now.

let package = Package(
name: "google_mobile_ads",
platforms: [
.iOS("13.0")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 13.0 rather than the 12.0 used in the podspec because webview-flutter-wkwebview requires 13, and Xcode enforces coherent min versions on a per-target level (unlike CocoaPods, which only fails if the final app has mismatches, which wasn't happening because any app built with a recent version of Flutter requires at least 13.0).

@stuartmorgan-g
Copy link
Author

The example app still seemed to work and show ads, but since I'm not deeply familiar with the project, someone who is should likely do manual testing as well.

@jmagman
Copy link
Contributor

jmagman commented Jan 27, 2026

@stuartmorgan-g do the mediation packages also require migration? https://github.com/googleads/googleads-mobile-flutter/tree/main/packages/mediation

@stuartmorgan-g stuartmorgan-g changed the title Adds support for Swift Package Manager Adds ‎google_mobile_ads support for Swift Package Manager Jan 27, 2026
@stuartmorgan-g
Copy link
Author

I hadn't looked in there; I didn't realize they were all plugins as well. They will need migration, but it's not as urgent since the breakage reported in the issue is specific to having a dependency on another plugin in the podspec. I've updated my comment in the issue and this PR description to clarify that this only does the one package.

@malandr2 malandr2 requested a review from LTPhantom February 11, 2026 17:19
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>13.0</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@LTPhantom
Copy link
Collaborator

Thanks @stuartmorgan-g! It seems some checks are failing but I feel it's because PR is behind some workflow fixes. Can you rebase so that we can retry the checks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add Swift Package Manager support (SPM)

3 participants