[英]Can't run flutter app with firebase on IOS
I get this error when I try running.尝试运行时出现此错误。
Launching lib/main.dart on iPhone XR in debug mode...
Starting Xcode build...
Xcode build done. 35.9s
*** First throw call stack:
(
0 CoreFoundation 0x00000001099ff1bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000108f9d735 objc_exception_throw + 48
2 CoreFoundation 0x00000001099ff015 +[NSException raise:format:] + 197
3 Runner 0x00000001040a8aa0 +[FIRApp configure] + 576
4 Runner 0x00000001044a931c -[FLTCloudFirestorePlugin init] + 188
5 Runner 0x00000001044a91c9 +[FLTCloudFirestorePlugin registerWithRegistrar:] + 297
6 Runner 0x000000010404d19e +[GeneratedPluginRegistrant registerWithRegistry:] + 126
7 Runner <…>
[✓] Flutter (Channel dev, v1.1.5, on Mac OS X 10.14.2 18C54, locale en-NG) [✓] Flutter (Channel dev, v1.1.5, on Mac OS X 10.14.2 18C54, locale en-NG)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1) [✓] iOS 工具链 - 为 iOS 设备开发 (Xcode 10.1)
[✓] Android Studio (version 3.2) [✓] Android Studio(3.2 版)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.6) [✓] IntelliJ IDEA 终极版(2018.1.6 版)
[✓] Connected device (1 available) [✓] 已连接设备(1 个可用)
• No issues found! • 未发现问题!
I guess you forgot to add GoogleService-Info.plist
file to your ios project我猜你忘了将GoogleService-Info.plist
文件添加到你的 ios 项目中
Follow this codelab (point 6 and 7 specifically) for detailed instruction.按照此代码实验室(特别是第 6 点和第 7 点)获取详细说明。
Remember that it's not enough to copy it in your ios/Runner
folder from the finder/explorer
or command line
.请记住,仅从finder/explorer
或command line
其复制到ios/Runner
文件夹中是不够的。
You need to open the ios/Runner.xcworkspace
with Xcode
and add the file to the project tree .您需要使用Xcode
打开ios/Runner.xcworkspace
并将文件添加到项目树中。 Xcode needs to be aware of this file, so that it can be copied in the application bundle . Xcode 需要知道这个文件,以便它可以被复制到应用程序包中。
For cases with two google-services plist files you can add a new build phase to copy the file to the correct location on compilation.对于有两个google-services plist 文件的情况,您可以添加一个新的构建阶段以将文件复制到编译时的正确位置。
environment="default"
# Regex to extract the scheme name from the Build Configuration
# We have named our Build Configurations as Debug-dev, Debug-prod etc.
# Here, dev and prod are the scheme names. This kind of naming is required by Flutter for flavors to work.
# We are using the $CONFIGURATION variable available in the XCode build environment to extract
# the environment (or flavor)
# For eg.
# If CONFIGURATION="Debug-prod", then environment will get set to "prod".
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi
echo $environment
# Name and path of the resource we're copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}
# Make sure GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}"
if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi
# Get a reference to the destination location for the GoogleService-Info.plist
# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"
# Copy over the prod GoogleService-Info.plist for Release builds
cp "${GOOGLESERVICE_INFO_FILE}" "${PLIST_DESTINATION}"
Try running the app and it should be good尝试运行应用程序,它应该很好
If you're developing your Flutter app for both iOS and Android, you need to register both the iOS and Android versions separately within the same Firebase project.如果您正在为 iOS 和 Android 开发 Flutter 应用程序,则需要在同一个 Firebase 项目中分别注册 iOS 和 Android 版本。
Configure iOS配置 iOS
The important value to provide is the iOS bundle ID, which you'll obtain using the following three steps.要提供的重要值是 iOS 捆绑包 ID,您将通过以下三个步骤获取该 ID。
In the command line tool, go to the top-level directory of your Flutter app.在命令行工具中,转到 Flutter 应用程序的顶级目录。
Run the command open ios/Runner.xcworkspace to open Xcode (Go > ios/Runner.xcworkspace and click right and select Flutter > click on Open iOS module in Xcode)运行命令 open ios/Runner.xcworkspace 打开 Xcode(Go > ios/Runner.xcworkspace 并单击右键并选择 Flutter > 在 Xcode 中单击 Open iOS module)
In Xcode, click the top-level Runner in the left pane to show the General tab in the right pane, as shown in the screencap below.在 Xcode 中,单击左窗格中的顶级 Runner 以在右窗格中显示 General 选项卡,如下面的屏幕截图所示。 Copy the Bundle Identifier value.复制捆绑标识符值。
Back in the Firebase dialog, paste the copied Bundle Identifier into the iOS bundle ID field, then click Register App.返回 Firebase 对话框,将复制的 Bundle Identifier 粘贴到 iOS bundle ID 字段中,然后单击 Register App。
Continuing in Firebase, follow the instructions to download the config file GoogleService-Info.plist.继续在 Firebase 中,按照说明下载配置文件 GoogleService-Info.plist。
Go back to Xcode.回到Xcode。 Notice that Runner has a subfolder also called Runner (as shown in the screencap above).请注意,Runner 有一个子文件夹,也称为 Runner(如上面的屏幕截图所示)。
Drag the GoogleService-Info.plist file (that you just downloaded) into that Runner subfolder.将 GoogleService-Info.plist 文件(您刚刚下载的)拖到该 Runner 子文件夹中。
In the dialog that appears in Xcode, click Finish.在 Xcode 中出现的对话框中,单击 Finish。
Go back to the Firebase console.返回 Firebase 控制台。 In the setup step, click Next, then skip the remaining steps and go back to the main page of the Firebase console.在设置步骤中,单击下一步,然后跳过其余步骤并返回 Firebase 控制台的主页。
You're done configuring your Flutter app for iOS!你已经为 iOS 配置了你的 Flutter 应用程序!
For More :
Platform-specific Firebase configuration For More :
特定For More :
平台的 Firebase 配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.