-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support Swift Playgrounds #2
Conversation
…ft 5.1 compatibility)
Hey Liam, thank you for contributing the first external pull request! I'll definitely take a closer look at this soon. From what I see so far, this looks great and I definitely think this is something that should be included in the project. (I have to admit that I saw this PR coming since I had noticed that someone forked the repository. 😅) |
The template playground file is just to save time, but in reality the entire .playgroundbook bundle could be generated from scratch. If you don't like the idea of the Playgrounds directory in the repo then it could be hosted in a different repo that uses something like Mint just to provide a cli that can be used to generate the bundle on each release
You're most welcome, no rush though, it was mostly just a weekend experiment 🙂 |
@liamnichols I see that this PR is still a "work in progress"? Let me know if/when you're done and I can review it more in-depth. Thank you again! 🙂 |
@a2: ah my bad for the confusion, yep it's ready to discuss at least 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your work! I think a lot of people will appreciate the ability to run this library through the Swift Playgrounds app 🙂
Playground/SwiftShortcutsTemplate.playgroundbook/Contents/Manifest.plist
Outdated
Show resolved
Hide resolved
...book/Contents/Modules/ShortcutSupport.playgroundmodule/Sources/PlaygroundPage+Shortcut.swift
Outdated
Show resolved
Hide resolved
...ontents/Modules/ShortcutSupport.playgroundmodule/Sources/ShortcutPreviewViewController.swift
Show resolved
Hide resolved
...ontents/Modules/ShortcutSupport.playgroundmodule/Sources/ShortcutPreviewViewController.swift
Outdated
Show resolved
Hide resolved
...ontents/Modules/ShortcutSupport.playgroundmodule/Sources/ShortcutPreviewViewController.swift
Outdated
Show resolved
Hide resolved
...book/Contents/Modules/ShortcutSupport.playgroundmodule/Sources/PlaygroundPage+Shortcut.swift
Show resolved
Hide resolved
...ontents/Modules/ShortcutSupport.playgroundmodule/Sources/ShortcutPreviewViewController.swift
Outdated
Show resolved
Hide resolved
return [ | ||
UIDragItem( | ||
itemProvider: NSItemProvider( | ||
object: ShortcutWrapper(shortcut) | ||
) | ||
) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoyingly this doesn't actually seem to work for me when I try to drag the shortcut into the Shortcuts.app 😕
It does however work if I drag into the Files.app though so still worth keeping around.
I'm not sure if it relates to me running iOS 14 or not though since I get the green "+" indicator in the Shortcuts app but nothing happens when I drop (if I try with a different drag item (like text), I don't even get the green "+")
I might end up filing a feedback about this after I dig a little deeper as it would be a nice to have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the code here should be working so i filled a Feedback about it... Might only be an iOS 14 bug still but worth keeping the code either way i think
Thanks for the review @a2, I've updated the code and tested the new playground and all seems good still 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the requested changes so quickly. Going to merge it now 🙂
Hey! This is an awesome looking project and since it's all (mostly) written in Swift, it got me thinking about the ability to write shortcuts in Swift Playgrounds directly on the iPad 🧐
In theory, each time you publish a new release you could also publish a zipped .playgroundbook bundle that could then be opened into the Swift Playgrounds app on iPad allowing people to prototype shortcuts and use them all without having to use a Mac. Is this something you'd consider?
I did think that it was semi-pointless since you can just use Shortcuts anyway to create them using the GUI, but it might be useful for people who would prefer to express their shortcuts in code still?
This draft PR makes a few changes that result in a working POC. I've also included the gif below to show it in action:
(Note that I re-ran the playground because of what I think is an iOS 14 bug that broke the
UIActivityViewController
on first run but I need to confirm)So yeah ... The changes to the project itself were pretty simple:
Then in addition to that, I've included a .playgroundbook template that mostly resembles a blank playground with a few extras:
PlaygroundPage
as well as an internal view controller that writes the shortcut to disk and lets it be shared viaUIActivityViewController
. Sharing on iOS kinda sucks but it does the jobThere is then a GeneratePlayground.swift script that copies the template, sets it's version based on arguments and moves the package source code into a module within the .playgroundbook. The idea is that you could run this each time you make a release then zip the output SwiftShortcuts.playgroundbook and include on the GitHub release.
Anyway ... I'd be keen to see what you think about this. I'm not the biggest user of Shortcuts in general but the second that I saw this library I really wanted to see if Swift Playgrounds could be pushed to its limits and it would be interesting to see what it might enable. Cheers!