Chr*_*rry 5 macos xcode deployment-target flutter just-audio
我正在尝试构建一个针对 macOS 的 Flutter 应用程序。添加一些依赖项(例如 just_audio)后,我会收到有关MACOSX_DEPLOYMENT_TARGET在各个位置设置为各种值(需要更改为其他值)的警告。
因此,我打开 Xcode 并按照说明仔细设置值。之后,应用程序成功编译,没有警告,并按预期执行一次、两次,甚至三次,但不可避免地会返回警告。当我返回 Xcode 时,我发现所有值都恢复到之前的状态。我尝试了不同的目标版本,从 10.15 到 13.1(当前安装),但警告最终总是会出现。
\n我是否错过了重要的一步?我对软件开发并不陌生,但对 macOS 和 Xcode 完全陌生。
\n以下是不断出现的错误的示例:
\nLaunching lib/main.dart on macOS in debug mode...\n--- xcodebuild: WARNING: Using the first of multiple matching destinations:\n{ platform:macOS, arch:arm64, id:00006000-000210D03EB8401E }\n{ platform:macOS, arch:x86_64, id:00006000-000210D03EB8401E }\n/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'FMDB' from project 'Pods')\n/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'sqflite' from project 'Pods')\n/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'audio_session' from project 'Pods')\n/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.12.2, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'audio_service' from project 'Pods')\n/Users/foo/projects/just_audio_background_test/macos/Runner.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'Flutter Assemble' from project 'Runner')\n/Users/foo/projects/just_audio_background_test/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.11, but the range of supported deployment target versions is 10.13 to 13.1.99. (in target 'FlutterMacOS' from project 'Pods')\nRun Code Online (Sandbox Code Playgroud)\n这是我的flutter doctor输出:
[\xe2\x9c\x93] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-TW)\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 33.0.0)\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 14.2)\n[\xe2\x9c\x93] Chrome - develop for the web\n[\xe2\x9c\x93] Android Studio (version 2021.3)\n[\xe2\x9c\x93] VS Code (version 1.74.1)\n[\xe2\x9c\x93] Connected device (2 available)\n[\xe2\x9c\x93] HTTP Host Availability\nRun Code Online (Sandbox Code Playgroud)\n
原因是pod install当您尝试运行或构建时,flutter 就会执行。因此,请像下面这样编辑您的post_install内容Podfile。添加的代码将在 flutter 执行时强制部署目标为 10.13 pod install。
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
end
end
end
Run Code Online (Sandbox Code Playgroud)
完整示例如下
platform :osx, '10.13'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
end
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
948 次 |
| 最近记录: |