2023-05-23 [!] Invalid `Podfile`
2023-05-22 本文已影响0人
我是小胡胡分胡
环境:
cocoapods 1.12.1
xcode 14.3
flutter 3.0.5
错误1:
[!] Invalid Podfile
file: undefined method `exists?' for File:Class.
https://www.mobibrw.com/date/2023/03
这个问题是由于 cocoapods 升级到 1.12 版本之后,依赖的 ruby 升级到 3.2 版本,其中的 File.exists 函数被替换成 File.exist,导致编译异常。
刚刚开始以为是 Flutter 的原因,结果发现 Flutter 3.7.7版本已经修复这个问题。
# from ruby 3.2 File.exists is broken, we need compat function
def mmkv_file_exists(file)
is_exist = false
if File.methods.include?(:exists?)
is_exist = File.exists? file
else
is_exist = File.exist? file
end
return is_exist
end
使用上面的代码替换 File.exists 即可。
或者直接改成File.exist?
/Volumes/huc/myshared/opt/fvm/versions/3.0.5/packages/flutter_tools/bin/podhelper.rb
return [] unless File.exists? file_path
改成:
return [] unless File.exist? file_path
错误2:
[!] CocoaPods could not find compatible versions for pod "shared_preferences_foundation":
In Podfile:
FlutterPluginRegistrant (from `Flutter/FlutterPluginRegistrant`) was resolved to 0.0.1, which depends on
shared_preferences_foundation
shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
Specs satisfying the `shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`), shared_preferences_foundation` dependency were found, but they required a higher
minimum deployment target.
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:317:in `raise_error_unless_state'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict'
<internal:kernel>:90:in `tap'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `unwind_for_conflict'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:682:in `attempt_to_activate'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb:94:in `resolve'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1082:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1080:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:125:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:422:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:162:in `install!'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `<main>'
错误3
Unable to build plugin frameworks: 2023-05-23 16:02:14.945 xcodebuild[17625:2200280] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
** BUILD FAILED **