-1

I'm using the following simple code to initialize a storyboard inside playground:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier:"ViewController")

PlaygroundPage.current.liveView = controller

ViewController is a public class embedded within a cocoa touch framework because I want to share this code with playground but I'm getting this error:

enter image description here

If I create a new storyboard with a simple UIViewController everything is working.Any ideas?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
sger
  • 719
  • 2
  • 12
  • 26
  • try the instantiateInitialViewController method – Shubham Ojha Jan 13 '19 at 11:58
  • I tried but same thing – sger Jan 13 '19 at 13:34
  • How do you embedded and import your framework in Playground? – Yannick Loriot Jan 13 '19 at 16:09
  • I created a new target with cocoa touch framework which contains Main storyboard and all class files.The problem is with Main storyboard and initial view controller if I create a new storyboard its working. – sger Jan 13 '19 at 16:51
  • I see the same error after adding a Storyboard to my Playground (in Resources). The Storyboard has a single UIViewController with a name and ID which I have tried to instantiate just like you did. – stonecanyon Jan 18 '19 at 12:02

1 Answers1

-1

Found the solution you have to set target membership for Main.storyboard for both framework and your project

sger
  • 719
  • 2
  • 12
  • 26
  • Huh? From a Playground I don't see how to set target membership for the Main Storyboard, which I have added to Resources. Are you saying that in order to load a Storyboard into a Playground, first we need to create a framework inside a project workspace, then set the target membership? – stonecanyon Jan 18 '19 at 11:57