[Flutter] Xcode 업그레이드 후 SDK Error를 만나서 당황한 사람의 일지

Broccolism·2023년 1월 15일
2

dev-story

목록 보기
8/8

3줄 요약

  1. xcode 업그레이드했더니 Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory), xcodebuild: error: SDK ... cannot be located. 에러 발생
  2. 원인: 쉘이 xcode SDK 경로를 찾지 못함
  3. 해결: 쉘 환경 변수에 아래와 같이 새 SDK 경로 추가 (경로 알아내는 방법은 가장 아래 '결말' 부분에..)
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk

발단

내 아이폰 13에서 사용할 플러터 앱을 개발하고 있었다. 드디어 구현과 테스트를 마친 후 휴대폰에 설치하려는데 이상하게 인식이 안 된다. 찾아보니 xcode를 업데이트해야 하고, xcode를 업데이트하려면 mac OS를 업데이트해야 한다고 한다. 그렇게 업데이트 지옥을 맛보게 되는데...

전개

  • 맥 OS 버전: macOS ventura 13.1
  • xcode 버전: 14.2
  • flutter 버전: Channel stable, 3.3.10
    아이폰 13에 빌드하려면 위 버전 이상이 필요하다. 열심히 업데이트 했다. 꼬박 반나절을 기다렸다.(사실 맥OS 업데이트는 켜놓고 그냥 잤다.) 이제 내 폰에 깔아보자! 혹시 모르니까 flutter doctor를 한번 해준다.

위기

??? 처음 보는 에러가 난다. 그것도 꽤 길게.

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-US)
[] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
Error executing simctl: 72
2023-01-15 19:18:43.989 xcodebuild[33641:5430470] Writing error result bundle to
/var/folders/dl/z9g4xprd5m73g8s9y0rpv5880000gn/T/ResultBundle_2023-15-01_19-18-0043.xcresult
xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk"
cannot be located.
xcrun: error: Failed to determine realpath of
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or
directory)
xcrun: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -find simctl 2>
/dev/null' failed with exit code 16384: (null) (errno=No such file or directory)
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH


[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    ✗ Xcode requires additional components to be installed in order to run.
      Launch Xcode and install additional required components when prompted or run:
        sudo xcodebuild -runFirstLaunch
[] Chrome - develop for the web
[] Android Studio (version 2021.3)
[] IntelliJ IDEA Ultimate Edition (version 2022.3)
[] VS Code (version 1.74.3)
[] Connected device (3 available)
[] HTTP Host Availability

! Doctor found issues in 1 category.

본업이 모바일 개발이 아니다보니 iOS 관련 에러가 나면 일단 겁부터 먹고 보는 편인데, 하필 xcode 관련 오류가 났다. (얼핏 보기에는 \n 때문에 마치 Android toolchain 에러인 것처럼 보이지만 그렇지 않다. 😇)

플러터 개발하다가 ios 에러를 만나면 일단 /ios 폴더에 들어가서 pod install 을 후다닥 쳐주면 대부분 해결된다는 팁을 들은 적 있어서 그렇게 했다. 안 먹힌다. flutter clean 도 몇번이고 해봤다. 통하지 않는다.

다시 에러 메세지로 돌아가보자.

자세히 보면 xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" cannot be located., Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory) 이렇게 일단 xcode와 path에 관련된 오류라는걸 알 수 있다.

절정

없는게 없는 stackOverflow에 역시 나와 똑같은 질문을 남긴 사람이 있었다. 원인은 정말 단순했다. xcode SDK 경로를 찾지 못한다는 것이다.(...) 이 부분에 명확히 나와있었다.

Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory)

결말

그래서 해결책은 그냥 쉘에게 올바른 경로를 알려주는 것이다.

  1. 아래 명령어로 xcode 경로를 알아낸다.
xcrun -sdk macosx --show-sdk-path 

내 컴퓨터는 이렇게 나왔다.

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk
  1. 나온 경로 복사
  2. 사용 중인 쉘의 설정 파일을 연다. zshell 사용 중이라면 sudo vi ~/.zshrc 로 열 수 있다.
  3. 아래와 같이 환경변수를 설정해준다.
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk
  1. 설정 파일을 적용(zshell의 경우 source ~/.zshrc)하거나, 쉘을 종료하고 재시작한다.
  2. 다시 flutter doctor 하면 말끔히 해결 ^-^
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-US)
[] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[] Xcode - develop for iOS and macOS (Xcode 14.2)
[] Chrome - develop for the web
[] Android Studio (version 2021.3)
[] VS Code (version 1.74.3)
[] Connected device (4 available)
[] HTTP Host Availability

• No issues found!

처음 보는 에러가 나도 침착하게 읽어봐야겠다. (라고 늘 다짐하지만 항상 당황하게 되는걸 보면 아직 갈 길이 먼 것 같다.😇) 이전에 쓰던 xcode 버전이 12.3 이었는데 에러 메세지에 그대로 나와있다. "너 왜 12.3 버전 SDK 경로를 알려주니? 나는 그거 안 쓸건데." 라고.,,.

profile
코드도 적고 그림도 그리고 글도 씁니다. 넓고 얕은 경험을 쌓고 있습니다.

5개의 댓글

comment-user-thumbnail
2023년 1월 16일

저는 이상하게 오류나면 한번에 와다다다다ㅏ 나더라구요 그러면 맥북 던지고 싶어요 ㅎㅎ

1개의 답글
comment-user-thumbnail
2023년 2월 21일

덕분에 해결했습니다 감사합니다 !!

1개의 답글
comment-user-thumbnail
2023년 10월 18일

이 글 보고 에러 해결했습니다ㅠㅠ 감사합니다!

답글 달기