chaneeii / iOS-Study-Log

✨ iOS에 대해 공부한 것들을 기록합니다 ✨
18 stars 0 forks source link

[Error] Xcode 빌드세팅 - Other Linker Flag : -ObjC 에 대해 알아보자 (selector not recognized) #41

Open chaneeii opened 1 year ago

chaneeii commented 1 year ago

🤔 Intro + Error

파이어베이스 FCM 세팅하던 친구가 갑자기 이상한 근본없는 버그가 있다고 해서 같이 찾아보다가 더 궁금해서 찾아보았다!

보내준 사진

스크린샷 2022-09-18 오후 12 34 08

💡 해결방법

같은 일을 겪은 분을 찾았다.

그중 Other Linker Flag 를 -ObjC 로 설정한다면 된다는 걸 봤고 실제로 해결이 되었다.

스크린샷 2022-09-18 오후 12 35 24
  1. In Xcode, choose View > Navigators > Show Project Navigator, or press ⌘1.
  2. Select your project under the PROJECT heading in the Project Navigator, then select the Build Settings tab.
  3. Scroll down to the Other Linker Flags build setting under the Linking collection, or type "Other Linker Flags" into the search bar.
  4. Set the value of the Other Linker Flags build setting to $(OTHER_LDFLAGS) -ObjC.

image

👀 왜 Other Linker Flags 에 -ObjC 를 넣어야하는가?

ObjC를 Other Linker Flags에 넣는 것은, Objective-C로 개발된 특별한? *.framework 파일을 사용할 때 발생하는 문제를 해결하기 위해서다

Q: How do I fix "selector not recognized" runtime exceptions when trying to use category methods from a static library?

A: If you're seeing a "selector not recognized" runtime exception when calling a category method that is implemented in a static library, you are hitting the link-time build issue described here, and need to add the -ObjC linker flag to your project, by following these steps:

👀 왜 이러한 에러가 발생하나요?

스크린샷 2022-09-18 오후 12 32 03 스크린샷 2022-09-18 오후 12 33 06

출처