Flutter firebase cli 사용법

해당내용은 극히 개인적인 내용을 남겨봅니다.

Cli 사용방법

  1. firebase에 프로젝트를 한개 만들기합니다.
  2. firebase login
    혹 다른아이디로 로그인 하고 싶다면
firebase login --reauth
  1. dart pub global activate flutterfire_cli
  2. npm install -g firebase-tools
  3. flutterfire configure
    → 0에서 만든 firebase에서 프로젝트를 선택하게 됩니다.
    → 주의! project root folder이어야 합니다.
  4. flutter pub add firebase_core
    팩키지를 add 합니다.
  5. 아래의 부분을 적용합니다. cd ios 폴더 이동
    ios/Podfile.lock 삭제 (rm -rf Podfile.lock 없다면 무시)
  6. Podfile 파일안에 아래의 부분을 찾고 추가합니다
target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  
  # Add this line
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.12.0'
  
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

저장하고 터미널에서 pod install --repo-update

  1. flutter clean && flutter pub get
  2. 아래와 같이 입력 main에
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widgetbuild(BuildContext context) {
    returnconst Placeholder();
  }
}

.gitignore에 기록해야할 것들…

자신이 개발하는 부분만 골라서 넣으면 됨.

# Firebase関連
android/app/google-services.json
ios/Runner/GoogleService-Info.plist
lib/firebase_options.dart
ios/firebase_app_id_file.json
macos/firebase_app_id_file.json
macos/Runner/GoogleService-Info.plist

Leave a Comment