如何解决我在 android studio 中运行我的 flutter 项目并尝试使用 iPhone 12 模拟器,但每次 Xcode 构建都失败
我正在使用 Macbook Pro 2019。我想使用 Firebase/Auth、Firebase/Firestore、Firebase/Analytics 和 Firebase/Core。我认为 podfile 有问题。 播客文件:
# Uncomment this line to define a global platform for your project
platform :ios,'10.0'
# Add the Firebase pod for Google Analytics
#pod 'Firebase/Analytics'
# For Analytics without IDFA collection capability,use this pod instead
# pod ‘Firebase/AnalyticsWithoutAdIdSupport’
# Add the pods for any other Firebase products you want to use in your app
# For example,to use Firebase Authentication and Cloud Firestore
#pod 'Firebase/Auth'
#pod 'Firebase/Firestore'
# 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 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Firestore'
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
颤振医生:
[✓] Flutter (Channel stable,2.2.1,on macOS 11.2.3 20D91 darwin-x64,locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)
• No issues found!
AppDelegate.swift:
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder,UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
}
错误:
在 ProjectZeus 中运行“flutter pub get”... 在调试模式下在 iPhone 12 Pro Max 上启动 lib/main.dart... 正在运行 pod 安装... 运行 Xcode 构建... Xcode 构建完成。 10.8s 无法构建 iOS 应用程序 Xcode 构建的错误输出: ↳ ** 构建失败 **
Xcode 的输出: ↳ 产生了 1 个错误。 注意:使用新的构建系统 注意:并行构建目标 注意:规划构建 注意:分析工作区 注意:构建构建描述 注意:构建准备完成 警告:签名和功能的功能可能无法正常运行,因为其权利使用占位符团队 ID。要解决此问题,请在 Runner 编辑器中选择一个开发团队。 (在项目“Runner”的目标“Runner”中)
无法为模拟器构建应用程序。 在 iPhone 12 Pro Max 上启动应用程序时出错。
提前致谢
解决方法
检查是否已使用 Xcode 正确添加了 google-services
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。