Im having some troubles to start an iOS app using xibs instead of storyboard. The problem is that im getting a black screen and the first view controller is not being called
This is a kind of "out of the box" solution, so it is irrelevant to your code. Specially since I don't see anything wrong with your code.
I had the same problem and tried for a long time to fix the code, what worked for me was finding an example project (in github for example) that uses xibs.
Download it and then edit it to make your application it is guaranteed to work. It is a shame that Xcode wants to force us to use their storyboards with these kinds of problems.
In Swift 3.0
//MARK: Initial View Controller
func initialViewController(){
self.window = UIWindow(frame: UIScreen.main.bounds)
let rootViewController = UIViewController(nibName: "HomeVC", bundle: nil)
let navigation : UINavigationController = UINavigationController(rootViewController: rootViewController)
navigation.isNavigationBarHidden = true
self.window?.rootViewController = navigation
self.window?.makeKeyAndVisible()
}
in appdelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
initialViewController()
return true
}
In xCode 11:
Step1:
-> Delete the storyBoard file
Step2:
Under yourProject > General > deployment info > main interface -> delete reference to storyboard
Step 3:
In info.plist > Application Scene Manifest > Scene Configuration > Application Session Role > item 0 > storyboard name
-> Delete the line
Step 4:
In SceneDelegate.m
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.windowScene = (UIWindowScene *)scene;
self.window.rootViewController = [[UINavigationController alloc]
initWithRootViewController:ViewController.new];
[self.window makeKeyAndVisible];
}
make sure to import your viewController headfile like so: #import "ViewController.h"