0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutter Firebaseを開発・本番環境を分ける時にiOSでハマったこと

Posted at

問題

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

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?