Search code examples
xcodeswift-playground

Xcode Playground - how to do this?


It might sound basic but I can not find a simple example on how to use Playground to test an existing code.

I have a view controller in which I already wrote some code in ( the view controller will add another simple UIView from another class I created).

This will run on simulator, but I want to see it live while I edit the code.

If I go file->new playground, it will open a playground with an existing code ( an example). I don't want to start rewriting my code into the new playground window.

Even if I try to add my own viewController into the new playground window, he will not recognize any of my project classes and provide error.

How would I run playground on my existing view controller to see the changes live?


Solution

  • I don't believe Playgrounds is designed for that purpose as it doesn't have a storyboard to view UI code. Look up @IBDesignable and @IBInspectable and implement those into your project. That might serve your purpose better.