How to Create Project Without Story Board in Xcode 6 (Swift)

How to create project without story board in xcode 6 (swift)?

I resolve my issue..

See the screen

Sample Image

Something strange with xcode6 beta, i am not sure whats wrong with it.

How do I create a new Swift project without using Storyboards?

You must mark the window and testNavigationController variables as optional:

var window : UIWindow?
var testNavigationController : UINavigationController?

Swift classes require non-optional properties to be initialized during the instantiation:

Classes and structures must set all of their stored properties to an appropriate initial value by the time an instance of that class or structure is created. Stored properties cannot be left in an indeterminate state.

Properties of optional type are automatically initialized with a value of nil, indicating that the property is deliberately intended to have “no value yet” during initialization.

When using optional variables, remember to unwrap them with !, such as:

self.window!.backgroundColor = UIColor.whiteColor();

How to create an Empty Application in Xcode without Storyboard

There is no option in XCode6 and above versions for directly creating an Empty Application as in XCode5 and earlier. But still we can create an application without Storyboard by following these steps:

  1. Create a Single View Application.
  2. Remove Main.storyboard and LaunchScreen.xib (select them, right-click, and choose to either
    remove them from the project, or delete them completely).
  3. Remove "Main storyboard file base name" and "Launch screen interface
    file base name" entries in Info.plist file.
  4. Open AppDelegate.m, and edit applicationDidFinishLaunchingWithOptions so that it looks like this:

Swift 3 and above:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool 
{
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.white
self.window?.makeKeyAndVisible()
return true
}

Swift 2.x:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.backgroundColor = UIColor.whiteColor()
self.window?.makeKeyAndVisible()
return true
}

Objective-C:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.rootViewController = [[ViewController alloc] init];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

When I create a new project in xcode 11 it goes without storyboard and if I run old project it comes without controllers?

Select User Interface as Storyboard while creating a new project in Xcode 11.

Sample Image

How to create an iOS project with a XIB in Xcode 6?

What do you mean it didn't work as Xcode 5? You can create empty project without storyboard and then add your own class with XIB like in Xcode 5:
File -> New -> File -> Cocoa Touch Class -> Set "Subclass of:" as (for example) UIViewController and check "Also create XIB file".

starting ios project without storyboard

OK, at last i got it.

What i had to do is just add again

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

After this, just delete the .h, .m and .xib and create them again.

For any reason its working fine now.

Xcode 6 - Template without Storyboards

I don't like Storyboards either.

Here is what I do to go from a SB-template to nice and clean 'from code design':

  • create a project from the single-view template (gives you the least storyboard 'boilerplaite')
  • delete the Storyboard
  • go to your AppDelegate(.m / .swift) and create a UIWindow through code in application:didFinishLaunchingWithOptions::

    CGRect screenBounds = [[UIScreen mainScreen] bounds];

    UIWindow *window = [[UIWindow alloc] initWithFrame:screenBounds];

    UIViewController *viewController = [[UIViewController alloc] init];
    [window setRootViewController:viewController];

    [window makeKeyAndVisible];

    [self setWindow:window];
  • remember to go select your target and delete the 'MainInterface' entry in 'General' under 'Deployment Info'

From this point on, you are ready to go and Xcode won't annoy you with SB anymore :)

Unfortunately, I haven't found a way to save a project as a template so far :/

How to create an empty ios project in xcode 6?

You need to deal with it, but it's easy. Start with the Single View application. Delete the storyboard and delete the reference to it in the Info.plist (so that there is no longer a main storyboard). If you like, delete the view controller class as well. Now just do everything from scratch in the app delegate's application:didFinishLaunchingWithOption:, just as you did in Xcode 5.

I'm using Swift these days, so I'll show you what a pure code app delegate launch looks like in Swift; I'm sure you can translate into Objective-C:

import UIKit

@UIApplicationMain
class AppDelegate : UIResponder, UIApplicationDelegate {
var window : UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

self.window = UIWindow(frame:UIScreen.mainScreen().bounds)
self.window!.rootViewController = ViewController() // or whatever you call it
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
return true
}
}


Related Topics



Leave a reply



Submit