Flutter iOS build fail on running pod install
Asked Answered
C

11

10

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
Coppins answered 27/2, 2019 at 18:26 Comment(0)
C
7

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.

Coppins answered 28/2, 2019 at 5:33 Comment(0)
B
16

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
Baiss answered 14/4, 2022 at 10:49 Comment(0)
C
7

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.

Coppins answered 28/2, 2019 at 5:33 Comment(0)
S
7

I faced this problem too. Then I realised that this is a problem with "pod install" and I 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
Shaver answered 16/12, 2021 at 9:17 Comment(0)
I
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
Idiom answered 22/2, 2022 at 9:1 Comment(1)
Thanks, it's work for me. If u me this bug when push and pull code from git, try this solution. fast and efficientMonjo
B
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.

Buehler answered 27/2, 2019 at 19:41 Comment(0)
B
1

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

Bobbitt answered 17/11, 2020 at 17:13 Comment(0)
T
1

It might be causing the issue because you mentioned an iOS version less than 13.0 in your project Podfile.

platform :ios, '13.0'

Changing iOS version solved my problem.

Tire answered 5/1 at 3:8 Comment(0)
D
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.

Dariadarian answered 19/9, 2020 at 5:36 Comment(0)
G
0

I run:

  pod repo update

and solve it

Gunzburg answered 6/2, 2023 at 20:45 Comment(0)
M
0

This usually occurs for Apple Silicon. To solve future issues.

  1. Go to vim ~/.zshrc

  2. Add alias to root of your zsh, e.g cleanpods alias pods='rm -rf ios/Pods && rm -rf ios/.symlinks && rm -rf ios/Flutter/Flutter.podspec && rm -rf ios/Podfile.lock && flutter clean && flutter pub get && cd ios && sudo arch -x86_64 gem install ffi && arch -x86_64 pod install && arch -x86_64 pod repo update && cd ..' then exit and save vim by press ESC then :wq!

  3. Just run cleanpods for this and any future occurrences

Mcintyre answered 6/11, 2023 at 5:6 Comment(0)
B
0

Just delete podfile.lock, and in podfile change Runner -> YourName Attribuited

Barnabas answered 26/1 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.