Skip to content

Add SPM support for Apple Embedded plugins (.gdip)#116939

Open
gumaciel wants to merge 1 commit intogodotengine:masterfrom
gumaciel:spm-integration
Open

Add SPM support for Apple Embedded plugins (.gdip)#116939
gumaciel wants to merge 1 commit intogodotengine:masterfrom
gumaciel:spm-integration

Conversation

@gumaciel
Copy link
Copy Markdown
Contributor

@gumaciel gumaciel commented Mar 1, 2026

Add spm_packages key to the [dependencies] section of .gdip files, allowing plugins to declare Swift Package Manager dependencies with exact version pinning. The export pipeline generates the corresponding PBX entries in the Xcode project.


Satisfies godotengine/godot-proposals#4758. Thanks to @MileyHollenberg for initial integration with Cocoapods and telling us about SPM!

Docs PR: godotengine/godot-docs#11805

This PR prevents external plugins from having to rely on hacky workarounds (like post-export scripts) to add Swift Package Manager (SPM) dependencies.

SPM is an excellent addition that will massively simplify the distribution and usage of iOS plugins because:

  • No more post-export hacks: Plugins no longer need complex export scripts to manipulate the generated Xcode project.
  • One-Click Deploy: SPM dependencies are natively resolved, guaranteeing that One-Click Deploy works out of the box.
  • CI/CD Ready: Natively supports automated build pipelines.
  • Lighter, Cleaner Plugins: Plugins become significantly smaller and simpler since heavy frameworks no longer need to be downloaded or embedded in the repository.

This implementation was designed with developer experience in mind. The new .gdip format places the SPM packages directly inside the existing [dependencies] section:

[dependencies]
linked=[]
embedded=[]
system=["AppTrackingTransparency.framework"]
capabilities=[]
files=[]
linker_flags=["-ObjC"]
spm_packages=[
  {
    "url": "https://github.com/googleads/swift-package-manager-google-mobile-ads.git",
    "version": "12.14.0",
    "products": ["GoogleMobileAds"]
  }
]

This approach is highly beneficial because:

  1. Self-Documenting: The JSON-like Array[Dictionary] format exposes url, version, and products explicitly.
  2. Extensible: More keys (like platforms or checksums) can be easily added in the future without breaking the parser.
  3. Familiarity: It respects and closely follows how SPM natively structures its package dependencies.
  4. Deterministic Builds: The export pipeline forces the Xcode requirement kind to be exactVersion. This guarantees reproducible builds and prevents bugs caused by dependencies silently updating to different versions.
  5. 100% Backwards Compatible: Older Godot versions parsing this .gdip file will simply ignore the spm_packages key safely.

Data Flow Diagram:

flowchart TD
    A["📄 .gdip file<br/><b>[dependencies]</b><br/>spm_packages=[...]"] -->|ConfigFile::load| B["load_plugin_config()<br/><i>plugin_config_apple_embedded.cpp</i>"]
    B -->|"Vector&lt;SPMPackage&gt;"| C["_export_apple_embedded_plugins()<br/><i>editor_export_platform_apple_embedded.cpp</i>"]
    C -->|Deduplicate by URL| D["PBX Generation"]
    D --> E["spm_packages<br/><i>packageReferences list</i>"]
    D --> F["spm_package_refs<br/><i>XCRemoteSwiftPackageReference</i>"]
    D --> G["spm_package_products<br/><i>XCSwiftPackageProductDependency</i>"]
    D --> H["modules_buildfile<br/><i>PBXBuildFile</i>"]
    D --> I["modules_buildphase<br/><i>Frameworks build phase</i>"]
    E --> J["_fix_config_file()<br/>Template Substitution"]
    F --> J
    G --> J
    H --> J
    I --> J
    J -->|"$spm_packages<br/>$spm_package_refs<br/>$spm_package_products"| K["📦 project.pbxproj<br/><i>Xcode resolves SPM at build time</i>"]
Loading

Binaries: poing-godot-admob-ios.zip

Follow plugin tutorial if needed (just don't follow the Cocoapods step, this should be automatically now with SPM): https://www.youtube.com/watch?v=TB7WhP8mieo

Or:

@gumaciel
Copy link
Copy Markdown
Contributor Author

gumaciel commented Mar 2, 2026

Screenshot 2026-03-01 at 20 51 40 Screenshot 2026-03-01 at 20 51 23 Screenshot 2026-03-01 at 20 50 53

Copy link
Copy Markdown
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

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

Looks great – just one nit.

Comment thread editor/export/plugin_config_apple_embedded.h Outdated
@stuartcarnie
Copy link
Copy Markdown
Contributor

@gumaciel you will need to rebase on the master branch and squash your commits too

@gumaciel
Copy link
Copy Markdown
Contributor Author

@stuartcarnie I've done the rebase + squash commits, please check again if possible

Just a question: Previously, I've done a merge commit with the master branch. Is this not allowed in PRs?

@bruvzg bruvzg modified the milestones: 4.x, 4.8 Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants