Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile storyboard in playground

I am creating an app on playground, I added a Main.storyboard file in this project. but when its compile, it gives me the following error.

NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle 

so i start thinking that it maybe some typo, so that's why this error generates. but this was not the problem, so i start searching on google, and stackoverflow, but did not find the solution about my problem. There are many questions on stackoverflow with the following content however, each has a very specific scenario.

then i find a playground project from github, in which the developer added a main storyboard and its compiling perfectly, but its extension is Main.storyboardc. then i search about storyboardc extension. so i understand its a compile storyboard. then for just checking i double tap the the Main.storyboard and change its name to Main.storyboadc. then the following error generates

'NSInvalidArgumentException', reason: 'There doesn't seem to be a valid compiled storyboard 

Now at this point I am sure that i have to compile my storyboard first then it will add in my playground, because with out .storyboardc extension, it did not even find the Main storyboard. as i stated above. so again i already check all the material on stackoverflow, each has a very specific scenario. so guide me how to compile main.storyboard.

like image 311
iqbal Avatar asked Mar 30 '17 09:03

iqbal


People also ask

How do I add a storyboard to an existing Xcode project?

Add new storyboard to the project by File->New->File... ->Userinterface->storyboard. Go to project summary and select MainStoryboard and select the storyboard name you just created.

What is the extension of compiled version of main storyboard file?

The compiler for storyboards (and all the other interface builder files) is called ibtool . The resulting files from the process have the extension . storyboardc .

What is storyboard Swift?

Basic Swift Code for iOS Apps Storyboards help us create all the screens of an application and interconnect the screens under one interface MainStoryboard. storyboard. It also helps in reducing the coding of pushing/presenting view controllers.


1 Answers

The command ibtool will do exactly this for you.

So for example, you can run ibtool --compile Main.storyboardc Main.storyboard inside the terminal. After that, all relevant files (Info.plist and .nib files) will be created inside the Main.storyboardc.

Now you can take that .storyboardc file and place it inside a project and reference the files inside the storyboard as you normally would.

let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let viewController = storyboard.instantiateViewController(withIdentifier: "MyViewController")

A .storyboardc file is nothing more than a group of nib files.

For more information have a look at the manual page man ibtool

like image 186
JoRa Avatar answered Oct 02 '22 03:10

JoRa