最近在做flutter项目,执行flutter run 的时候,会在iOS项目中执行pod install 这个命令,但是在执行过程中会报一些错误此文记录一下。
1、我这个是ruby环境问题,按照GitHub上操作没有解决,1、https://github.com/CocoaPods/CocoaPods/issues/7697
;2、https://github.com/CocoaPods/CocoaPods/issues/6992
;3、https://github.com/CocoaPods/CocoaPods/issues/8003
目前我已经解决了,我是Mac电脑,系统自带ruby环境,但是我又安装了jruby ,可能是jruby 配置的有问题,我把jruby 删了,又重新升级了一下ruby,重新安装了cocoapods,就可以了。在网上找了同样的一个错误,在此记录一下,错误提示如下文:
Report
What did you do?
pod install
What did you expect to happen?
Install all pod dependencies correctly.
What happened instead?
Stack
CocoaPods : 1.5.3
Ruby : jruby 9.2.0.0 (2.5.0) 2018-11-01 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.151-b12 on 1.8.0_151-b12 +jit [darwin-x86_64]
RubyGems : 2.7.7
Host : Mac OS X 10.14 (18A391)
Xcode : 10.1 (10B61)
Git : git version 2.17.2 (Apple Git-113)
Ruby lib dir : /Users/hexu/.rvm/rubies/jruby-9.2.0.0/lib
Repositories :
Plugins
cocoapods-deintegrate : 1.0.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.1
cocoapods-try : 1.1.0
Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end
target 'Runner' do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
Error
NameError - uninitialized constant Nanaimo::Reader::StringScanner
Did you mean? Nanaimo::Reader::StringScanner
StringScanner
org/jruby/RubyModule.java:3526:in `const_missing'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/nanaimo-0.2.6/lib/nanaimo/reader.rb:97:in `initialize'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/xcodeproj-1.7.0/lib/xcodeproj/plist.rb:27:in `read_from_path'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/xcodeproj-1.7.0/lib/xcodeproj/project.rb:206:in `initialize_from_file'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/xcodeproj-1.7.0/lib/xcodeproj/project.rb:108:in `open'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:918:in `block in inspect_targets_to_integrate'
org/jruby/RubyHash.java:1396:in `each'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:917:in `block in inspect_targets_to_integrate'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:912:in `inspect_targets_to_integrate'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:78:in `analyze'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:243:in `analyze'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:153:in `resolve_dependencies'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:116:in `install!'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/gems/cocoapods-1.5.3/bin/pod:55:in `<main>'
org/jruby/RubyKernel.java:994:in `load'
/usr/local/bin/pod:1:in `<eval>'
org/jruby/RubyKernel.java:1037:in `eval'
/Users/hexu/.rvm/gems/jruby-9.2.0.0/bin/jruby_executable_hooks:24:in `<main>'
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=uninitialized+constant+Nanaimo%3A%3AReader%3A%3AStringScanner%0ADid+you+mean%3F++Nanaimo%3A%3AReader%3A%3AStringScanner%0A+++++++++++++++StringScanner&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
- pod init error: NameError
2、在添加新的第三方依赖后,重新运行项目,报错:
Analyzing dependencies
[!] CDN: trunk Repo update failed - 13 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/f/3/WechatOpenSDK/1.7.7/WechatOpenSDK.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/f/3/WechatOpenSDK/1.7.8/WechatOpenSDK.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/f/3/WechatOpenSDK/1.7.9/WechatOpenSDK.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/f/3/WechatOpenSDK/1.8.0/WechatOpenSDK.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/f/3/WechatOpenSDK/1.8.1/WechatOpenSDK.podspec.json Response: Couldn't connect to server。。。。。。
解决方法:在Podfile 添加source,然后执行 pod repo remove trunk,然后pod install,就可以了