問題
FlutterでFirebaseをbackendとして使っている。
開発・本番環境を分けるべく、この記事を参考にしていた。
が、XcodeのTARGETS > Runner > Build PhasesのRun Scriptを設定してGoogleService-Info.plistを開発、本番ビルドで切り替える
のところで、記事のままやると失敗してしまい、以下のエラーが出てしまう。
<unknown>:0: error: failed to emit precompiled header '/Users/aldin/Library/Developer/Xcode/DerivedData/Runner-bjnbqukpbiokvkchuytagvputftk/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_3T9V4UQ7DGNZS-clang_313XNT4ZQGK7Y.pch' for bridging header '/Users/aldin/Documents/skydive/room8/flutter/room8/ios/Runner/Runner-Bridging-Header.h'
/Users/aldin/Documents/skydive/room8/flutter/room8/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/aldin/Documents/skydive/room8/flutter/room8/ios/Runner/Runner-Bridging-Header.h:1:
#import "GeneratedPluginRegistrant.h"
^
2 errors generated.
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel
Could not build the application for the simulator.
Error launching application on iPhone 13.
Exited (sigterm)
解決策
Run Script
の元の内容を保留して、追記する。コードは以下のようになる。
if [ "${CONFIGURATION}" == "Debug" ]; then
cp -r "${PROJECT_DIR}/Runner/GoogleService-Info-dev.plist" "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/GoogleService-Info.plist"
elif [ "${CONFIGURATION}" == "Release" ]; then
cp -r "${PROJECT_DIR}/Runner/GoogleService-Info-prod.plist" "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/GoogleService-Info.plist"
fi
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build