Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Friction adding swift plugin to objective-c project #16049

@xster

Description

@xster

flutter create a non-swift project

In pubspec.yaml, add a swift plugin such as flutter_iap.

  1. flutter run warns about use_frameworks! from pod install. Easy to resolve so far.
  2. Building gives The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor. error.
    Seems like swift pod developers need to specify
    s.pod_target_xcconfig = { 'SWIFT_VERSION' => <a version above 2.3 for it to work with Xcode 9> }
    in their podspec. Added temporary hack in Podfile with
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.2'
    end
  end
end

and re-pod install
3.

#import "Headers/flutter_iap-umbrella.h"
            ^
   .../ios/Pods/Target Support Files/flutter_iap/flutter_iap-umbrella.h:13:9: error: include of non-modular header inside framework module 'flutter_iap': '.../.pub-cache/hosted/pub.dartlang.org/flutter_iap-1.0.1/ios/Classes/FlutterIapPlugin.h'

Add

pre_install do |installer|
  # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end

and

post_install do |installer|
  installer.pods_project.targets.each do |target|
    # workaround for https://github.com/CocoaPods/CocoaPods/issues/7463
    target.headers_build_phase.files.each do |file|
      file.settings = { 'ATTRIBUTES' => ['Public'] }
    end
  end
end

to make it work.

Wonder if we can add some automatic handling of swift plugins in the default objective-c project's Podfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: first hourThe first hour of using Fluttera: pluginsSupport for writing, building, and running plugin packagesplatform-iosiOS applications specificallyt: xcode"xcodebuild" on iOS and general Xcode project managementteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions