Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Installing Swift Packages in Colab

First the package needs a dynamic library product. You might have to modify the package to have one. Here's an example.

Now make a notebook that clones the package, builds the package, and copies the build artifacts into the right places. Here's an example.

In a Swift notebook, dlopen the shared library and then import the module. For example:

import Glibc
dlopen("/swift/toolchain/usr/lib/swift/linux/", RTLD_NOW)
import DeckOfPlayingCards

Now you can use it. For example:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment