【问题标题】:Issues with Runner using FlutterRunner 使用 Flutter 的问题
【发布时间】:2021-08-22 22:45:01
【问题描述】:

我遇到了一个问题,我有一个 Flutter 应用程序,我正在将它配置为能够在 iOS 中使用,问题是当我在 Xcode 中运行它时它会运行但初始页面完全空白。

像这样:

当我检查 Xcode 时,我看到了这个:

它打开 AppDelegate.swift

我看到了这段代码:

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

并得到这个异常:

Exception   NSException *   "`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/."    0x000060000351d380

但是在我创建应用程序的 Visual Studio Code 中,我将 GoogleServices-Info.plist 文件放在了 Runner 文件夹中:

我不确定这是否是感情,但这些是我在 pub.dev 的项目中使用的扩展:

dependencies:
  flutter:
    sdk: flutter
  provider: ^5.0.0
  intl: ^0.17.0
  carousel_pro: ^1.0.0
  url_launcher: ^6.0.3
  photo_view: ^0.11.1
  cloud_firestore: ^2.2.1
  firebase_core: ^1.1.1
  firebase_auth: ^1.1.4
  image_picker: ^0.7.5
  firebase_storage: ^8.0.6
  random_string: ^2.1.0
  algolia: ^1.0.1
  custom_switch: ^0.0.1
  material_design_icons_flutter: ^4.0.5955
  google_sign_in: ^5.0.4
  firebase_dynamic_links: ^2.0.4
  share: ^2.0.2
  flutter_facebook_login: ^3.0.0
  http: ^0.13.3

我知道只有这些需要额外配置:

url_launcher
  image_picker
  google_sign_in
  firebase_dynamic_links
  flutter_facebook_login

无论如何,这是我的 info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>RoofDeck</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>property1</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Allow Permission to use the Image Gallery</string>
    <key>NSCameraUsageDescription</key>
    <string>Allow Permission to use the Camera</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Allow Permission to use the Microphone</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>RoofDeck requires access to the photo library.</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>RoofDeck requires access to the microphone.</string>
    <key>NSCameraUsageDescription</key>
    <string>RoofDeck requires access to the camera.</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
    <string>https</string>
    <string>http</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <!-- TODO Replace this value: -->
            <!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
            <string>com.googleusercontent.apps.0000000000-00000000000000000</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <!--
              Replace "000000000000" with your Facebook App ID here.
              **NOTE**: The scheme needs to start with `fb` and then your ID.
            -->
            <string>fb000000000000/string>
        </array>
    </dict>
</array>

<key>FacebookAppID</key>

<!-- Replace "000000000000" with your Facebook App ID here. -->
<string>000000000000</string>
<key>FacebookDisplayName</key>

<!-- Replace "YOUR_APP_NAME" with your Facebook App name. -->
<string>RoofDeck</string>

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>
</dict>
</plist>

仅供参考,我在字符串上有正确的 Facebook 应用程序 ID,只是为了安全,我没有在此处添加正确的 Google 反向客户端 ID。

有什么想法吗?

【问题讨论】:

    标签: ios xcode flutter flutter-dependencies


    【解决方案1】:

    我假设您正在关注Algolia Flutter documentation 进行设置。我在他们的文档之后也遇到了问题。最后,我最终使用了非官方的Algolia package,它使设置变得更加容易,而且没有任何问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-22
      • 2021-03-24
      • 2020-03-30
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多