Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)

[✓] Android Studio (version 3.2)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.6)

[✓] Connected device (1 available)

• No issues found!

like image 497
Oga Emma Avatar asked Jan 08 '19 12:01

Oga Emma


People also ask

How do I run the Flutter app on physical iOS?

To test or deploy our flutter app to a physical device we first need to enable physical device deployment in Xcode using Apple ID or an Apple Developer account. And we also need to set up a package manager to manage flutter plugins that are to be used in the project.

Can flutter apps run on iOS?

It has gained popularity for its ability to create cross-platform apps. Flutter apps can be developed at one go and cross-compiled for different platforms – Mac, iOS, Android, Linux, Windows, Google Fuchsia, Linux, and the web.

Do I need Xcode for flutter for iOS?

Flutter is a multi-platform application development framework that enables you, among other platforms, to develop iOS and Android apps from the same source code. However, you need to use Xcode to build an iOS app and Xcode will only work on macOS.


2 Answers

I guess you forgot to add GoogleService-Info.plist file to your ios project

Follow this codelab (point 6 and 7 specifically) for detailed instruction.

Remember that it's not enough to copy it in your ios/Runner folder from the finder/explorer or command line.

You need to open the ios/Runner.xcworkspace with Xcode and add the file to the project tree. Xcode needs to be aware of this file, so that it can be copied in the application bundle.

like image 136
shadowsheep Avatar answered Nov 05 '22 11:11

shadowsheep


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.

  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. Add the files accordingly to the folders. Next, head to Target Runner and on the Build Phases section.
  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.
  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

like image 3
6thsage Avatar answered Nov 05 '22 12:11

6thsage