Swift Package Manager Notes

Published on Friday, 27 January 2017

I've been running through the excellent tutorials from NSScreencast (@NSScreencast) on using the swift package manager.

I've ran into a couple of issues which I thought I'd share as others might also run into them and hopefully they will be of use.

Thanks to subdigital for the help whilst I'm learning.

I had a couple of issues with some gems in Ruby since macOS comes shipped with a lesser version.

Setup: https://gorails.com/setup/osx/10.12-sierra

Reboot once completed.

Next when I went to complete the second video in the series I'd realised I hadn't set up a great folder structure.

I had Katas then the code I'd been working with for the first FizzBuzz, this really needs it's own folder, I moved this over then made a copy for the updates to guard, should really be using source control but I haven't for now.

I tried running

bundle exec guard init
bundle exec guard

But got an error when I tried updating any of the code

:0: error: build had 1 command failures error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/AlexHedley/Documents/NSScreencast/Katas/FizzBuzz/.build/debug.yaml test Failed

I asked ben for help and he pointed me in the right direction, this wasn't an issue with ruby but with swift.

I ran

swift build

and got a better error to work with

:0: error: PCH was compiled with module cache path '/Users/AlexHedley/Documents/NSScreencast/Katas/.build/debug/ModuleCache/Q3KKH3V7UU86', but the path is currently '/Users/AlexHedley/Documents/NSScreencast/Katas/FizzBuzz Updated/.build/debug/ModuleCache/Q3KKH3V7UU86'

Looking around I found that I needed to delete the .build folder

http://stackoverflow.com/a/410...

then I ran

swift build
bundle exec guard init
bundle exec guard

and everything was working.


Other things I looked at

Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData

http://stackoverflow.com/quest...

Would it be worth deleting the ModuleCache folder /Users/AlexHedley/Library/Developer/Xcode/DerivedData/ModuleCache http://meandmark.com/blog/2016...

Usually it can be resolved by holding down the Option key and choosing Product > Clean Build Folder...

http://stackoverflow.com/a/154... Is there a way to do this for what we are using?


Completed Tutorials

Wordpress Original Link