Reputation: 1105
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
Upvotes: 10
Views: 49578
Reputation: 306
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
Upvotes: 9
Reputation: 1
Just delete podfile.lock, and in podfile change Runner -> YourName Attribuited
Upvotes: 0
Reputation: 93
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.
Upvotes: 1
Reputation: 483
This usually occurs for Apple Silicon. To solve future issues.
Go to vim ~/.zshrc
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!
Just run cleanpods
for this and any future occurrences
Upvotes: 0
Reputation: 414
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
Upvotes: 17
Reputation: 399
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
Upvotes: 4
Reputation: 39
I added a user-defined build setting for the Runner on the project level name SWIFT-VERSION. Nothing else worked for me.
Upvotes: 1
Reputation: 1105
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.
Upvotes: 8
Reputation: 9
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.
Upvotes: 0
Reputation: 535
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.
Upvotes: 1