我正在尝试做一个flutter插件,所以我按照https://flutter.dev/docs/development/packages-and-plugins/developing-packages上提供的步骤创建了一个插件。当我尝试运行一个ios示例时,我得到了一个错误。下面是我运行ios示例应用时得到的日志。
有人能帮我吗?
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
8条答案
按热度按时间qrjkbowd1#
当我们在终端上通过命令创建插件时,它会创建一个插件,默认为Android的Java和iOS的Objective-C。它可以通过使用命令更改为Android的Kotlin和iOS的Swift,但它只会增加对根文件夹中
android/
和ios/
的支持。这不会改变example/
目录中的示例代码。所提供的示例仍然是Java for Android和Objective-C for iOS。所以我从Android Studio创建了一个插件,我通过选中“包括Swift对iOS代码的支持”选项创建了Swift对iOS的支持,它创建了一个使用Swift而不是Objective-C的示例。41ik7eoe2#
如果您使用的是Apple Silicon Chip(M1),则可以执行此操作。
7hiiyaii3#
我也面临过这个问题。然后我意识到这是"pod安装"的问题。并在这里找到了解决方案https://github.com/CocoaPods/CocoaPods/issues/10723
并运行:
代替
bvhaajcl4#
每次我把我的项目从一台电脑换到另一台电脑时,我都会遇到这个问题,
我按照这个步骤来解决这个问题,
1.
2.替换此
与
3.run
4zcjmb1e5#
您需要设置Swift版本,因为
flutter_plugin did not specify a Swift version by default
在
ios/Podfile
中添加以下列方式:
您也可以查看this github thread和这个stackoverflow讨论,以获得关于为什么会发生这种情况的更多细节。
v6ylcynt6#
我在项目级别名称SWIFT-VERSION上为Runner添加了一个用户定义的构建设置,其他设置都不起作用。
j91ykkif7#
不用担心。有一个简单的解决方案。创建这个文件-AppResources/iOS/Podfile并将其添加到文件中
至此,您的项目的SWIFT_VERSION已设置完毕。
o2g1uqev8#
我跑:
并解决它