Search code examples
objective-cxcodecocoaswiftswift-playground

Embed Xcode Playground within an application


I want to make a Cocoa OS X application where users will be able to input and execute Swift language code within a window in my application. My first thought was to make my own basic IDE, and execute compilation and executing with system calls; however, I'd really like to have the interactive Playground feature.

I did my research and found that I can create Xcode Playground files with embedded documentation, but this raises a question:

Does the documentation have to be placed above and below the playground, or can I embed a Playground within a container in my HTML code?

The Xcode Playground embedded documentation I speak of can be found here.

Basically, I am looking to embed the Playground in a way that mimics the layout used on CodeAcademy.com

enter image description here

Is this possible with the Documentation embedded Xcode Playgrounds, or must I recreate an IDE from scratch within my Cocoa application?


Solution

  • According to Apple's Interactive Learning Document Format Reference, the sections element of a playground can contain only a flat list of code and documentation elements interspersed, which is to say they must be inline as of writing.

    However, you'll notice a message that the top of the guide,

    Warning: This is a specification that is likely to change.

    Conclusion: no, but file a feature request.