Xcode根据构建配置加载指定配置文件问题求助
问题解决:根据Xcode构建配置复制正确的Firebase配置文件
一、修复Build Phase脚本的逻辑错误
你的脚本中if条件判断存在语法问题,导致始终进入else分支,同时变量引用和空格规范也需要修正:
错误点说明
- 条件判断的逻辑或写法错误:原脚本用
|作为逻辑或,这是管道符,bash中应使用-o(单中括号场景)或||(双中括号场景)。 - 中括号前后缺少空格:
[和]是bash的test命令符号,前后必须加空格,否则会被当作字符串处理,导致条件判断失效。 - 变量未加双引号:当路径或变量包含空格时会引发错误,建议给所有路径变量添加双引号。
修正后的完整脚本
# 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 appropriate 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
二、解决Bundle ID不一致问题
出现的提示说明Xcode项目Bundle ID与对应GoogleService-Info.plist中的Bundle ID不匹配,需按以下步骤修正:
- 分别打开
Debug/GoogleService-Info.plist和Release/GoogleService-Info.plist,检查BUNDLE_ID字段的具体值。 - 打开Xcode项目,进入TARGETS -> 你的应用目标 -> Build Settings,搜索
Bundle Identifier。 - 确认
dev.debug配置下的Bundle ID与Debug版plist的BUNDLE_ID完全一致,dev.release(或其他Release类配置)与Release版plist的BUNDLE_ID完全一致。
内容的提问来源于stack exchange,提问作者hugger
相关产品推荐
相关产品推荐

