INEEDACHACHA

Flutter Cocoapods -> SPM 전환 Trouble Shooting 본문

Flutter/전환실록

Flutter Cocoapods -> SPM 전환 Trouble Shooting

INEEDACHACHA 2025. 7. 10. 10:01

발단

  • 공통 컴포넌트 버튼을 만들던 중 하기와 같은 에러가 발생했다.
  • SPM 전환 완료 후 Podfile도 지운 상태였기 때문이다.
  • 해당 에러는 pod install을 하라는 에러였다.
  • 갑자기 생긴 에러, 2-3개 전 PR의 내용이었고 상당 기간 개발이 진행 중에 생김
Error (Xcode): The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.


Could not build the application for the simulator.
Error launching application on iPhone SE (3rd generation). 

조치 내용 1차 (Pod 다시 생성)

  • flutter는 캐시 문제가 워낙 많으니 캐시를 모두 없앴다.
  • 조심해야하는 것은 SPM만 쓰더라도 workspace를 지우면 안 된다는 것이다.
    • 인공지능은 workspace를 지우도록 유도한다.
  • SPM을 비활성화 시킨다.
pubspec.yaml 

flutter:
  config:
    enable-swift-package-manager: false
전역 비활성화  

flutter config --no-enable-swift-package-manager
flutter clean
flutter pub get
flutter run
  • 이렇게 했을 경우 Pod이 생기면서 에러가 사라진다.

조치 내용 2차 (SPM 수동 이식)

전역 활성화 

flutter config --enable-swift-package-manager
pubspec.yaml 

flutter:
  config:
    enable-swift-package-manager: true
  • 상기의 두 가지로 SPM을 활성화 해준다.
  • 그리고 다시 빌드를 하면 아래와 같은 에러가 생긴다.
All plugins found for ios are Swift Packages, but your project still has CocoaPods integration. To remove CocoaPods integration, complete the following steps:
  * In the ios/ directory run "pod deintegrate"
  * Also in the ios/ directory, delete the Podfile
  • pod deintegrate 실행
  • Podfile, Directory 삭제
  • 이렇게 하면 flutter 상에서는 빌드가 될 것이다.

조치 내용 3차 (Xcode 상에서 빌드)

  • 상기의 조치로 인해 flutter 에서는 빌드 성공
  • 하지만, Xcode에 들어가서 빌드를 했을 때는 안 됐다.
  • Xcode에서 .xcodeproj를 실행해서
  • Runner target을 클릭 후 Build Phase -> Link Binary With Libraries로 이동한다.
  • 이동 후 'FlutterGeneratedPluginSwiftPackage'가 반드시 존재해야 한다.

  • 사진과 같은 조치가 끝났다면
  • CocoaPod에 대한 의존은 없어지고 빌드도 잘 된다.