Problem building Watch Extension in Xcode 12 beta 3

I have a problem building my project on Xcode 12 beta 3. When I build I get the following error for my Watch Extension:

Code Block
ld: in /Applications/Xcode-beta3.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk/usr/lib/libWKExtensionMainLegacy.a(WKExtensionMainLegacy.o), building for watchOS Simulator, but linking in object file (/Applications/Xcode-beta3.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk/usr/lib/libWKExtensionMainLegacy.a(WKExtensionMainLegacy.o)) built for watchOS, for architecture arm64


From what I understand is that it is complaining that the libWKExtensionMainLegacy.a file is build for arm64, not the simulator.

I've checked https://developer.apple.com/forums/thread/130684 but didn't really help me.

Any suggestions on how to resolve this?

Accepted Reply

I'm getting the same error.

I have CLANG_MODULES_AUTOLINK set to NO, both WatchConnectivity and WatchKit frameworks linked explicitly (the extension is written in Objective-C).

Turned out libWKExtensionMainLegacy.a in Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk supports x86_64, i386, and arm64.

Code Block
$ lipo -archs libWKExtensionMainLegacy.a
x86_64 arm64 i386


However, according to the link https://developer.apple.com/forums/thread/130684, the configuration might not be correct.

Having x8664 code is not sufficient to distinguish if a binary is intended for the iOS Simulator, a macOS app, or a Mac Catalyst app. Combing built binaries across different destinations (which includes the simulator vs. device binaries) is not a supported combination -- there is no Apple platform where ARM code and x8664 code in the same binary is a correct configuration.

Stripping the arm64 from the binary didn't help (just did it for testing, it couldn't be treated as a solution anyway), and got a new warning:

Code Block
Showing Recent Issues
Ignoring file .../Xcode12-beta3.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk/usr/lib/libWKExtensionMainLegacy.a, missing required architecture arm64 in file .../Xcode12-beta3.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk/usr/lib/libWKExtensionMainLegacy.a (2 slices)


and error:

Code Block
Showing Recent Issues
In .../Xcode12-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.watchos.a(floatditf.c.o), building for watchOS Simulator, but linking in object file (.../Xcode12-beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.watchos.a(floatditf.c.o)) built for watchOS, file '.../Xcode12-beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.watchos.a' for architecture arm64




Replies

I'm getting the same error.

I have CLANG_MODULES_AUTOLINK set to NO, both WatchConnectivity and WatchKit frameworks linked explicitly (the extension is written in Objective-C).

Turned out libWKExtensionMainLegacy.a in Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk supports x86_64, i386, and arm64.

Code Block
$ lipo -archs libWKExtensionMainLegacy.a
x86_64 arm64 i386


However, according to the link https://developer.apple.com/forums/thread/130684, the configuration might not be correct.

Having x8664 code is not sufficient to distinguish if a binary is intended for the iOS Simulator, a macOS app, or a Mac Catalyst app. Combing built binaries across different destinations (which includes the simulator vs. device binaries) is not a supported combination -- there is no Apple platform where ARM code and x8664 code in the same binary is a correct configuration.

Stripping the arm64 from the binary didn't help (just did it for testing, it couldn't be treated as a solution anyway), and got a new warning:

Code Block
Showing Recent Issues
Ignoring file .../Xcode12-beta3.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk/usr/lib/libWKExtensionMainLegacy.a, missing required architecture arm64 in file .../Xcode12-beta3.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk/usr/lib/libWKExtensionMainLegacy.a (2 slices)


and error:

Code Block
Showing Recent Issues
In .../Xcode12-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.watchos.a(floatditf.c.o), building for watchOS Simulator, but linking in object file (.../Xcode12-beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.watchos.a(floatditf.c.o)) built for watchOS, file '.../Xcode12-beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.watchos.a' for architecture arm64




I believe this is an issue if you are deploying to earlier than watchOS 6. Bumping the watchOS deployment target to 6.0 made this go away. This isn't a long-term solution for us, but might be useful for others.
I've filed FB8207488 with a sample project. This is easily reproducible by creating a new "iOS App with Watch app" project and dropping the watchOS deployment target to 5.3.