XCode7后,如何创建空白的ios工程

在XCode 6的某个版本后,XCode的项目向导取消了空的ios工程选项。

参考 http://stackoverflow.com/questions/25783282/how-to-create-an-empty-application-in-xcode-6-without-storyboard

可以如下操作:

There is no option in XCode6 for directly creating an Empty Application as in XCode5 and earlier. But still we can create application without Storyboard in XCode6 by following these steps:

  1. Create an Single View Application with XCode6
  2. Remove Main.storyboard and LaunchScreen.xib (select them, right-click, and choose to either remove them from the project, or delete them completely).
  3. Remove "Main storyboard file base name" and "Launch screen interface file base name" entries in Info.plist file.
  4. Open AppDelegate.m, and edit applicationDidFinishLaunchingWithOptions so that it looks like this:
    - (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];
        [self.window makeKeyAndVisible];
        return YES;
    }

     

    For Swift:

    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
    }
  5. 对于ios 7 以后,还有一点要注意:必须在上述方法中再添加如下一行:
self.window.rootViewController= [[UIViewController alloc]init];

更新:还有一种方法,可以直接恢复 向导中的选项

 

2 thoughts on “XCode7后,如何创建空白的ios工程

  1. Susan

     

    Hi Heyuan,

     

    Nice to meet you.

    I am the recruiter of Pivotal Beijing.

    Currently we are seeking a talent software engineer now.

    Do you have any interesting to know more about this opportunity?

     

    Thanks

    Susan

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *