Create Application Scene in blank OS X Storyboard - macos

I try to transfer an existing cocoa application to make use of the new storyboards for OS X with XCode6 (Beta2).
I added a new blank storyboard file and set it as the main interface of my application.
However, I have no idea how to link my NSApplication to this storyboard.
When I start a new project using storyboards I see a scene called application scene. It includes the Application (NSApplication object), Main Menu, AppDelegate...
How can I add an application object (i.e. an application scene) to a blank storyboard?
Is there something analogous to window controller and view controller objects which can be dragged on the storyboard?

As a quicker alternative, you could copy the Application Scene from a new project to your existing one:
Create a new, empty project with the "Use storyboards" option enabled.
In the new project, option-click the storyboard file, select "Open with External Editor".
In your favorite text editor, select the Scene node right under "<!--Application-->" and copy it to clipboard.
In the project that has a missing Application Scene, repeat step 2.
Paste the scene node you just copied at the top of the Scenes node (mind the plural!).
Save.
You'll now have an Application Scene in your existing project, which saves a lot of time compared to copying everything over to a new project.

Some people at the Apple Developer Forum seem to have the same problem as well:
Mac Storyboard and Application Menus
It seems that currently there is no out-of-the-box way of migrating an existing application to use storyboards. That's true at least for XCode6 Beta2.
I ended up creating a new project and transferring my existing code base manually.

A possible way is just to copy and paste the objects from a fresh project that had "Use storyboards" checked during creation within XCode.

Related

Where did tabbed controller views go in storyboard?

Forgive but I haven't coded in about a year or two, so I haven't been following the latest update in Xcode.
Anyways, I decided to go back and brush up on some skills and I noticed right off the bat that a lot has changed.
I created a new project using the tabbed view controller set up, usually it shows in storyboard immediately upon creating the project. Now there is nothing there. Where did it go and how do I bring it back?
I attached a screenshot so you can see the simulator running the tabbed apps but not showing in storyboard.
enter image description here
You opened the LaunchScreen.storyboard. This layout appears on the screen for a few moments while the app is launching.
https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/launch-screen
The storyboard that you are looking for is Main.storyboard
Notice, that there is no Main.storyboard if you start with SwiftUI
There are no specialized app templates any more. But there is still a tab view controller object in the storyboard editor's library, so just drag it into the canvas and use it. It gives you same two-child tab view controller as before.

How to convert manual view controller to storyboard as a launch screen

New iOS requirements need Apps for iPhone or iPad must be built with the iOS 13 SDK or later and use an Xcode storyboard to provide the app’s launch screen.
But my project is very old and has never used Storyboards. All UI elements are created dynamically using ViewControllers.
I managed to create a storyboard file and set it as a launcher but it has no scenes and I do not know how to proceed. I would like to:
Create a scene where I place only the original launch image inside (hoping that apple still accepts this branding)
If it is possible to just connect my main ViewController with the scene (if that works with dynamical ViewControllers)
If nothing helps than I would need to create a simple scene which has just a bottom bar like my ViewController
I had this exact issue, here's what I did:
Create LaunchScreen.storyboard and set to use it as launch screen
Using the + button in the top-right (this was not an obvious step), add a View Controller into the storyboard
Untick "Use Safe Area Layout Guides" on the right panel if you're getting that error
Tick "Is Initial View Controller"
Then clean and run, for me it just worked. I did have trouble seeing it update though, as discussed here: Launch Screen storyboard not displaying image

Where is the "Use Storyboards" button in Xcode 8.3?

In older versions, it was a "Use Storyboards" button when creating a Cocoa app that determines whether to create a storyboard file or a xib one, but now I can't find it.
Because it isn't there. It is superfluous. Just make your Cocoa project and get started. If you then want to make a xib, make one. If you want to make another storyboard, make one.
If you want to write an application that uses no storyboards at all but uses a main nib as in the old days, then make an Application xib file or a MainMenu xib file and point the target's Main Interface setting at it, and delete the default storyboard. (I just wrote an application that works that way, and it was no trouble at all. Just watch out because a modern xib has "Prefer coder" turned on by default, which may come as a surprise to an old AppKit fogie like myself.)

Cocos2d-x OS X application menus

I have a cocos2d-x application that I have been mostly debugging on iOS. Now I am working on the OS X side of things.
As expected, everything works pretty much the same, except that I have some gesture commands in my iOS app that do not translate to OS X.
I would like to create menu items (OS X level) and associated shortcuts to accomplish some of the gesture interactions (at least as one option).
Creating a MainMenu.xib and linking it in the project settings doesn't seem to be the whole story. The menus are still the generic "AppName" and Window menus, and not the ones I created in the xib file.
I believe I need to wire it up to the AppDelegate somehow, but I'm not sure how, and I haven't had any success finding documentation to that effect, at least in relation to how it interplays with Cocos2d-x.
Essentially you just need to create the menu in an Objective-C++ class that you call from AppDelegate.cpp or wherever. The extension will be .mm in order to invoke the objective-c compiler/runtime. You can then create the NSMenu and add items or replace an entire menu set[ServiceMenu/WindowMenu/MainMenu]
NSMenu reference: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenu_Class/index.html)
I found the only interesting part was receiving an action from the menu where I believe you need to then also create an objective-c class as the receiver (target).
You should be able to load the .xib file in as a entirely new menu to replace the one GLFW3 creates, but I haven't looked into that yet.
Update: Here's an example project.
https://github.com/stevetranby/TestNSMenuCocos2Dx
Update: Added example to project for loading the menu with .xib

Adding outlets to iPhone View

I am creating a custom iPhone View in MonoTouch through the interface builder in XCode (In monodevelop New File -> MonoTouch -> iPhone View).
When selecting a new iPhone View it creates an xib file, but no .h file is created, so how can I create outlets?
I usually drag an outlet from my label/button etc. to the .h file, but since it doesn't exist for this view, I don't know how to create the outlets.
Can someone point me in the right direction, since all articles on google are for the old versions, where outlets where created differently.
When you double-click a .xib in MonoDevelop, MonoDevelop will generate header files for your [Register]'d C# classes that subclass ObjC types and export them to a temporary Xcode project, where you can use Xcode to drag&drop Outlets and Actions.
Adding a new iPhone View file (.xib) does not auto-create any backing C# classes for you, it just creates the .xib, therefore MonoDevelop does not autogenerate any header files for you when you double-click the .xib.
When Xcode launches, you can manually create some Objective-C headers for this .xib and drag&drop outlets or actions to it (or you can create C# classes in MonoDevelop before double-clicking the .xib). When you switch back to MonoDevelop, MonoDevelop will "import" the header files, translating them into the equivalent C#.
While in Xcode, you can also add .xib's there and MonoDevelop will import those as well.
The Xamarin documentation has a good tutorial on this. There is a section for Adding Outlets and Actions to the UI using Interface Builder in Xcode4
Adding an Outlet In order to create the Outlet, use the following
procedure:
Determine for which control you want an Outlet.
Hold down the Control key on the keyboard, and then drag from the control to an empty space in your code file after the #interface
definition.

Resources