flutter工程 如何更改swift版本
时间: 2023-09-07 13:12:39 浏览: 269
更改 Flutter 工程中使用的 Swift 版本,需要在 Xcode 中进行以下步骤:
1. 打开 Flutter 工程中的 ios 目录,找到 `Podfile` 文件。
2. 打开 `Podfile` 文件,找到 `platform :ios` 行,更改 `ios` 版本号,如:
```ruby
platform :ios, '11.0'
```
3. 找到 `use_framework!` 行,下面添加以下代码:
```ruby
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
end
```
其中,`SWIFT_VERSION` 可以更改为你想要使用的 Swift 版本号。
4. 保存 `Podfile` 文件,然后在终端中进入 ios 目录,运行 `pod install` 命令,更新依赖库。
```bash
cd ios
pod install
```
5. 最后,在 Xcode 中打开 `Runner.xcworkspace` 工程文件,选择 `Runner` 项目,在 `Build Settings` 中找到 `Swift Language Version` 选项,将其设置为你想要使用的 Swift 版本号即可。
注意:如果修改了 `Podfile` 文件,需要使用 `pod install` 命令更新依赖库后,才会生效。
阅读全文
相关推荐


















