GoogleService-Info.plist : Copy bundle resources or not
Asked Answered
N

1

6

I user flutter flavors (dev and prod) and my respective GoogleServices-Info.plist file is present in a Firebase/dev Firebase/prod folders respectively

I use a "Build Phases" script to copy the file to Runner/ directory at build-time with the below script

if [ "${CONFIGURATION}" == "Debug-prod" ] || [ "${CONFIGURATION}" == "Release-prod" ] || [ "${CONFIGURATION}" == "Release" ]; then
cp -r "${PROJECT_DIR}/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}/Firebase/dev/GoogleService-Info.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"

echo "Development plist copied"
fi

Was all working OK, till I tried to use CI/CD with codemagic.

(1) First I got this error from codemagic build(But worked fine locally)

error: Build input file cannot be found: >'/Users/builder/clone/ios/Runner/GoogleService-Info.plist'

(2) I then removed the file from "Copy bundle resources" from my Xcode Target. Now I get below error(Both locally as well as with codemagic):

error: Could not get GOOGLE_APP_ID in Google Services file from build environment

What is the correct setting I should keep to get the build working both locally as well as in codemagic?

Update: After a bit of pondering, looks like (1) is the correct setting. > GoogleServices-Info.plist should be part of the copy bundle resources. >ADDITIONALLY, Runner/GoogleServices-Info.plist MUST exist before build >starts. So I placed a default plist file in the directory and it worked. >My Build Phases script will override this default plist file to >appropriate file based on the flavor

Norvol answered 4/9, 2019 at 22:22 Comment(2)
Are you specifying the flavor in the "build arguments" section of the "build" step? e.g. --flavor prod -t ./lib/main.dartApuleius
Yes, I am specifying that. The build runs ok at (1) locallyNorvol
N
7

After a bit of pondering, looks like (1) is the correct setting. GoogleServices-Info.plist should be part of the copy bundle resources.

ADDITIONALLY, Runner/GoogleServices-Info.plist MUST exist before build starts. So I placed a default plist file in the directory and it worked. My Build Phases script will override this default plist file to >appropriate file based on the flavor

Norvol answered 5/9, 2019 at 1:54 Comment(2)
could you please help me? I think I have similar issue: #75045883Squab
Really need your help, I dont understand your answer when you said: "So I placed a default plist file in the directory and it worked" . could you please elaborate more?Squab

© 2022 - 2024 — McMap. All rights reserved.