2

I have a flutter plugin (let's say it's named plugin) that needs to have a separate debug build (say debug/foo.framework) and a release build (release/foo.framework) and they should be used in the respective app builds. Is there a way to do this?

Pod::Spec.new do |s|
  ...
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework foo' }
  s.vendored_frameworks = 'foo.framework'
end

What I'd want, conceptually, is something like this (should work for dependency, but doesn't for vendored_framework - says file: undefined method 'vendored_frameworks')

Pod::Spec.new do |s|
  ...
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework foo' }
  s.vendored_frameworks 'debug/foo.framework', :configurations => ['Debug']
  s.vendored_frameworks 'release/foo.framework', :configurations => ['Release']

I've also tried this, but it fails with circular dependency:

Pod::Spec.new do |s|
  s.name     = 'plugin'
  ...
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework foo' }

  s.subspec 'debug' do |cs|
    cs.vendored_frameworks = 'debug/foo.framework'
  end
  s.subspec 'release' do |cs|
    cs.vendored_frameworks = 'release/foo.framework'
  end

  s.default_subspecs = :none
  s.dependency 'plugin/debug', :configurations => ['Debug']
  s.dependency 'plugin/release', :configurations => ['Release']
end
vaind
  • 1,642
  • 10
  • 19

1 Answers1

0

I had the same issue (when dealing with React-Native) and ended up dividing the plugin in to 3 Pods.

my-plugin:

Pod::Spec.new do |s|
  s.name         = "my-plugin"
  s.dependency "my-lib-debug", :configurations => ['Debug']
  s.dependency "my-lib-release", :configurations => ['Release']
end

my-lib-debug:

Pod::Spec.new do |s|
  s.name         = "my-lib-debug"
  s.ios.vendored_framework = 'ios/dependencies/debug/my-lib.xcframework'
end

my-lib-release:

Pod::Spec.new do |s|
  s.name         = "my-lib-release"
  s.ios.vendored_framework = 'ios/dependencies/release/my-lib.xcframework'
end

Application Podfile:

  pod 'my-plugin', :path => 'path/to/my-plugin'
  pod 'my-lib-debug', :path => 'path/to/my-lib-debug', :configurations => ['Debug']
  pod 'my-lib-release', :path => 'path/to/my-lib-release', :configurations => ['Release']