I don't know what it's talking about. Anyone know what that is? One of my directly required packages has a dependency on the swift-numerics package, so I assume it's related to that.
Can you provide a little more information about what you're doing? What platform(s) are you targeting? Is the package with a dependency on swift-numerics public? If so, what is it? What toolchain are you compiling with?
I had been working on a macOS app, and I decided to make it a multiplatform app (macOS, iOS), so I created a new project in Xcode, chose the multiplatfrom option, and re-added all the .swift files gradually, and got it compiling again.
The dependency is my own private package. To see if it helped, I added Swift Numerics directly to my project too, but that did not change the error. I'm using Xcode 13.4.1. I'm not sure what you mean by toolchain. Is there another build setting. The build setting for SWIFT_VERSION is 5.0.
I don't know of many ways to do it. I click on the root (Project) node in the navigator. Xcode shows the 3 tabs (Info, Build Settings, Project Dependencies). In the latter, I hit the "+" button, enter the package URL. For my private packages I use file URLs, for Numerics it's the github URL and I accepted the default version (1.0.0 - next major). Some of my packages I then re-add as local packages, using the same "+" button and the the "Add Local..." button. When I do that, they show as editable files under a "Packages" group in the left-side Xcode navigator, as opposed to read only views at the bottom of the navigator under "Package Dependencies". Swift Numerics is still down there under "Package Dependencies" because I don't have a local editable copy.
I'm going to try now to get rid of all the local copies of my packages so that everything is in the bottom list. I vaguely remember local copies triggering bugs in the past.
Okay, I've boiled it all down now to a simple demo project. I have:
A freshly created multiplatform app project "DemoPackageProblem", with almost no code.
PackageA (which depends on SwiftNumerics)
PackageC (which depends on PackageA)
First problem: the app compiles and runs on macOS. It uses a type from PackageC so I know it links okay. But the macOS tests will not run. I get a linker error:
Undefined symbols for architecture x86_64:
"PackageC.ThingInPackageC.init() -> PackageC.ThingInPackageC", referenced from:
Tests_macOS.Tests_macOS.testNothing() throws -> () in Tests_macOS.o
ld: symbol(s) not found for architecture x86_64`
Perhaps if I figure out this linker error it will fix the problem with the _NumericsShims as well.
If I click on the macOS tests target, it shows the "target application":
But I don't see any way to explicitly link against PackageC. In the macOS app target, I see the PackageC in the Frameworks, Libraries, and Embedded Content list, as expected:
(1) Yes, I try to use PackageC in my test. The complete code is short:
import XCTest
@testable import DemoPackageProblem
import PackageC
class Tests_macOS: XCTestCase {
func testNothing() throws {
let val = ThingInPackageC()
XCTAssertEqual(val.text, "Hello, World!")
}
}
It compiles but doesn't link.
(2) I don't how else to add PackageC to the macOS target other than to select it when I add the package, as I did, and then verify that it is the the link list for the macOS app target, as show in the screenshot above.
Oddly, Xcode does not let you select more than one target when you add the Package initially. I pick the macOS target, but I will need to manually add it to the iOS target. I assume I just need to add it to that list in the screenshot, but I don't know.
I'll try your suggestion to manually create the different targets without using the Xcode project template.
In multiplatform projects, unlike in normal projects, Xcode creates only "UITest" targets. Those are behaving differently with linking. When I manually created a "Unit Testing Bundle" target, that compiles, links, and runs as expected.
Xcode faked me out because it called the bundles and files "Tests macOS". In normal projects it creates unit tests called "[Project]Tests" and UI Tests called "[Project]UITests".
Ug. Sorry for the noise. Maybe if someone else hits this they will see my flailing here and save some time.