Xcode without Storyboard and ARC
Asked Answered
P

6

115

i have downloaded new xcode-5 and just started using it.

We can create application directly including storyboard and ARC , it is not asking for option like earlier versions.

So, my question is how can we use xcode5 without ARC and storyboard. we have to manually remove storyboard file ? or is there any other option.

Pessimism answered 21/6, 2013 at 11:29 Comment(10)
No one can really answer this, but I think Apple did it because both Storyboards and ARC are the future in developing apps with Xcode or in Objective-C. Since Xcode 5 is still a beta it might be that they add support for it later this year but I think that's not gonna happen.Underset
Remove the storyboard file manually, and remove the -fobjc-arc compiler flag in the project settings.Bistort
Have you tried opening a project made by xcode with previous versions?Abrahamabrahams
To remove ARC, you can do what @H2CO3 suggested. As far as removing Storyboard goes, try adding a new UIViewController. It still has the option to check "With XIB for user interface". You'll just have to change your AppDelegate accordingly to set that UIViewController as your rootViewController.Barncard
Questions about tools primarily used by programmers are very much on topic, provided that they don't ask for the 'best' of something or 'shopping' recommendations. I've reopened this accordingly.Karlow
Unfortunately we can not discuss XCode 5, or iOS 7 because they are both under NDA. If you need to ask any questions regarding this, please ask on the Apple Developer Forums.Bathulda
As shown in my answer , it is working . Yes i know it is under NDA but i think if some one testing with xcod 5 and want to know about this , it may be helpful for him :)Pessimism
But this is not the proper place to do so. Do understand that.Bathulda
the only thing that makes this under NDA is the words "Xcode 5" part. anything actually described can be done on previous versions of Xcode so technically this topic is free to discuss.Kono
In order to get the "Use Storyboards" option back, I came across this script: https://mcmap.net/q/189687/-xcode-5-disabling-storyboards-duplicateLujan
P
150

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.

Pessimism answered 29/7, 2013 at 10:57 Comment(5)
Isn't there an "empty project" option any more? I don't think I will every start using storyboards.Expertism
Be sure to change your Target's "Main interface" setting to your new root <View Controller>.Neman
you are right @Expertism we can do it by empty project , but these are the changes if i already crated view based application. (we have to remove some storyboard code manually from appDelegate file) while in empty application we have to add new code in it :)Pessimism
I came across a script that will add the option to remove storyboards back: https://mcmap.net/q/189687/-xcode-5-disabling-storyboards-duplicateLujan
why isn't the UINavigationController *nav not autoreleased? and we should use _window in [UIWindow alloc]?Skricki
B
44

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

Buyse answered 20/9, 2013 at 6:30 Comment(1)
Wow! Works like a charm and much simpler than the accepted answer. I just had to be sure to change all of the references to LoginViewController to match my own controller's name.Billman
C
11

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

Charissecharita answered 11/12, 2013 at 8:31 Comment(0)
D
5

ShortCut: I Prefer

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

Deposition answered 1/10, 2013 at 10:16 Comment(1)
Keeping around an older version of Xcode just for that is not worth it. I'd rather create a new project, get rid of the Storyboard stuff, add UIWindow instantiation in appDelegate and save it as a template project for later.Stormystorting
H
3

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.

Haroun answered 4/11, 2013 at 21:21 Comment(5)
However, those templates are old and don't take advantage of all the new changes available, such as -registerClass:forCellReuseIdentifier:.Homopterous
@Homopterous That is true. You need to tweak that if that functionality is important to you. Of course I hope that Apple will bring back the option to opt-out of Storyboards in a future release of Xcode.Haroun
I hope so. Like you, I use Storyboard in smaller apps, mostly due to the quick TableView development, but in larger apps, Storyboard is a major major pain. From scrolling around, to remembering segue IDs (they've got to add a way to utilize #defines or const NSString* between Storyboards and source files), to doing git conflict resolution, and more, Storyboards just aren't the be all and end all.Homopterous
those V/A arrows though.Atomizer
@JohnRiselvato You are right :) The obnoxious arrows are gone now :)Haroun
P
0

I have a Tip:

  1. The First: I create my project by XCode 4.6 (Because this version is nearest to XCode 5).
    • Of course that with XCode 4.6, you can chose use or not using ARC, Storyboard.
  2. The Second: After that I will open my Project with XCode 5. => I think that Xcode 5 will understand that project is use nonARC, and of course, do not have Storyboard.

I hope your project will work! :D

Propellant answered 21/3, 2014 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.