Swift Package Manager "Undefined symbols for architecture x86_64" from command line
<p>I have an application using <a href="https://swift.org/package-manager/" rel="noreferrer">Swift Package Manager</a> that runs from the command line and is tested using <a href="https://github.com/bppr/Swiftest" rel="noreferrer">Swiftest</a>. I am not using Xcode and this is my first Swift project so I don't know how to get out of this error. </p>

<p>I am trying to remove a dependency that I am no longer using. My <code>Package.swift</code> file looks like this:</p>

<pre><code>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))
    ]
)
</code></pre>

<p>And I want to eliminate the "Target1" dependency from "Target2". I am getting this error:</p>

<pre><code>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
</code></pre>

<p>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: </p>

<pre><code>├── 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
</code></pre>

<p>my <code>main.swift</code> 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. </p>

<p>Anyway, why is this happening? Why do I need to maintain that dependency in <code>Package.swift</code> to something that I am not actually depending on?</p>

<p>Thanks for your help and let me know if you need more info.</p>