Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter iOS build fail on running pod install

I'm trying to make a flutter plugin, so I created a plugin by steps provided on https://flutter.dev/docs/development/packages-and-plugins/developing-packages. I'm getting an error when I try to run an ios example. Below is the log I'm getting while running the ios example app.

Can anyone help me with this?

Running pod install...
CocoaPods' output:
    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
    -> Fetching podspec for `flutter_plugin` from `.symlinks/plugins/flutter_plugin/ios`

    Resolving dependencies of `Podfile`

    Comparing resolved specification to the sandbox manifest
      A Flutter
      A flutter_plugin

    Downloading dependencies

    -> Installing Flutter (1.0.0)

    -> Installing flutter_plugin (0.0.1)
      - Running pre-install hooks
    [!] Unable to determine Swift version for the following pods:

    - `flutter_plugin` does not specify a Swift version and none of the targets (`Runner`) integrating it has the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:115:in `verify_swift_pods_swift_version'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:37:in `validate!'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:459:in `validate_targets'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:138:in `install!'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command/install.rb:48:in `run'
    /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:22:in `load'
    /usr/local/bin/pod:22:in `<main>'

Error output from CocoaPods:
        [33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
        Consider adding the following to ~/.profile:
Error running pod install
like image 372
Amol Gangadhare Avatar asked Feb 27 '19 18:02

Amol Gangadhare


Video Answer


4 Answers

Got the issue. when we create a plugin by command on the terminal it creates a plugin with default Java for Android and Objective-C for iOS. It can be changed to Kotlin for Android and Swift for iOS by using a command, but it will add support to only android/ and ios/ in the root folder. This does not change the example code in example/ directory. The provided examples are still in Java for Android and Objective-C for iOS. So then I created a plugin from Android Studio, I created a Swift support for iOS by checking an option 'Include Swift support for ios code', it created an example with swift instead of Objective-C. Then the issue is solved.

like image 153
Amol Gangadhare Avatar answered Oct 22 '22 09:10

Amol Gangadhare


You need to set your Swift Version since flutter_plugin did not specify a Swift version by default

In your ios/Podfile add

config.build_settings['SWIFT_VERSION'] = '4.1'  # required by simple_permission

In the following manner:

target 'Runner' do
  use_frameworks!  # required by simple_permission
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.1'  # required by simple_permission
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

You may also check out this github thread and this stackoverflow discussion for further details regarding why this occurred.

like image 45
Esh Avatar answered Oct 22 '22 11:10

Esh


I faced this problem every time when I change my project one pc to another,

I follow this steps to solve that,

1.

Delete podfile.lock

2.replace this

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

with

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
    flutter_additional_ios_build_settings(target)
  end
end

3.run

flutter clean
flutter run
like image 2
JuniorBOMB Avatar answered Oct 22 '22 09:10

JuniorBOMB


I faced this problem too. Then I realized that this is a problem with "pod install". And found a solution here https://github.com/CocoaPods/CocoaPods/issues/10723

sudo arch -x86_64 gem install ffi

And run:

arch -x86_64 pod install

instead of

pod install
like image 2
Kz Zk Avatar answered Oct 22 '22 11:10

Kz Zk