Search code examples
swiftswift-playgroundswift-package-managerswift-package

Swift Playgrounds: Unable to Resolve Package ‘Graphics’ and ‘unzip’ Executable Not Found Error


When I import a package in Swift Playgrounds on my iPad, I receive the following error:

enter image description here

This package interactions with libgit2, and it don’t have any release in the origin repository, so I find a existing fork which have release.

Playgrounds version: 4.3.1(1727.53)

Is it means that I install a software that supports unzip on iPad?


Solution

  • XGit depends on a binary located at https://github.com/light-tech/LibGit2-On-iOS/releases/download/v1.3.1/libgit2.xcframework.zip, which is a zip file and Swift Playgrounds for iPad apparently cannot unzip it. Perhaps because the iPad app is running inside a container/sandbox, and can't launch another process like unzip.

    I tried doing the same thing with Swift Playground on macOS, and while it was able to unzip the binary (I can see it in the DerivedData folder), the Playgrounds app immediately crashed after resolving the packages.

    Opening up the .swiftpm file in Xcode, I get the warnings:

    This Swift Playgrounds project depends on a binary library, and will therefore not be buildable in Swift Playgrounds.

    This Swift Playgrounds project depends on a target containing non-Swift source code, and will therefore not be buildable in Swift Playgrounds.

    Basically, Swift packages with binary dependencies are just not supported in Swift Playgrounds.

    Even if it does support binary dependencies in the future, and is able to unzip the zip file, the library you are using contains Objective-C++ (i.e. not Swift) code. I doubt something called Swift Playgrounds is ever going to support compiling that code.

    I'd recommend finding another package, or use Xcode instead.