Xcode 12b3 Undefined symbol: __swift_FORCE_LOAD_$_swiftWebKit

Using Xcode 12 beta 2 and beta 3 I'm getting the following linker error:

Code Block
ld: warning: Could not find or use auto-linked library 'swiftWebKit'
Undefined symbols for architecture x86_64:
  "swift_FORCE_LOAD_$_swiftWebKit", referenced from:
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in DurationPicker.o
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in AlertRule.o
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in VideoExportCamerasTableViewHandler.o
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in CameraListCollectionViewCell.o
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in RecorderConnector.o
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in CameraListThumbnailCell.o
      swift_FORCE_LOAD_$_swiftWebKit_$_Apex in VideoExportDetailsViewController.o
      ...
     (maybe you meant: __swift_FORCE_LOAD_$_swiftWebKit_$_Apex)
ld: symbol(s) not found for architecture x86_64


The example is when building for the simulator, but I get the same error building for an arm device as well.

I don't get this error with Xcode 11. I'm guessing there's some framework I need to import or link (SwiftWebKit, it would seem), but I'm not sure why this is an issue with Xcode 12 and not with Xcode 11. I've tried linking the WebKit.framework and import WebKit in the mentioned files, but the error remains.

This is a mixed Obj-C / Swift project, and these are not the only Swift classes in the project. I have not been able to determine what's special about these particular files compared to the others in the project.

Anyone know what the problem is here and how to fix it?

Accepted Reply

Figured this out. There is a new library in Xcode 12 that needs to be added to the Link Binary with Libraries phase call libSwiftWebKit.tbd. Error went away after adding this.

Unfortunately, adding this library breaks compilation with Xcode 11, so you'll have to add & remove it depending on which version of Xcode you're using.

👎
  • This worked for with a base React Native 0.64 setup on Xcode 12.5

Add a Comment

Replies

Been seeing a similar issue and haven't been able to solve it. It seems similar to the previous issues from Xcode 11 beta, but none of those solutions seem to work:

https://developer.apple.com/forums/thread/120074?answerId=372345022#372345022
Ok, yep tried that and a couple others linked to from that thread and none of them worked.


This one:
LD_VERIFY_BITCODE = NO

And this one:
LD_RUNTIME_SEARCH_PATHS = /usr/lib/swift $executable_path/Frameworks @loader_path/Frameworks

Neither of them did the trick. Someone also mentioned just adding a new, blank Swift file, but that doesn't work either.
Still seeing the same thing with Beta 4.
Figured this out. There is a new library in Xcode 12 that needs to be added to the Link Binary with Libraries phase call libSwiftWebKit.tbd. Error went away after adding this.

Unfortunately, adding this library breaks compilation with Xcode 11, so you'll have to add & remove it depending on which version of Xcode you're using.

👎
  • This worked for with a base React Native 0.64 setup on Xcode 12.5

Add a Comment
Adding and removing libSwiftWebKit.tbd to the "Link Binary with Libraries" phase added $(SDKROOT)/usr/lib/swift to LIBRARY_SEARCH_PATHS build setting and that fixed the error for me.
I found another, simpler solution to this. Rather than adding libSwiftWebKit.tbd to your project, you can simple ensure that your LIBRARYSEARCHPATHS build setting has $(SDKROOT)/usr/lib/swift in it. Xcode will search that directory for libSwiftWebKit.tbd on its own during the build, eliminating the need for you to explicitly link it to your project, which also means it won't break backwards compatibility with Xcode 11.
🎉
Neither adding libSwiftWebKit.tbd or setting $(SDKROOT)/usr/lib/swift worked for me. Still looking for a fix.

I have added both but now m getting this error My Xcode Version is 14.0.1

error build: Building for Mac Catalyst, but linking in .tbd built for macOS, file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/swift/libswiftWebKit.tbd' for architecture arm64

I am facing the same issue.

This appeared for me randomly! i was able to archive my project normally before and since then i didn't add any new libraries and stuff.

The project runs perfectly fine on my device but it doesn't archive for some reason...

This is the error heading i am receiving from the console: Undefined symbol: _$s10RealmSwift0A14CollectionImplPAAE12makeIteratorAA11RLMIteratorVy7ElementQzGyF