Including CoreML in a Swift project for a watch app fails to compile.
Unsure if this is a Swift compilation issue or related to the frameworks or Xcode.
Any assistance would be great.
Steps to Repro:
- Create a new Watch App project using Xcode 12 beta 1 (12A6159)
- In the
ExtensionDelegate add import CoreML
- Add
let _ = MLPredictionOptions() in applicationDidFinishLaunching()
Getting this error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MLPredictionOptions", referenced from:
objc-class-ref in ExtensionDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When trying to add CoreML directly to the project Frameworks I get this error:
ld: framework not found CoreML
clang: error: linker command failed with exit code 1 (use -v to see invocation)
1 Like
There must be something wrong with the build settings (or the wrong SDK is getting used)... It's looking for x86_64 while building for a watch which seems very off; I think all the watches use arm architectures.
Also, this should be in the 'Using Swift' category, not Development/Compiler. Development is for people contributing to the toolchain and core libraries, and Development/Compiler is for contributing to the compiler.
1 Like
Jon_Shier
(Jon Shier)
3
This is likely for the watchOS simulator, which is x86_64.
@BobbyRohweder You may need to manually link the CoreML framework on watchOS, as that system seems to have issues with automatic linking sometimes.
2 Likes
atreat
(Austin Treat Emmons)
4
@Jon_Shier what's the best way to link CoreML manually?
I've added it to my "Link Binary with Libraries" build step and I still get ld: framework not found CoreML when linking x86_64. I can see -framework CoreML in the link command.
Other Linker Flags is what I meant, where you can manually add -framework CoreML, but if that's already there then it won't help.
1 Like
anilkatti
(Anilkatti)
6
@Jon_Shier is correct. This turned out to be a bug in the framework SDK - it should be addressed in a coming beta release of Xcode. Unfortunately, there is no workaround.
2 Likes