Inconsistent package builds

I've been a programmer 20 years (VB, C#, Java, PHP/HTML/Javascript. Now I'm trying to write for Mac.
I can't get past square 1.

I'm trying to recreate an example:


I copy that zip & open it into a folder.
It compiles fine in Terminal using swift build

I copy & unzip the same zip to a new directory.
I compile in the new directory and it compiles fine.
I open Package.swift in the new folder and delete all the code.
I copy the code from the file in the example folder.and paste it into the file in the new folder.
It throws an error:
argument 'targets' must precede argument 'dependencies'.
I get other errors about commas and other things too.

I've done this over and over and over and over.
There have been times when I did the same thing and the new folder compiled fine.
I do the exact same exact thing again and it doesn't compile.

If I actually TYPE something into the new file, even in the comments it never compiles.
In general I'm finding it to be extremely inconsistent and volatile.

What is going on?
How in the world are you guys programming for Mac?

How in the world are you guys programming for Mac?

Most folks start with Xcode rather than with Swift Package Manager, but still let’s see what we can do to sort you out.

I ran through your steps and I’m not seeing anything weird, so I suspect I’m misinterpreting them. Here’s what I did:

  1. I’m running macOS 10.13.6 with Xcode 9.4 installed and selected via xcode-select.

  2. I went to this page and clicked “Clone or download” > Download ZIP.

  1. This downloaded example-package-deckofplayingcards-master.zip to my desktop.

  2. I unpacked that with the Finder, resulting in a directory called example-package-deckofplayingcards-master.

  3. I created a window (let’s call it window A) in Terminal and changed into the example-package-deckofplayingcards-master directory.

  4. In Terminal I entered swift build and it built successfully.

     $ swift build
     Fetching https://github.com/apple/example-package-fisheryates.git
     Fetching https://github.com/apple/example-package-playingcard.git
     Cloning https://github.com/apple/example-package-playingcard.git
     Resolving https://github.com/apple/example-package-playingcard.git at 3.0.4
     Cloning https://github.com/apple/example-package-fisheryates.git
     Resolving https://github.com/apple/example-package-fisheryates.git at 2.0.5
     Compile Swift Module 'PlayingCard' (3 sources)
     Compile Swift Module 'FisherYates' (2 sources)
     Compile Swift Module 'DeckOfPlayingCards' (1 sources)
     $ 
    

    .

  5. Back in the Finder I unpacked the archive again, resulting in a directory called example-package-deckofplayingcards-master 2 (note the 2 at the end).

  6. I created a window (let’s call it window B) in Terminal and changed into the example-package-deckofplayingcards-master 2 directory.

  7. In Terminal window B I entered swift build and it built successfully, just like in step 6.

  8. Still in window B, I edited Package.swift and removed all of its content.

  9. In window A, I edited Package.swift and copied its content.

  10. Back in window B, I pasted the text from step 11 into Package.swift.

  11. Still in window B, I saved the file and quit my editor.

  12. Still in window B, I ran swift build again. It built successfully.

Please review my steps and let me know what I’m doing wrong (well, right :-).

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Thanks much for your reply.
I don't know what the problem is.
It must be something to do with my environment (Sierra, xCode 9)
It's really fickle.

I'll figure something out:)
Thanks again.