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 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();
No main.storyboard or ViewController.swift upon initialization of new project in Xcode?
In the latest Xcode, select Storyboard
from the User Interface dropdown,
Older Xcode
Unselect Use SwiftUI
at the following step,
Programmatically creating app without using storyboards: simulator shows me a black screen
Delete the Main.storyboard
file from your project. In the project navigator, select the target and clear Main interface field under Deployment info.
Next, edit Info.plist file and remove the value for key 'Main storyboard file base name'. Set it to empty string.
If you are using Xcode 11 or higher, on creating a new Single View App, Xcode will create the SceneDelegate.swift
file. It will also make some entries to the Info.plist file. To cleanup these storyboard entires, click Application Scene Manifest —> Scene Configuration —> Application Session Role —> Item 0 (Default Configuration) to expand it, click the minus(-) button at the end of the Storyboard Name item to remove it. The value Main
for this key implies that the SceneDelegate.swift
file will use the Main.storyboard
file, but it is already removed.
If you run the app, the project will successfully build and install, but you will only see an empty screen as you have now removed the window
of your application.
In AppDelegate.swift
, add the following code to didFinishLaunchingWithOptions
method:
window = UIWindow(frame: UIScreen.main.bounds)
window!.rootViewController = MapController()
window!.makeKeyAndVisible()
Also, remember to return true
from this method.
If your app uses the SceneDelegate.swift
file, modify this file instead. Add the following code to scene(_:willConnectTo:options:)
method:
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = MapController()
window?.makeKeyAndVisible()
On running the app now, you will see a white screen as that is the background color you have set to the MapController.
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;
}
Swift app without storyboard
You have two options
1) Open Info.Plist and remove "Main storyboard file base name" row.
2) Go to Target -> General Tab -> Deployment Info -> Main Interface -> Remove "Main" and set it to blank string
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.
How to use Google Maps Platform SDK for iOS with Xcode project without using storyboard?
You get black screen because after you stopped using storyboard as your app is confused and doesn't know what is the initial screen to load (the one that has an arrow in storyboard).
you can set it programmatically in AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let rootViewController = YourInitialViewController()
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = rootViewController
window?.makeKeyAndVisible()
return true
}
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.
Related Topics
How to Get Image Metadata in iOS
iOS 9 Segue Causes App to Freeze (No Crash or Error Thrown)
Does This App Use the Advertising Identifier (IDFA)? - Admob 6.8.0
Uitableview Dynamic Cell Heights Only Correct After Some Scrolling
Possible to Handle Your Own Http Url Schemes in iOS
Swift iOS Check If Remote Push Notifications Are Enabled in iOS9 and iOS10
Screenshot for Avplayer and Video
Centering Mkmapview on Spot N-Pixels Below Pin
App Icons Not Included in Build from Xcode
How to Make Post Nsurlrequest with 2 Parameters
How to Run Nstimer in Background Beyond 180Sec in iOS 7
Xcode Simulator: How to Remove Older Unneeded Devices
Use Didselectrowatindexpath or Prepareforsegue Method for Uitableview
Creating a Navigationcontroller Programmatically (Swift)
Uitableviewcell Checkmark to Be Toggled on and Off When Tapped
Disabling Automatic Scrolling of Uitableview When Editing Uitextfield Inside Uitableviewcell
How to Open Fb and Instagram App by Tapping on Button in Swift