9

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
Amol Gangadhare
  • 1,059
  • 2
  • 11
  • 24

8 Answers8

7

If you are using Apple Silicon Chip (M1), you can do this.

cd ios
pod cache clean --all
Pod clean
pod deintegrate
sudo gem install cocoapods-deintegrate cocoapods-clean

sudo arch -x86_64 gem install ffi
arch -x86_64 pod repo update
arch -x86_64 pod install
Alper
  • 266
  • 5
  • 5
6

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.

Amol Gangadhare
  • 1,059
  • 2
  • 11
  • 24
4

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
Dharman
  • 30,962
  • 25
  • 85
  • 135
Kirill_Z
  • 158
  • 5
4

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
JuniorBOMB
  • 336
  • 1
  • 3
  • 11
1

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.

Esh
  • 505
  • 5
  • 17
1

I added a user-defined build setting for the Runner on the project level name SWIFT-VERSION. Nothing else worked for me.

rgish
  • 39
  • 6
0

Do not worry. There is a simple solution to it. Create this file — AppResources/iOS/Podfile and add this into the file

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.0'
     end
   end
end

That’s it your project’s SWIFT_VERSION has been set.

0

I run:

  pod repo update

and solve it

Erhan Demirci
  • 4,173
  • 4
  • 36
  • 44