I have an application using Swift Package Manager that runs from the command line and is tested using Swiftest . I am not using Xcode and this is my first Swift project so I don't know how to get out of this error.
I am trying to remove a dependency that I am no longer using. My Package.swift
file looks like this:
import PackageDescription
let package = Package(
name: "MyApplication",
targets: [
Target(name: "Target1"),
Target(name: "Target2", dependencies: ["Target1"]),
Target(name: "Application", dependencies: ["Target2"]),
Target(name: "Specs", dependencies: ["Target1", "Target2"]),
],
dependencies: [
.Package(url: (test package))
]
)
And I want to eliminate the "Target1" dependency from "Target2". I am getting this error:
Linking Application
Undefined symbols for architecture x86_64:
"__TFC10Target1CfT_S0_", referenced from:
_main in main.swift.o
"__TMaC10Target1", referenced from:
_main in main.swift.o
ld: symbol(s) not found for architecture x86_64
All of the solutions I have seen for this error are in reference to Xcode, so I am honestly not even sure where to look for this. Target1 file is not used or referenced anywhere in Target2 file. Here is the design of the application:
├── Package.swift
├── README.md
└── Sources
├── Application
│ └── main.swift
├── Target1
│ ├── Model1.swift
│ └── Model2.swift
├── Target2
│ ├── Model3.swift
│ └── View.swift
└── Specs
├── main.swift
├── Model1Spec.swift
├── Model2Spec.swift
└── Model3Spec.swift
my main.swift
file in the application is the runner. Here is the only place where the two files connect, as I am injecting the return value of a Target1 class's function into the new instance of a Target2 class. This is probably more information than you need.
Anyway, why is this happening? Why do I need to maintain that dependency in Package.swift
to something that I am not actually depending on?
Thanks for your help and let me know if you need more info.
You are using Target 1 from Application, and that's what the error is complaining about. Application depends on Target 2 (which currently depends on Target 1 in your supplied Package.swift). If you have removed that then Application won't be able to use anything from Target 1.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.