Flutter shared_preferences 模块未找到 - iOS Xcode build
Flutter shared_preferences module not found - iOS Xcode build
我在 Flutter 中使用 shared_preferences
依赖项。
构建 Xcode(产品-> 存档 - 对于通用目标)失败并显示
module 'shared_preferences' not found
我尝试了 flutter clean
、flutter pub cache repair
、尝试将 Flutter lib/ 移动到新项目 (flutter create .
) 并且我使用旧的 Xcode 版本 (11.4.1) 进行构建..目前我有 12.0 beta 3.
奇怪的是,我的 IDE (IntelliJ) 模拟器中的 运行 工作正常,没有错误。
这些是我的依赖项 (pubspec.yaml)
dependencies:
flutter:
sdk: flutter
http: ^0.12.2
intl: any
flutter_spinkit: ^4.1.2
redux: any
flutter_redux: any
redux_thunk: any
shared_preferences: 0.5.1+2
在我的案例中,问题是我从 Project.xcodeproj 而不是 Project.xcworkspace 打开 Xcode 项目。
如果您将项目方案模式用作调试,则将您的方案更改为从调试发布。
产品 -> 方案 -> 调试发布。
并再次尝试存档项目。
我不得不按以下方式更改方案:
Product -> Scheme -> Edit Scheme
在 Stack Overflow 上搜索我发现了这个
哪个链接到这个
https://github.com/flutter/flutter/issues/54599#issuecomment-644336055
这帮我解决了!
你可以试试这个命令
pod 分解 && pod 设置 && pod 安装
我在 flutter 升级 xcode 和 flutter 2.12 时也遇到了这个问题。
解决这个问题:
- 在ios文件夹中,删除所有文件夹和文件,保留ios文件夹在你的flutter项目中。
- 在 flutter 项目中执行 > flutter create .
- 用 xcode
打开 ios/Runner.xworkspace
- 在 xcode 内,右上角会有一个黄色警告图标,单击它并修复建议的问题。
- 用 xcode
构建
我删除了ios文件夹,然后我运行在项目路径:
flutter create .
flutter build ios
我在 Flutter 中使用 shared_preferences
依赖项。
构建 Xcode(产品-> 存档 - 对于通用目标)失败并显示
module 'shared_preferences' not found
我尝试了 flutter clean
、flutter pub cache repair
、尝试将 Flutter lib/ 移动到新项目 (flutter create .
) 并且我使用旧的 Xcode 版本 (11.4.1) 进行构建..目前我有 12.0 beta 3.
奇怪的是,我的 IDE (IntelliJ) 模拟器中的 运行 工作正常,没有错误。
这些是我的依赖项 (pubspec.yaml)
dependencies:
flutter:
sdk: flutter
http: ^0.12.2
intl: any
flutter_spinkit: ^4.1.2
redux: any
flutter_redux: any
redux_thunk: any
shared_preferences: 0.5.1+2
在我的案例中,问题是我从 Project.xcodeproj 而不是 Project.xcworkspace 打开 Xcode 项目。
如果您将项目方案模式用作调试,则将您的方案更改为从调试发布。
产品 -> 方案 -> 调试发布。
并再次尝试存档项目。
我不得不按以下方式更改方案:
Product -> Scheme -> Edit Scheme
在 Stack Overflow 上搜索我发现了这个
这帮我解决了!
你可以试试这个命令
pod 分解 && pod 设置 && pod 安装
我在 flutter 升级 xcode 和 flutter 2.12 时也遇到了这个问题。
解决这个问题:
- 在ios文件夹中,删除所有文件夹和文件,保留ios文件夹在你的flutter项目中。
- 在 flutter 项目中执行 > flutter create .
- 用 xcode 打开 ios/Runner.xworkspace
- 在 xcode 内,右上角会有一个黄色警告图标,单击它并修复建议的问题。
- 用 xcode 构建
我删除了ios文件夹,然后我运行在项目路径:
flutter create .
flutter build ios