Deliverance: Swift Package Manager

…but not quite yet.

I was really looking forward to being a cheerleader for Swift Package Manager. When I found out about it I thought, in my optimistic assumptions, that it was great that Apple had created its own form of CocoaPods. I also assumed that it would be better implemented than CocoaPods, and easier to use. Well, I after spending around 8 hours investigating its usage I can definitely say I am going to use it!! In a year or two…

I will be listing out some ofthe problems I encountered, but please take it with a grain of salt. I am a new developer, and I readily admit that I don’t know what I don’t know. Ultimately, though, Apple can be faulted because of this same reason. Also, this is going to a bit shorter of a blog than I wanted, because I just ran out of time. I will be circling back for my next blog to see if I can create a clear step-by-step process that avoids all weirdness like “no known module” errors and such.

Problem #1: HORRIBLE documentation

When I started to write this blog I was excited to write both about how to implement modules, and also create modules. I never got to the creation part, because of the lack of documentation available.

You can find basic overview documentation from Apple here:

The problem with this documentation is that it leaves out important steps for getting xcode to recognize your modules, or at least it seems that way. For example in Terminal after including your dependences in Package.swift you have to not just do a build, but it seems like you have to swift package generate-xcodeproj in Terminal in order to have your xcode project recognize the modules you’ve added. However, in the package manager section of it makes no mention of needing to do this, only using swift build in Terminal after you’ve added your dependencies. Which didn’t seem to work on repeated attempts to use the modules even though swift package show-dependencies showed that the modules were connected.

Problem #2: XCode doesn’t autocomplete the module or module resources

Without generating the project it appears that Xcode doesn’t recognize the modules, and you’ll pull your hair out for several hours trying to figure out why it’s not recognizing them. Even worse, if you were lucky enough to stumble upon generate xcodeproject you may still not know it’s working because there seems to be no autocomplete on installed modules or type recognition. Again, I am likely missing some critical step, but THE DOCUMENTATION IS SPARSE AND UNCLEAR.

Final Comments

I do want to come back to this and see if I just had bad luck during the first attempt, but I exceeded my blog time quota on this by a good 150%. Secondly, you may notice I’m not providing any instructions on what I did exactly to ultimately have success, and there’s a good reason for that: until I am confident that it is working 100% when I follow specific steps, I don’t want to facilitate any exploration into Swift Package Manager.

If I were you I’d just keep using the user friendly CocoaPods until some of the kinks of Swift Package Manager are worked out.