Skip to content

feat: Swift Package Manager support for iOS and macOS - #1142

Draft
hiroshihorie wants to merge 3 commits into
mainfrom
hiroshi/swift-package-manager
Draft

feat: Swift Package Manager support for iOS and macOS#1142
hiroshihorie wants to merge 3 commits into
mainfrom
hiroshi/swift-package-manager

Conversation

@hiroshihorie

Copy link
Copy Markdown
Member

What

Adds Swift Package Manager support for the iOS and macOS plugins, following the Flutter SPM plugin convention:

  • ios/livekit_client/Package.swift and macos/livekit_client/Package.swift, with Sources/livekit_client/ symlink trees into shared_swift/ (and the iOS broadcast files in ios/Classes/), so the existing sources stay the single source of truth.
  • The packages depend on flutter_webrtc's Swift package (../flutter_webrtc, resolved by the Flutter tool) and consume its flutter-webrtc and WebRTC products. Reusing flutter_webrtc's WebRTC binary target keeps a single copy of the xcframework in the package graph, mirroring how the podspecs share the WebRTC-SDK pod today.
  • The example app's Xcode projects get the SPM integration committed (package reference, product dependency, prepare pre-action in the Runner scheme), matching what flutter would generate.

CocoaPods is unchanged: podspecs and Classes/ are untouched, and apps with SPM disabled keep building through pods.

Depends on

Testing

With Flutter 3.44.1 (SPM on by default) and a local dependency_overrides pointing flutter_webrtc at the PR 2062 branch:

  • flutter build macos --debug and flutter build ios --debug --simulator of the example both succeed.
  • Both plugins compile as Swift packages (verified LiveKitPlugin / FlutterWebRTCPlugin symbols in the app binaries) with exactly one embedded WebRTC.framework.
  • permission_handler_apple has no SPM support and keeps building through CocoaPods in hybrid mode.

Note for local testing: the Flutter tool copies plugins that declare SwiftPM dependencies on other plugins into the app's build directory with rsync. With the example app living inside this repo that copy recurses into itself (flutter_tools bug, to be filed upstream). Workaround is to make example/build a symlink to a directory outside the repo before building.

Adds ios/livekit_client and macos/livekit_client Swift packages using
the Flutter SPM plugin layout. Sources are symlinks into shared_swift
and ios/Classes so they stay the single source of truth. CocoaPods
integration is unchanged and both podspecs keep working as before.

The packages depend on flutter_webrtc's Swift package for the WebRTC
framework, mirroring the podspec dependency. Requires a flutter_webrtc
release that includes its own SPM support (PR 2062).
…S projects

Mirrors the changes flutter's automatic SPM migration makes (package
reference, product dependency, and the prepare pre-action in the Runner
scheme). Committing them avoids the migration step at build time, which
currently fails to validate projects whose plugins declare SwiftPM
dependencies on other plugins. CocoaPods phases are untouched so the
example still builds with SPM disabled.
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.

1 participant