简体   繁体   中英

Undefined symbol: _OBJC_CLASS_$_WKInterfaceController error after updating Xcode to version 11.1

I updated Xcode to version 11.1 and got this expected error:

WatchKit is not available when building for iOS Simulator.

Then I deleted WatchKit from iOS app target as suggested. Since then I am having this error:

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_WKInterfaceController", referenced from: objc-class-ref in INFOnlineLibrary(IOLWatchKitHelper.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Undefined symbol: _OBJC_CLASS_$_WKInterfaceController

PS: The x86_64 part is dependent on the device/simulator choice. If I choose a real device it gives the same error for arm64. So I don't think it is a architecture issue also because of the fact that the framework that includes WKInterfaceController is just a standart watchOS framework which is Watchkit.

PS_2: There is no use of WKInterfaceController or even WatchKit in the iOS app. It is only used in WatchAppExtension part

What I have tried so far:

  • First thing was to add WatchKit framework to WatchApp and WatchAppExtension targets.
  • When I searched for Undefined symbols for architecture x86_64 type of errors in general there were many different suggestions. Even though I think it is not architecture dependent thing, I tried setting building active architecture only no in all targets. The most suggested putting $(inherited) to the search paths was already done before.
  • Checked the target of.m files. They are all fine.
  • I even went far and commented all the code that is using WKInterfaceController. Nothing has changed after. I also deleted watch app, it still looked for _OBJC_CLASS_$_WKInterfaceController but I am not sure did it properly.
  • I checked the WatchKit.framework Device Supporting Files with file WatchKit.framework command and saw that it supports arm64. Then added that library manually to libraries, ran on device but still didn't work.

Please check "Link Binary With Libraries" in "Build Phaes". Is there any library that used still WKInterfaceController or is dependent on the Watchkit?

I was getting the same error though with another framework. You just have to make sure that error files have the required framework is in your Link Binary with Libraries .

In my case I had the error Undefined symbol: OBJC_CLASS $_SKStoreProductViewController which is related to StoreKit . All I had to do was add the StoreKit.framework into Link Binary with Libraries

I faced a similar error, but in my case it was probably some unclean library lying around after adding / removing dependencies. So I did Xcode -> Product -> Clean Build Folder , and rebuilt the project. It succeeded.

When I saw this error, it turned out to be because one of my .mm implementation files was not checked in the "Target Membership" section of the options pane, and so was not being built.

I had to drag & drop the framework into Xcode, under the Frameworks group. It was already added under Target > Build Phases > Embedded Frameworks, but apparently that wasn't enough.

If you are sure that implementation files are checked in the "Target Membership" section of your app for the build, make sure that there is an implementation of the header file somewhere. I ran across this issue when I had a class that I had defined within the same file as another class and forgot to put its implementation in the related .m file for both classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM