Vinayakaram Nagarajan
Vinayakaram Nagarajan

Reputation: 825

GoogleService-Info.plist : Copy bundle resources or not

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

Upvotes: 6

Views: 3406

Answers (1)

Vinayakaram Nagarajan
Vinayakaram Nagarajan

Reputation: 825

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

Upvotes: 7

Related Questions