Hi I am getting following issue while I am trying to initialze firebase.
Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized. Have you added the "GoogleService-Info.plist"
file to the project?
My code is:
await Firebase.initializeApp();
I am using separate Google Service Info Plist for development and production.
So I am using following script in Xcode under Target > Build Phase > Run New Script Phase to copy the plist to main directory.
if [ "${CONFIGURATION}" == "Debug-prod" ] || [ "${CONFIGURATION}" == "Release-prod" ] || [ "${CONFIGURATION}" == "Release" ]; then
cp -r "${PROJECT_DIR}/Runner/Firebase/prod/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Production plist copied"
elif [ "${CONFIGURATION}" == "Debug-dev" ] || [ "${CONFIGURATION}" == "Release-dev" ] || [ "${CONFIGURATION}" == "Debug" ]; then
cp -r "${PROJECT_DIR}/Runner/Firebase/dev/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "Development plist copied"
fi
Any help would be appreciated 🙂
2
Answers
You have to add some default GoogleService-Info.plist into
${PROJECT_DIR}/Runner/GoogleService-Info.plist
(best option would be the dev one)After you start building, your script will override that one.
XCode project have to know that GoogleService-Info.plist exists in project, your script is about overriding it’s content
open your /ios/Runner/Runner.xcworkspace with xcode,
then add the Google-info.plist to this file (click right and choose add file to Runner) ,
then choose the file and don’t forget to check the option of copy items and you are donne.