
@UIApplicationMain
添加此声明,编译器会自动生成入口代码 (main 函数代码),并设置 AppDelegate 为应用程序的代理
@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate {}
当然也可以自定义,新建名为 main.swift 的文件,编写以下内容:
import UIKitclass MyApplication: UIApplication {}// 文件名必须为 `main.swift`,第三个参数可为空UIApplicationMain(CommandLine.argc,CommandLine.unsafeArgv,NSStringFromClass(MyApplication.self),NSStringFromClass(AppDelegate.self))
在 OC 中,入门文件 main.m 是这样的:
#import <UIKit/UIKit.h>#import "AppDelegate.h"int main(int argc, char * argv[]) {NSString * appDelegateClassName;@autoreleasepool {// Setup code that might create autoreleased objects goes here.appDelegateClassName = NSStringFromClass([AppDelegate class]);}return UIApplicationMain(argc, argv, nil, appDelegateClassName);}
资源名管理
https://github.com/mac-cain13/R.swift
https://github.com/SwiftGen/SwiftGen
