카테고리 없음

[Flutter] CocoaPods could not find compatible versions for pod "Firebase/Auth"- CocoaPods 의존성 및 버전 관련 에러 해결하기

mark340 2025. 2. 7. 15:09

문제 상황

CocoaPods를 통한 iOS 의존성 설치 중 다음과 같은 에러가 발생했습니다:

[!] :
  In snapshot (Podfile.lock):
    Firebase/Auth (= 11.0.0)
  In Podfile:
    firebase_auth depends on Firebase/Auth (= 11.6.0)

발생 원인 분석

  1. Firebase 패키지 버전 간의 불일치
  2. CocoaPods 스펙 저장소의 만료
  3. Podfile.lock과 실제 의존성 요구사항의 충돌

에러 유형별 해결 방법

1. 버전 불일치 에러

Could not find compatible versions for pod "Firebase/Auth"

해결 방법:

  1. pubspec.yaml의 Firebase 패키지 버전 동기화:
  2. dependencies: firebase_core: ^2.24.2 firebase_auth: ^4.15.3 firebase_analytics: ^10.7.4
  3. 이전 설치 정보 제거:
  4. cd ios rm -rf Pods/ rm -rf Podfile.lock

2. CocoaPods 스펙 저장소 만료

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.

해결 방법:

pod repo remove trunk
pod setup
pod install

3. 의존성 충돌

[!] CocoaPods could not resolve dependencies for target 'Runner'

해결 방법:

  1. 의존성 캐시 정리:
  2. pod deintegrate pod cache clean --all
  3. Podfile 업데이트:
  4. platform :ios, '12.0'
platform :ios, '12.0'

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

CocoaPods 의존성 관리 이해하기

Podfile.lock의 역할

  • 설치된 의존성의 정확한 버전을 기록
  • 팀원 간 동일한 버전 사용 보장
  • 의존성 잠금으로 예기치 않은 업데이트 방지

버전 지정 방식

pod 'Firebase/Auth', '11.6.0'         # 정확한 버전
pod 'Firebase/Auth', '~> 11.6.0'      # 패치 업데이트만 허용
pod 'Firebase/Auth', '>= 11.6.0'      # 최소 버전 지정

CDN vs. Git Sources

# CDN 사용
source 'https://cdn.cocoapods.org/'

# Git 소스 사용
pod 'CustomPod', :git => 'https://github.com/user/repo.git'

종합적인 해결 프로세스

  1. 의존성 초기화:
  2. cd ios rm -rf Pods/ rm -rf Podfile.lock pod deintegrate
  3. CocoaPods 업데이트:
  4. pod repo update pod install --repo-update
  5. Flutter 프로젝트 클린:
  6. cd .. flutter clean flutter pub get
  7. 재설치:
  8. cd ios pod install

문제 해결 Tips

  1. 버전 호환성 확인
  • Firebase 등 주요 패키지의 호환성 매트릭스 확인
  • Flutter 버전과 iOS 최소 지원 버전 확인
  1. Pod 설치 옵션
  2. pod install --verbose # 자세한 로그 확인 pod update --no-repo-update # 저장소 업데이트 없이 설치 pod install --repo-update # 저장소 업데이트 포함 설치
  3. CocoaPods 캐시 관리
  4. # 특정 Pod 캐시 삭제 pod cache clean 'Firebase'

전체 캐시 삭제

pod cache clean --all

```

참고 자료