ImagineEngine icon indicating copy to clipboard operation
ImagineEngine copied to clipboard

Document how Imagine Engine can be used in Swift Playgrounds on iPad

Open Schlumpfpapa opened this issue 8 years ago • 11 comments

Would be great if ImagineEngine could be used in iPad Playgrounds.

As a first step I tried to put the folders „API“, „Internal“ and „UIKIt“ in xCode into an iOS Playground's „Sources“ Folder. Unfortunately xCode is stuck on „Compiling ImageEngineTest“ for over an hour now.

Can this be achieved somehow? Having ImagineEngine on iOS Playgrounds App would be huge!

Thanks and keep up the good work!

Schlumpfpapa avatar Oct 27 '17 07:10 Schlumpfpapa

Hi @Schlumpfpapa 👋

I agree, that would be amazing! I don't know if it's yet possible to import 3rd party frameworks in Swift Playgrounds for iPad though. I don't have an iPad myself at the moment, so I'm not able to try this out or work on this. But if anyone wants to check it out, and if we need to make any changes in the framework itself to make it happen, I'm all for it 👍

JohnSundell avatar Oct 27 '17 09:10 JohnSundell

Hi again,

Using a precompiled framework in an iPad Playground is not (yet?) possible as far as I know. What is possible though, is putting a buch of source files into the „sources“ directory of a Playground. These files are getting precompiled and you can use them from the main playground file like any other code which is included there. This can be tested with xCode Playgrounds on a Mac too. Unfortunately I was not able to get it running by simple adding the three folders („API“, „Internal“ and „UIKIt“) into the „sources“ directory, but I might have done something wrong.

Schlumpfpapa avatar Oct 27 '17 10:10 Schlumpfpapa

OK, actually it already does work. All you have to do is put all the files from „API“, „Internal“ and „UIKIt“ into the „sources“ folder except the files with names ending in -macOS.

Perhaps it would be a good idea to move those files in the project to a different location to simplify the process for iPad users.

You also have to put the resources folder from the Tutorial Playground into the iOS Playground.

The first few lines from the tutorial running on an iPad: img_45561a0a851c-1

Schlumpfpapa avatar Oct 27 '17 10:10 Schlumpfpapa

That is AWESOME 🚀 My desire to buy an iPad just got multiplied by 1000 😅

OK to close this now then?

JohnSundell avatar Oct 27 '17 10:10 JohnSundell

Sure. Perhaps it would be a good idea to write some hints into the docs though and to move the offending files elsewhere perhaps, like said above.

Unfortunately I have not much practise in collaborating to a git project, otherwise I could make a pull request myself and correct the error in the tutorial code (missing import PlaygroundSupport).

Schlumpfpapa avatar Oct 27 '17 10:10 Schlumpfpapa

That's a great idea - I'll take care of it 👍 Actually the playground that the tutorial comes with already includes the PlaygroundSupport import 🙂

Thanks a lot for bringing this up and for helping me figure out how to use Imagine Engine in Swift Playgrounds on iPad - this is really exciting 🎉

JohnSundell avatar Oct 27 '17 11:10 JohnSundell

I now was able to get the whole Tutorial Playground running on an iPad. Except for one „small“ detail: Tapping the asteroids does not trigger clicked events.

img_847c90b91e68-1

Schlumpfpapa avatar Oct 27 '17 11:10 Schlumpfpapa

Hmmm interesting. Do UIGestureRecognizers normally work in a playground's live view on iPad (because that's how the click handling is implemented)?

JohnSundell avatar Oct 27 '17 12:10 JohnSundell

I have written an iPad Playground using SpriteKit. At least SKView.touchesBegan and SKView.touchesEnd work as expected.

Schlumpfpapa avatar Oct 27 '17 12:10 Schlumpfpapa

Since I don't have access to an iPad I'm afraid I can't be of much help debugging this 😢

JohnSundell avatar Oct 27 '17 13:10 JohnSundell

@JohnSundell This is very interesting and I do have an iPad :)

What if we had a script that generates a pre-configured playground for the developer? 🤔

insidegui avatar Nov 20 '17 16:11 insidegui