Skip to content

SwiftPM when two plugins depend on each other #166528

Description

@NikBenson

Hi everyone,

I am currently working on a large project using many technologies and am responsible for the Flutter implementation. Based on native needs we want to get rid of CocoaPods in the long run. Therefore I am currently migrating a federated architecture plugin to SwiftPM. As the support is in active development, we will support both for a while, but I cannot quite figure out, how I can depend on the iOS code of a dependant plugin in another plugins iOS code.

I have the following dependency tree with pub:

x_sdk_flutter_example a.b.c
├── x_sdk_flutter a.b.c
│   ├── x_sdk_flutter_android...
│   ├── x_sdk_flutter_ios...
│   ├── x_sdk_flutter_platform_interface...
│   └── y...
├── x_sdk_flutter_android a.b.c
│   └── x_sdk_flutter_platform_interface...
├── x_sdk_flutter_ios a.b.c
│   └── x_sdk_flutter_platform_interface...
├── x_sdk_flutter_model a.b.c
├── x_sdk_flutter_pigeon a.b.c
├── x_sdk_flutter_platform_interface a.b.c
│   ├── x_sdk_flutter_model...
│   └── x_sdk_flutter_pigeon...
└── y a.b.c

My specific problem arises with x_sdk_flutter_ios transitive dependency on x_sdk_flutter_pigeon. I need to use the native pigeon in my platform implementation.

In CocoaPods I specified it like this:

Pod::Spec.new do |s|
  s.name             = 'x_sdk_flutter_ios'
  s.version          = 'a.b.c'
  s.summary          = 'Federated Architecture iOS Flutter Plugin for x'
  s.description      = <<-DESC
Federated Architecture iOS Flutter Plugin for x
                       DESC
  s.homepage         = '-'
  s.author           = { '-' => '-' }
  s.source           = { :path => '.' }
  s.source_files = 'x_sdk_flutter_ios/Sources/x_sdk_flutter_ios/**/*.swift'
  s.dependency 'Flutter'
  s.platform = :ios, '15.0'

  s.dependency 'x_sdk_flutter_pigeon'
  s.static_framework = true

  s.dependency 'native-x', 'a.b.c'
  s.static_framework = true

  # Flutter.framework does not contain a i386 slice.
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
  s.swift_version = '5.0'
end

My Pigeons are generated like this:

@ConfigurePigeon(
  PigeonOptions(
    copyrightHeader: 'pigeons/copyright.txt',
    dartOut: 'lib/src/pigeons.g.dart',
    dartPackageName: 'x_sdk_flutter_pigeon',
    kotlinOut:
        'android/src/main/kotlin/[...]/x_sdk_flutter_pigeon/pigeons.g.kt',
    kotlinOptions: KotlinOptions(
      package: '[...].x_sdk_flutter_pigeon',
    ),
    swiftOut:
        'ios/x_sdk_flutter_pigeon/Sources/pigeons.g.swift',
  ),
)

It is a monorepo, but the packages are published using a private pub server and therefore are split at release.

How would I specify this dependency in x_sdk_flutter_ios?

Is and/or will this be supported when using SwiftPM? I haven't worked with SwiftPm prior to this, so it could be my problem. But I would assume a case like this should be covered here.

Metadata

Metadata

Assignees

Labels

Bot is counting down the days until it unassigns the issueP2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions