Arena
Arena copied to clipboard
Fetch transitive dependency sources into Playground Books
Arena currently fetches the sources of direct dependencies and integrates them (flattened) into UserModule
. It does not fetch sources of transitive dependencies, i.e. dependencies that are dependencies of your primary dependency.
The sources are actually there, in .build/checkouts
, just need to pull them in.
Example
arena https://github.com/finestructure/ArenaTest --book
$ ls -l SPM-Playground/SPM-Playground.playgroundbook/Contents/UserModules/UserModule.playgroundmodule/Sources/
total 8
-r--r--r-- 1 sas staff 52 2 Mar 09:18 ArenaTest-ArenaTest.swift
Is there no way whatsoever to integrate frameworks or multiple modules within playground books? Flattening dependencies into a single namespace is quite error prone and we'll start seeing name clashes sooner or later 🤔
I'm afraid there isn't (see also https://simonfairbairn.com/swift-packages-swift-playgrounds/).
I tried placing them in subfolders but that fails on import into the playground app.
What I'm currently doing is prefixing the files with the module name when copying:
Foo/Helpers.swift
-> Foo-Helpers.swift
That should avoid most if not all clashes (as Swift doesn't support files with the same name within the same module if I'm not mistaken). It would be easy to make this even safer by just adding a random hash in case of clashes. (Right now Arena bails out if the target file already exists.)
I wish there was a way to properly add a framework rather than this hack. Not sure if the swift forums are a good place to ask but I might just shoot a message there to see if it's possible somehow :)