Flutter 環境
- Flutter version 2.10.5
- Dart version 2.16.2
- DevTools version 2.9.2
- CocoaPods version 1.16.2
- Xcode 16.3
問題一:XCResult parsing error: Error: This command is deprecated and will be removed in a future release, --legacy flag is required to use it.
參考鏈接:https://github.com/flutter/flutter/pull/152988
1.打開flutter sdk代碼,找到?packages/flutter_tools/lib/src/ios/xcresult.dart文件,按照下圖修改
2.打開flutter sdk代碼,找到?/packages/flutter_tools/test/general.shard/ios/xcresult_test.dart文件,按照下圖修改
3.刪除flutter sdk中的flutter_tools.snapshort和flutter_tools.stamp文件
- /bin/cache/flutter_tools.snapshot
- /bin/cache/flutter_tools.stamp
4.重新運行flutter doctor后再次運行項目即可
問題二:Invalid Podfile file: undefined method ‘exists?’ for class File
參考鏈接:https://stackoverflow.com/questions/75414034/invalid-podfile-file-undefined-method-exists-for-fileclass
在你的flutter sdk中打開這個文件:
flutter/packages/flutter_tools/bin/podhelper.rb
然后更換
return [] unless File.exists? file_path
到
return [] unless File.exist? file_path
問題三:Error: Cannot run with sound null safety, because the following dependencies don’t support null safety
參考鏈接:https://www.hudiepm.com/swift/xcode-swift—no-sound-null-safety.html
1.點擊targets中的項目
2.再點擊build setting
3.在User-Defined中添加EXTRA_FRONT_END_OPTIONS 值為–no-sound-null-safety
問題四:Error (Xcode): linker command failed with exit code 1 (use -v to see invocation)
參考鏈接:https://juejin.cn/post/7449992870625771556
Target debug_universal_framework failed: ProcessException: Process exited abnormally:
ld: warning: -bitcode_bundle is no longer supported and will be ignored
ld: warning: -bitcode_process_mode is no longer supported and will be ignored
ld: file cannot be open()ed, errno=2 path=marker in 'marker'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
1.找到flutter sdk路徑中的iOS.dart文件,并且注釋’-fembed-bitcode-marker’:
/packages/flutter_tools/lib/src/build_system/targets/ios.dart
2.刪除flutter sdk中的flutter_tools.snapshort和flutter_tools.stamp文件
- 路徑:/bin/cache/flutter_tools.snapshot
- 路徑:/bin/cache/flutter_tools.stamp
3.重新運行flutter doctor后再次運行項目即可
問題五:Error (Xcode): SDK does not contain ‘libarclite’ at the path’/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a’; try increasing the minimum deployment target
1.找到flutter module的隱藏的iOS文件夾中podfile文
2.Podfile文件中添加如下,因為最低部署目標已提升至 iOS 12。
target.build_configurations.each do |config|config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end