我正在尝试使geolocator 2.1.0插件与我的ios xcode项目一起使用,并在运行pod install之后得到以下2个错误提示
类型'UIApplication'没有成员'openSettingsURLString' 和 'OpenExternalURLOptionsKey'不是'UIApplication'的成员类型
已采取的步骤。
我打开一个新的Flutter项目(无论是否选中“ Swift支持”,都会发生错误)-获取默认应用。
仅使用-geolocator:^ 2.1.0
希望我缺少一些简单的东西。感谢您的高级帮助。
Podfile看起来像这样
(我已经用'config.build_settings ['SWIFT_VERSION'] ='4.1''更新了文件。
# 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
# 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'
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
答案 0 :(得分:4)
在use_frameworks!
的目标运行器中添加(YOUR_PROJECT)/ios/Podfile
。
target 'Runner' do
use_frameworks! # required by Geolocator
# 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')
地理定位器的旧版本,例如^1.6.3
,要求将SWIFT_VERSION
设置为4.0
或4.1
。
但是geolocator
版本2.1.0
使用permission_handler
版本2.1.1
,它需要SWIFT_VERSION
4.2
。
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2' # required by Geolocator
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
我能够使用Flutter geolocator
和Xcode 2.1.0
在我的应用中成功构建并使用0.11.9
版本10.1
。