0

I am trying to use a specific file based on the Xcode build configuration (Debug / Release).

The script is running, but it always uses the else condition even though I am using the "dev.debug" OR "dev.release" build configuration...

The project's Bundle ID is inconsistent with either the Bundle ID in 'GoogleService-Info.plist', or the Bundle ID in the options if you are using a customized options. To ensure that everything can be configured correctly, you may need to make the Bundle IDs consistent.

I have seen a few ways this could be done, I've tried them all but they seem to be always ignoring my if condition.

Here is my build phase script to manage this.

# Name of the resource to copy
INFO_PLIST_FILE=GoogleService-Info.plist

# Get references to debug and release versions of the plist file
DEBUG_INFO_PLIST_FILE=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Debug/${INFO_PLIST_FILE}
RELEASE_INFO_PLIST_FILE=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Release/${INFO_PLIST_FILE}

# Make sure the debug version exists
echo "Looking for ${INFO_PLIST_FILE} in ${DEBUG_INFO_PLIST_FILE}"
if [! -f $DEBUG_INFO_PLIST_FILE] ; then
    echo "File GoogleService-Info.plist (debug) not found."
    exit 1
fi

# Make sure the release version exists
echo "Looking for ${INFO_PLIST_FILE} in ${RELEASE_INFO_PLIST_FILE}"
if [! -f $RELEASE_INFO_PLIST_FILE] ; then
    echo "File GoogleService-Info.plist (release) not found."
    exit 1
fi

# Get a reference to the destination location for the plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app


echo "Copying ${INFO_PLIST_FILE} to final destination: ${PLIST_DESTINATION}"

# Copy the appropiate file to app bundle
if ["${CONFIGURATION}" == "dev.debug" | "${CONFIGURATION}" == "dev.release"] ; then
    echo "File ${DEBUG_INFO_PLIST_FILE} copied"
    cp "${DEBUG_INFO_PLIST_FILE}" "${PLIST_DESTINATION}"
else
    echo "File ${RELEASE_INFO_PLIST_FILE} copied"
    cp "${RELEASE_INFO_PLIST_FILE}" "${PLIST_DESTINATION}"
fi

I would love all the help I can get here copying the correct file over based on the configuration, cheers!

hugger
  • 426
  • 4
  • 19

1 Answers1

0

I fixed this by using case/switch instead of if/else...

case "${CONFIGURATION}" in

   "Release" )
        echo "BUILD CONFIG: RELEASE"
        cp -r "${RELEASE_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;
        
   "dev.release" )
        echo "BUILD CONFIG: RELEASE DEV"
        cp -r "${RELEASE_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;

   "Debug" )
        echo "BUILD CONFIG: DEBUG"
        cp -r "${DEBUG_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;
        
   "dev.debug" )
        echo "BUILD CONFIG: DEBUG DEV"
        cp -r "${DEBUG_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;

    *)

I really don't know why the if/else was not working, but, I hope this helps someone!

hugger
  • 426
  • 4
  • 19