본문 바로가기

Flutter

IOS 빌드 에러 일기

기존에 동료가 세팅해놨던 맥북에서 잘 동작하던 코드가, 새로산 맥북에서 빌드를 하니 빌드가 안되는 현상이 발생했다.

 

별 짓을 다해도 안되서, 3일 내내 구글링하면서 삽질만 하다가 결국 방법을 찾아냈다.

 

우선, ios Target 버전 문제가 하나 있었다.

 

이는 아래 블로그를 보고 참고해서 수정했다.

 

https://letyarch.blogspot.com/2021/06/flutter-ios.html

 

[Flutter] iOS 배포 버전 이슈 해결법

❮ [Flutter] iOS 배포 버전 이슈 해결법 20210617 플러터를 하다보면 가끔씩 이런 경고를 만나곤 한다. Warning: IPHONEOSDEPLOYMENTTARGET is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99 경고

letyarch.blogspot.com

 

xcode 를 이용해서 타겟을 수정을 하면, Podfile에 적용되지는 않아서, flutter run으로 빌드 했을때 적용이 되지 않아서 별도로 수정을 해줘야하는 것 같다.

(아닐수도 있지만, 3일 동알 삽질해본 결과는 그렇다.)

 

Podfile 상단에 보이는 아래 주석으로 처리된 부분을

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

다음과 같이 바꾼다.

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'

 

그 뒤, Podfile 맨 아래에, IPHONES_DEPLOYMENT_TARGET을 동일한 버전으로 추가해줘야하는데, 자동으로 생성된 부분을 보면 다음과 같이 되어 있다.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

이를 다음과 같이 수정해준다.

post_install do |installer|
  installer.pods_project.targets.each do |target|
  flutter_additional_ios_build_settings(target)
      target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
  end
end

 

다음은 archtecture 문제인데... 

구글에 보면 정말 동일한 문제가 상당히 많았다.

 

m1칩이 적용되면서, archtecture 문제로 발생하는 것이라고 한다.

 

xcode 내에서 arm64를 excluded 에 추가해주면 된다고하는데, flutter run으로 하면 또 적용이 되지 않아서, 방법을 찾던 중 Podfile에 다음과 같이 추가해주면 되었다. 

 

post_install do |installer|
  installer.pods_project.targets.each do |target|
  flutter_additional_ios_build_settings(target)
      target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'i386 arm64'
      end
  end
end

 

위와 같이 하니 정상적으로 빌드도 되고 실행도 되었다.

 

정말 IOS는 쉽지 않다 ㅠ

 

추가로 삽질 중에, pod install을 하니 warning이 발생하는 케이스가 있었는데, 이는 아래 블로그 링크를 보고 해결했다.

 

 

https://otrodevym.tistory.com/entry/Flutter-mac-CocoaPods-did-not-set-the-base-configuration-of-your-project-because-your-project-already-has-a-custom-config-set

 

[Flutter-mac] CocoaPods did not set the base configuration of your project because your project already has a custom config set

상황 mac에서 flutter와 xcode를 업그레이드 하고 나서 빌드 에러가 발생했습니다. 문제 파악 "#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"가 누락 되어 있다는 문구를 확인..

otrodevym.tistory.com

 

 

앞으로 ios 작업중 발생하는 문제들은 꾸준히 기록해놔야겠다.