Search code examples
swiftlinkerprotocol-buffersfoundationhyperledger-sawtooth

Apple Mach-O Linker error. "_OBJC_CLASS_$_SwiftObject" and Foundation undefined


I have a project with library in it. If I select library as a build target it builds successfully. If I select project as a target I have linker error Undefined symbols for architecture x86_64: and list of undefined symbols. What is strange – all that symbols are standard things like "_OBJC_CLASS_$_SwiftObject", "Foundation.URLRequest.httpBody.setter : Foundation.Data?", "Swift.String.init(Swift.Substring) -> Swift.String".

Errors list

This errors disappears when I'm removing SawtoothProtobuf.pb.swift file from build. However when building only lib project which contains this file everything builds successfull.


Solution

  • I'm running into a VERY similar issue too. I've tried to build a static library from swift framework to be accessible by obj-c by putting @objc and @objMember in front of all the required things and I'm getting similar errors as you are. It's weird though because it works in the framework works in the demo app from the code owner but it fails when I install it on mine...

    Adding a blank swift file fixed it for me. I guess there needs to be some swift libraries loaded into the app which doesn't happen if there's no exposed swift code.