Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode without Storyboard and ARC

People also ask

Should I use storyboard in Xcode?

Another benefit to using Storyboards (over creating views programmatically) is that you get to see what your view will look like at runtime without having to run your app. You can quickly make a change in Interface Builder and immediately see what it'll look like – without waiting for Xcode to compile and run.

How do I delete a storyboard in Xcode?

Delete Main. storyboard file and make sure you select "Move to trash" option to remove it completely.

Why is Main storyboard not showing up in Xcode?

You have SwiftUI enabled in your project, which does not use storyboards anymore. Your layout is inside the ContentView. swift file. If you do want to work the old way, with storyboards, you should uncheck 'Use SwiftUI' in the project creation screen.


Create a project with an Empty application and Add any viewcontroller (i added TestViewController here)

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
 {
   self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   // Override point for customization after application launch.
   TestViewController *test = [[TestViewController alloc]     initWithNibName:@"TestViewController" bundle:nil];
   UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:test];
   self.window.rootViewController = nav;
   [self.window makeKeyAndVisible];
   return YES;
 }

STEPS FOR REMOVE ARC

1) In build setting set Automatic Reference Counting to NO.

///////////////////////////////////////////////////////////////////////////END///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

If you have Already Created Application with storyboard and ARC then

STEPS FOR REMOVE STORY BOARD

1) Remove Main.storyboard file from your project.

2) Add new files with xib for your controller , if it is not added in compiled sources in build phases then add there manually.

3) Remove Main storyboard file base name from plist.

4) Change appdelegate didFinishLaunchingWithOptions file and add :

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

[self.window makeKeyAndVisible];

just like :

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;

     // Override point for customization after application launch.

     TestViewController *test = [[TestViewController alloc]     initWithNibName:@"TestViewController" bundle:nil];
     UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:test];
     self.window.rootViewController = nav;
     [self.window makeKeyAndVisible];

     return YES;
}


Now,in above example you have to manage memory management manually like ,

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

 [test release]; 

STEPS FOR REMOVE ARC

1) In build setting set Automatic Reference Counting to NO.


Instead of delete the storyboard file, you can Create a new project with Empty Application template. So that you can avoid the storyboard file creation.

Use following steps to omit storyboard: enter image description here

  1. Create a new project with Empty Application template.
  2. Add a new viewController (Example: LoginViewController)
  3. Change the didFinishLaunchingWithOptions in AppDelegate.m file as specified below.

Change To:

#import "LoginViewController.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc]  initWithRootViewController:loginVC];

    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

    return YES;
}

Remove ARC: Go to Build Setting -> Objective-C Automatic Reference Counting -> NO


create new project

![Create new Project]

remove Main storyboard file base name in Info

//remove Main storyboard file base name in Info

Add This Code In appdelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc]  initWithRootViewController:loginVC];

    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

    return YES;
}

Then automatic remove your storyboard.

Please Try this... successfully Executed. thanks


ShortCut: I Prefer

Create the project without Storyboard and ARC in xcode4 and then open that project in xcode5 .


Xcode 4 had the "Use Storyboards" checkbox when you created a new project. It is possible to grab the old Xcode 4 application templates (XML files) and convert them to Xcode 5. That way, you get the old templates back that let you choose whether you want storyboards or not.


I wrote a script that does all that work for you: https://github.com/jfahrenkrug/Xcode4templates


After running the script, you will have an "Xcode 4" section in the "New Project" screen:

enter image description here

And then - Alas! - you get your beloved choices back:

enter image description here

You will need a copy of the Xcode 4 .app bundle from http://developer.apple.com/ios to use this script.