728x90
문제 발생 상황
Flutter 프로젝트에서 Firebase를 설정한 후, iOS 빌드를 실행할 때 다음과 같은 오류가 발생:
*** Terminating app due to uncaught exception 'cohttp://m.firebase.core', reason: '`FirebaseApp.configure()` could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
또는 실행 중 Xcode에서 Firebase 초기화 시 크래시 발생
(앱이 실행되지 않고 종료됨)
에러 원인 분석
위 오류는 GoogleService-Info.plist가 프로젝트에 제대로 추가되지 않았거나, Xcode 빌드 캐시 문제로 인해 Firebase가 해당 파일을 인식하지 못하는 경우에 발생합니다.
이 문제의 주요 원인은 다음과 같습니다:
- GoogleService-Info.plist가 올바른 경로에 있지 않음
- Firebase가 ios/Runner/GoogleService-Info.plist를 인식해야 하지만, 경로가 다르면 파일을 찾을 수 없음.
- Xcode가 GoogleService-Info.plist를 프로젝트에 포함하지 않음
- Copy Bundle Resources에 GoogleService-Info.plist가 추가되지 않았을 경우.
- Xcode의 빌드 캐시가 남아 있음
- DerivedData 및 Pods 등의 캐시가 남아 있으면 빌드에 반영되지 않을 수 있음.
- Flutter 패키지 및 CocoaPods 설정 문제
- flutter pub get 및 pod install이 제대로 실행되지 않았을 경우.
해결 방법
1️⃣ GoogleService-Info.plist 파일이 올바른 위치에 있는지 확인
터미널에서 아래 명령어를 실행하여 GoogleService-Info.plist의 정확한 위치를 확인하세요.
find ios -name GoogleService-Info.plist
✅ 결과가 ios/Runner/GoogleService-Info.plist로 나오면 정상
❌ 만약 다른 위치에 있다면, 올바른 경로로 이동해야 합니다.
mv ~/Downloads/GoogleService-Info.plist ios/Runner/
2️⃣ Xcode에서 GoogleService-Info.plist를 다시 추가
- Xcode에서 GoogleService-Info.plist 삭제
- Xcode에서 GoogleService-Info.plist 우클릭 → "Delete" 클릭
- "Remove Reference" 선택 ("Move to Trash" 선택 X)
- 파일 다시 추가
- Xcode에서 Runner 폴더 우클릭 → "Add Files to Runner..." 선택
- ios/Runner/GoogleService-Info.plist 선택 후 "Copy items if needed" 체크
- "Add" 버튼 클릭
- Xcode의 Build Phases → "Copy Bundle Resources" 확인
- GoogleService-Info.plist가 없으면 "+" 버튼 클릭 후 추가
3️⃣ Xcode 빌드 캐시 삭제 및 재설정
터미널에서 아래 명령어를 실행하여 빌드 캐시를 완전히 삭제하세요.
* 이 방법이 제일 좋음 *
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ios/Pods
rm -rf ios/Podfile.lock
rm -rf ~/.pub-cache
이 명령어는
- ✅ Xcode 빌드 캐시 삭제 (DerivedData)
- ✅ CocoaPods 삭제 (ios/Pods)
- ✅ Flutter 패키지 캐시 삭제 (~/.pub-cache)
4️⃣ Flutter 패키지 및 CocoaPods 다시 설치
위에서 삭제한 내용을 다시 설치해야 합니다.
flutter clean
flutter pub get
cd ios && pod install --repo-update && cd ..
5️⃣ Xcode에서 빌드 클린 후 다시 실행
- Xcode에서 ios/Runner.xcworkspace 열기
- Shift + Command + K → "Clean Build Folder" 실행
- Xcode에서 실행 버튼 ▶️ 클릭
- 끝 !!!!
728x90
LIST
'Flutter' 카테고리의 다른 글
Flutter 앱에 Google 광고 넣기 (0) | 2025.02.15 |
---|---|
Dart 3.7 업데이트! 개발자들을 위한 최신 포맷팅 스타일 총정리 (4) | 2025.02.14 |
Flutter 면접 질문: "왜 클래스 기반 위젯을 사용해야 할까?" (2) | 2025.02.12 |
Flutter에서 SizedBox.shrink()를 활용하여 빈 공간 추가하는 방법 (2) | 2025.02.07 |
Flutter에서 날짜와 시간 선택 유효성 검사 구현하기 (1) | 2025.01.20 |