我正在尝试在 Codemagic 上构建一个颤振应用程序。该应用程序使用多个 firebase 项目,因此我已对其进行了相应配置。我能够在本地运行适用于 android 和 iOS 的所有版本。android 构建在 Codemagic 上也是成功的,但 iOS 构建失败了。
在下面的屏幕截图中,您可以在到达 Firebase 设置运行脚本文件后看到 iOS 构建失败
我的 Firebase 设置文件的代码是
environment="default"
# Regex to extract the scheme name from the Build Configuration
# We have named our Build Configurations as Debug-dev, Debug-prod etc.
# Here, dev and prod are the scheme names. This kind of naming is required by Flutter for flavors to work.
# We are using the $CONFIGURATION variable available in the XCode build environment to extract
# the environment (or flavor)
# For eg.
# If CONFIGURATION="Debug-prod", then environment will get set to "prod".
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi
echo $environment
# Name and path of the resource we're copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}
# Make sure GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}"
if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi
# Get a reference to the destination location for the GoogleService-Info.plist
# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"
# Copy over the prod GoogleService-Info.plist for Release builds
cp "${GOOGLESERVICE_INFO_FILE}" "${PLIST_DESTINATION}"
这是 Codemagic 团队推荐的另一种方法
我没有创建风味,而是将我的firebase
文件作为环境变量上传到 codemagic。一切都适用于 android,但 iOS 构建失败,提示无法获取 GOOGLE_APP_ID。我知道很多人在堆栈上就这个问题提出了问题,但没有一个对我有用,因为它们与代码魔术无关,而是手动将文件拖到 Xcode。我还做了一个 SSH 来检查 firebase 文件是否被添加到 iOS 文件夹中,并且它确实是在预构建脚本的帮助下添加的,但 iOS 构建仍然失败。