I've built a custom Swift module using Swift Package Manager. It's intended to be used on Linux with Vapor (hence the use of SwiftPM), but I want to build and test it within Xcode first (i.e., with a simple macOS app for the front-end). The module builds fine, but when I add it to my Xcode project (the test app), I get an "Undefined symbols for architecture x86_64" error followed by dozens of errors pointing to the module code. The module target is definitely being built for macOS, and definitely for x86_64. So what might be going wrong?
Asked
Active
Viewed 368 times
2
-
You might link your built module incorrectly so that your source does not found your module. – Terence Feb 14 '17 at 15:14
-
You can google it and check the steps of how to import it. By the way, do you build your module as .framework? If you can try to put it in "Embedded Binaries" instead of "Linked Framworks and libraries" – Terence Feb 14 '17 at 17:00
-
I found a guide, maybe it helps to setup your project. https://honzadvorsky.com/articles/2016-02-25-14-00-3_steps_to_marry_xcode_with_swift_package_manager/ – Terence Feb 14 '17 at 17:22
-
Heh... thanks, but I've been through that one. However, I've just created a simple test and it fails when run from "swift test" at the command line (same error: "Undefined symbols for architecture x86_64"), so clearly something is wrong with the module itself. – jbm Feb 14 '17 at 17:28
-
1In that case, Apple provided a sample package https://github.com/apple/example-package-dealer, you can try it and see if the problem still exist, if so, maybe you can try to reboot your computer XD – Terence Feb 14 '17 at 17:37
-
Okay... (Sorry SO for so many comments!) The problem was that my partner had left an old main.swift file in Sources. This caused the build tool to build an executable, not a library. The test is working now, so I'm pretty confident I'll be able to get this running in my workspace. The answer that helped me find the problem is here: http://stackoverflow.com/questions/41322034/swift-test-give-error-undefined-symbols-for-architecture-x86-64 – jbm Feb 14 '17 at 17:51