简体   繁体   English

无法在 IOS 上使用 firebase 运行 flutter 应用程序

[英]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/explorercommand 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 文件的情况,您可以添加一个新的构建阶段以将文件复制到编译时的正确位置。

  1. Create a config folder on the root of the iOS folder and inside it have the names of the two apps/builds you're targeting.在 iOS 文件夹的根目录上创建一个 config 文件夹,其中包含您要定位的两个应用程序/构建的名称。 Add the files accordingly to the folders.相应地将文件添加到文件夹中。 Next, head to Target Runner and on the Build Phases section.接下来,前往 Target Runner 和 Build Phases 部分。
  2. Add a new run script phase by clicking the + button at the top of that section.通过单击该部分顶部的 + 按钮添加新的运行脚本阶段
  3. Rename it to a descriptive title, I call mine Copy GoogleServices-Info.plist to correct location Then move it right below the Link Binary With Libraries phase.将其重命名为描述性标题,我称我的Copy GoogleServices-Info.plist 到正确位置然后将其移动到 Link Binary With Libraries 阶段的正下方。
  4. Copy the following script into the build phase body将以下脚本复制到构建阶段正文中
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

  1. In the Firebase console, select Project Overview in the left nav, then click the iOS button under "Get started by adding Firebase to your app".在 Firebase 控制台中,选择左侧导航栏中的项目概览,然后单击“通过将 Firebase 添加到您的应用程序开始”下的 iOS 按钮。

在此处输入图片说明

  1. The important value to provide is the iOS bundle ID, which you'll obtain using the following three steps.要提供的重要值是 iOS 捆绑包 ID,您将通过以下三个步骤获取该 ID。

  2. In the command line tool, go to the top-level directory of your Flutter app.在命令行工具中,转到 Flutter 应用程序的顶级目录。

  3. 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)

  4. 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.复制捆绑标识符值。 在此处输入图片说明

  5. 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。

  6. Continuing in Firebase, follow the instructions to download the config file GoogleService-Info.plist.继续在 Firebase 中,按照说明下载配置文件 GoogleService-Info.plist。

  7. Go back to Xcode.回到Xcode。 Notice that Runner has a subfolder also called Runner (as shown in the screencap above).请注意,Runner 有一个子文件夹,也称为 Runner(如上面的屏幕截图所示)。

  8. Drag the GoogleService-Info.plist file (that you just downloaded) into that Runner subfolder.将 GoogleService-Info.plist 文件(您刚刚下载的)拖到该 Runner 子文件夹中。

  9. In the dialog that appears in Xcode, click Finish.在 Xcode 中出现的对话框中,单击 Finish。

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

相关问题 "Amplify 更新 0.3.2 后无法在 ios 上运行颤振应用程序" - Can't Run flutter app on ios after Amplify update 0.3.2 无法在调试模式下在真实 ios 设备上运行 flutter 应用程序 - Can't run flutter app on real ios device in debug mode 无法在 ios 模拟器上运行我的 flutter 应用程序 - Can't run my flutter app on an ios simulator Flutter:现有应用程序不在 ios 中运行 - Flutter: The existing app doesn't run in ios Flutter iOS 模拟器无法运行 - Flutter iOS simulator can't run Firebase 不能与 iOS 模拟器一起运行。 Flutter - Firebase won't run with iOS simulator. Flutter 无法使用 Firebase 在 iOS 应用程序中安装 pod - Can't install pod in iOS app with Firebase 无法编译 React Native iOS 应用以在物理设备上运行,React Native Firebase 出现问题 - Can't compile React Native iOS app to run on physical device, issue with React Native Firebase Flutter 应用程序无法在 IoS 模拟器上运行,其中运行器内有循环,并且域 = NSPOSIXErrorDomain,代码 = 63 - Flutter App can't run on IoS simulator with cycle inside runner, and domain=NSPOSIXErrorDomain, code=63 Flutter 与 Firebase 集成在 IOS 上出现错误(无法安装吊舱) - Flutter integration with Firebase error on IOS (can't install pod)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM