title: How do I use Swift Package Manager with an existing macOS project?
body: <p>I've been using Cocoapods to manage dependencies for my Swift project. I came across <a href="https://github.com/jakeheis/Shout" rel="noreferrer">this package</a> which is not listed at Cocoapods. Instead it suggests using Swift Package Manager. However, whenever I try to use Swift Package Manager to do basically anything, it ends up completely destroying my entire project.</p>
  <p>So, in order to figure out how to actually use Swift Package Manager, I'm playing with it in a test project.</p>
  <p>Here's what I've tried:</p>
  <ol>
  <li>Create a new project from Xcode</li>
  </ol>
  <blockquote>
  <p>File -&gt; New -&gt; Project -&gt; Cocoa App</p>
  <p>Product Name: basic-ssh-test</p>
  </blockquote>
  <p>This creates a basic application which loads a blank window when I hit &quot;Run&quot;. Just for fun I added <code>print(&quot;test&quot;)</code> to the <code>applicationDidFinishLaunching</code> function in my <code>AppDelegate</code> so the debug window says &quot;test&quot; when I run the program.</p>
  <p>Now I want to add the <code>Shout</code> package as a dependency.</p>
  <ol start="2">
  <li><code>swift package init --type executable</code></li>
  </ol>
  <p>This creates the following files:</p>
  <pre><code>Creating executable package: basic-ssh-test
  Creating Package.swift
  Creating README.md
  Creating .gitignore
  Creating Sources/
  Creating Sources/basic-ssh-test/main.swift
  Creating Tests/
  </code></pre>
  <p>Now I'm going to add the &quot;Shout&quot; dependency to my new <code>Package.swift</code> file:</p>
  <pre><code>// swift-tools-version:4.0
  import PackageDescription
  
  let package = Package(
      name: &quot;basic-ssh-test&quot;,
      dependencies: [
          .package(url: &quot;https://github.com/jakeheis/Shout&quot;, from: &quot;0.2.0&quot;)
      ],
      targets: [
          .target(
              name: &quot;basic-ssh-test&quot;,
              dependencies: [&quot;Shout&quot;]),
      ]
  )
  </code></pre>
  <p>And I'll pull in the dependencies:</p>
  <ol start="3">
  <li><code>swift package resolve</code></li>
  </ol>
  <p>This results in the dependencies being pulled into the <code>.build</code> directory:</p>
  <pre><code>Fetching https://github.com/jakeheis/Shout
  Fetching https://github.com/jakeheis/CSSH
  Fetching https://github.com/IBM-Swift/BlueSocket
  Cloning https://github.com/IBM-Swift/BlueSocket
  Resolving https://github.com/IBM-Swift/BlueSocket at 0.12.91
  Cloning https://github.com/jakeheis/CSSH
  Resolving https://github.com/jakeheis/CSSH at 1.0.3
  Cloning https://github.com/jakeheis/Shout
  Resolving https://github.com/jakeheis/Shout at 0.3.0
  </code></pre>
  <p>Now I regenerate the <code>xcodeproj</code> file:</p>
  <ol start="4">
  <li><code>swift package generate-xcodeproj</code></li>
  </ol>
  <p>Now when I open the <code>xcodeproj</code> file there is a new group called <code>Sources</code> that has a single directory <code>basic-ssh-test</code> with a single swift file in it <code>main.swift</code> with <code>print(&quot;Hello, world!&quot;)</code>.</p>
  <p>The code that I'm actually interested in running is now in a blue folder called <code>basic-ssh-test</code>. All of the necessary files are still in there, but instead of running my application, Xcode is running the <code>main.swift</code> file. I can tell because the debug output is &quot;Hello, world!&quot; instead of &quot;test&quot;.</p>
  <p>I've read a couple of tutorials that claim that Swift Package Manager will move my source files and continue to build the same as before, but that's clearly not the case.</p>
  <p>There's also no longer a &quot;Main Interface&quot; option in my Build Settings, so I can't select &quot;MainMenu.xib&quot; as my application starting point.</p>
  <p>This is essentially the same thing that happens when I try to use Swift Project Manager with my existing project. It pulls in the dependencies, but it basically ignores my entire existing project and just runs the &quot;hello world&quot; code.</p>
  <p>How do I use Swift Package Manager to add a dependency to an existing project without ignoring the existing codebase?</p>