Let's assume you've copied a Main.storyboard from an Xcode 6 project into a standalone playground's Resources directory. How can you instantiate a UIStoryboard
using the Main.storyboard file? Trying to use the default via nil
doesn't work:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
Nor does explicitly using the main bundle:
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
Even if the playground is part of the storyboard's Xcode project, I receive the same error: "Could not find a storyboard named 'main' in bundle NSBundle..."
Seems that the bundle path is correct and should be able to deserialize the storyboard file.
To open Playground on Xcode, navigate to File in the menu and click on New > Playground... To test our square function, we will choose the Blank template. Name your Playground file, then click on Create.
Create a XIB FileRight click on the portion of the screen where your project's files are (view controller, storyboard, etc), and choose new file . Xcode will prompt you for which file type you'd like to create. Choose the View option under the user interface menu.
Swift Playgrounds can satisfy your curiosity about what coding is and how it works, but it doesn't really let you write apps. Not even a super-simple basic one. The code you write can't leave the app; it can't even leave that particular puzzle page!
I found this:
"You can throw a xib file into your Resources, but the playground cannot read it or run it because it’s not in compiled form. Today, I (finallly!) thought of using ibtool to pre-compile my MainMenu.xib file into nib and then load that. When you install Xcode’s command line tools, ibtool gets added to /usr/bin. So all you need to do to compile your nib is issue the following command:
ibtool --compile MainMenu.nib MainMenu.xib`
Throw that resulting nib into your playground’s resources folder and you’re ready to load it up."
at http://ericasadun.com/2015/03/25/swift-todays-wow-moment-adding-menus-to-playgrounds/
Your storyboard will be compiled into multiple nibs (one per scene)
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With