Can I upload a storyboard on an iOS playground?

Can I upload a storyboard on an iOS playground? Follow these steps:

How to create an instance of a storyboard from a file on an iOS playground?

Compiled Main.storyboard using

ibtool --compile MainMenu.nib MainMenu.storyboard 

Added it to the Resources folder of the playground. Then I tried to download it:

 let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) 

This results in an error:

 Playground execution aborted: Execution was interrupted, reason: signal SIGABRT. 

Is this supported in Xcode 7.3.1 or even in Xcode 8?

+5
source share
2 answers

Your initboard storyboard script works for me if I set up a playground resource section with the same structure as the application.

Resources-> Base.lproj-> Main.storyboardc

+4
source

After many attempts, I finally got this job. A few caveats:

1 .. Compile the storyboard using

 ibtool --compile MainMenu.storyboardc MainMenu.storyboard 

Do not use

 ibtool --compile MainMenu.nib MainMenu.storyboard 

2. Place the compiled storyboardc file in the "Resources" folder of the playground, not the "Sources" folder

3 .. Specify the module name using the -module flag when compiling. Otherwise, your exits may cause a runtime error. For a playground book, the module name is Book_Sources. For your own playground, the name of the module is [Name of the playground] _ Sources. Note. I did not find anything in the Apple documentation, so it can be changed. The last command looks like this:

 ibtool --compile MainMenu.storyboardc MainMenu.storyboard --module Book_Sources 
+1
source

All Articles