gpt4 book ai didi

xcode - Flutter:类型 'UIApplication' 没有成员 'openSettingsURLString'

转载 作者:IT王子 更新时间:2023-10-29 06:47:39 24 4
gpt4 key购买 nike

我正在尝试让 geolocator 2.1.0 插件与我的 ios xcode 项目一起工作,并在我运行 pod install 后出现以下 2 个错误

类型“UIApplication”没有成员“openSettingsURLString”和“OpenExternalURLOptionsKey”不是“UIApplication”的成员类型

采取的步骤。

  1. 我打开一个新的 Flutter 项目(无论是否选中“Swift Support”都会出错)-获取默认应用。

  2. 仅更新我的 pubspec.yaml 文件 - geolocator : ^2.1.0

  3. 运行“flutter pacakges get”和“pod install”。所有库都显示在 AndroidStudio 和 XCode 9.2 中。

希望我遗漏了一些简单的东西。感谢高级帮助。

Pod 文件看起来像这样

(我已经用“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

最佳答案

(YOUR_PROJECT)/ios/Podfile 的目标 Runner 中添加 use_frameworks!

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.04.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

我能够在我的应用程序中成功构建和使用 geolocator 版本 2.1.0,使用 flutter 0.11.9 和 Xcode 10.1.

关于xcode - Flutter:类型 'UIApplication' 没有成员 'openSettingsURLString',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53450817/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com