Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch transitive dependency sources into Playground Books #19

Open
finestructure opened this issue Mar 2, 2020 · 2 comments
Open

Fetch transitive dependency sources into Playground Books #19

finestructure opened this issue Mar 2, 2020 · 2 comments

Comments

@finestructure
Copy link
Owner

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
@MaxDesiatov
Copy link

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 🤔

@finestructure
Copy link
Owner Author

finestructure commented Mar 2, 2020

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants