How to create project without story board in xcode 6 (swift)?
I resolve my issue..
See the screen
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:
- Create a
Single View Application
. - Remove
Main.storyboard
andLaunchScreen.xib
(select them, right-click, and choose to either
remove them from the project, or delete them completely). - Remove "Main storyboard file base name" and "Launch screen interface
file base name" entries inInfo.plist
file. - 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.
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 inapplication: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
Swift: Lazily Encapsulating Chains of Map, Filter, Flatmap
Swift and Objectmapper: Nsdate with Min Value
How to Star a Repo with Github API
How Does Let X Where X.Hassuffix("Pepper") Work
Com.Apple.Itunes Aedeterminepermissiontoautomatetarget Is Always Return -600
Changing Nav Bar Item Programmatically in Swift
How to Test an Optionset with a Switch Statement
Testing Protocol Conformance with Associated Types
Nspopover to Start in a Detached State
Not Getting Expected Delegate Calls When Trying to Restore In-App Purchases with Storekit
How to Give PDF Data a Filename for User to Save in Swift
Realm, Avoid to Store Some Property
Passing Arguments to #Selector Method in Swift
Cant Change Navigation Bar Height iOS 11
Swift: Visual Glitches When Presenting a Main and Alternative (Login/Onboarding) Flow