我正在尝试启动一个在 iOS 模拟器上启动的 Flutter 项目,但问题是我不能。在另一台Mac上,我的朋友能够启动它,但我一直在原地踏步……我尝试过: **
# Uncomment this line to define a global platform for your project
platform :ios, '15.0'
# 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', '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 Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
# pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.3.0'
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.aggregate_targets.each do |target|
target.xcconfigs.each do |variant, xcconfig|
xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
end
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
xcconfig_path = config.base_configuration_reference.real_path
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.calendar
# 'PERMISSION_EVENTS=1',
## dart: PermissionGroup.reminders
# 'PERMISSION_REMINDERS=1',
## dart: PermissionGroup.contacts
# 'PERMISSION_CONTACTS=1',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=1',
## dart: PermissionGroup.speech
# 'PERMISSION_SPEECH_RECOGNIZER=1',
## dart: PermissionGroup.photos
#'PERMISSION_PHOTOS=1',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
# 'PERMISSION_LOCATION=1',
## dart: PermissionGroup.notification
# 'PERMISSION_NOTIFICATIONS=1',
## dart: PermissionGroup.mediaLibrary
# 'PERMISSION_MEDIA_LIBRARY=1',
## dart: PermissionGroup.sensors
# 'PERMISSION_SENSORS=1',
## dart: PermissionGroup.bluetooth
# 'PERMISSION_BLUETOOTH=1',
## dart: PermissionGroup.appTrackingTransparency
# 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
## dart: PermissionGroup.criticalAlerts
# 'PERMISSION_CRITICAL_ALERTS=1'
]
end
end
target.build_configurations.each do |config|
config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
#config.build_settings['OTHER_SWIFT_FLAGS'] << '-D BYPASS_PERMISSION_NOTIFICATIONS'
#config.build_settings['OTHER_SWIFT_FLAGS'] << '-D BYPASS_PERMISSION_IOSADDTOPHOTOLIBRARY'
#config.build_settings['OTHER_SWIFT_FLAGS'] << '-D BYPASS_PERMISSION_IOSCHANGEPHOTOLIBRARY'
end
end
end
我已经按照不同的顺序尝试过,但仍然没有用。错误(我没有把它们全部列出来,因为它们很大)是:
Failed to build iOS app
Error output from Xcode build:
↳
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:559C4BFF-EDD7-47C0-BBF0-23EFA0F09B49, OS:17.5, name:iPhone 15 Pro Max }
{ platform:iOS Simulator, id:559C4BFF-EDD7-47C0-BBF0-23EFA0F09B49, OS:17.5, name:iPhone 15 Pro Max }
** BUILD FAILED **
Xcode's output:
↳
Writing result bundle at path:
/var/folders/zy/s6zpmk8x1sz8rh2r5f6cf0040000gn/T/flutter_tools.LUGgCm/flutter_ios_build_temp_dirp82spW/temporary_xcresult_bundle
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
/Users/user/Downloads/app-flavors/ios/Runner/AppDelegate.swift:34:29: warning: 'alert' was deprecated in iOS 14.0
completionHandler([.alert, .sound])
^
/Users/user/Library/Developer/Xcode/DerivedData/Runner-gbukoovcjoxwzreoddwxmohrumea/Build/Intermediates.noindex/Runner.build/Debug-dev-iphonesimulator/Runner.build/Script-486182A2307E10650A730B9F.sh: line 5: flutterfire: command not found
Command PhaseScriptExecution failed with a nonzero exit code
/Users/user/Downloads/app-flavors/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'wakelock_plus-thermal' from project 'Pods')
/Users/user/Downloads/app-flavors/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'permission_handler_apple-permission_handler_apple_privacy' from project 'Pods')
/Users/user/Downloads/app-flavors/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'nanopb-nanopb_Privacy' from project 'Pods')
/Users/user/Downloads/app-flavors/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'libwebp' from project 'Pods')
/Users/user/Downloads/app-flavors/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'leveldb-library-leveldb_Privacy' from project 'Pods')
/Users/user/Downloads/app-flavors/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'flutter_local_notifications-flutter_local_notifications_privacy' from project 'Pods')
etc...
我不确定问题是什么...问题可能是 cocoapods 还是 PATH ~/.zshrc 文件?
export PATH="/opt/homebrew/bin:$PATH"
export PATH="$PATH:/user/local/opt/flutter/bin"
export PATH="$PATH:$HOME/.pub-cache/bin"
export PATH="/opt/homebrew/Caskroom/flutter/3.22.2/flutter/bin:$PATH"
在 My flutter doctor -v 中没有问题。非常需要并感谢任何形式的帮助。