删除 Storyboard
首先删除项目下的Main.storyboard 文件,然后打开Info.plist, 删除SceneDelegate的StoryboardName
iOS 13之前,修改文件为AppDelegate.m:
1 2 3 4 5 6 7 8 9 10 11 12 |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if (@available(iOS 13.0, *)){ }else{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; ViewController *viewController = [[ViewController alloc] init]; self.window.rootViewController = viewController; [self.window makeKeyAndVisible]; } return YES; } |
iOS 13之后修改的为SceneDelegate.m,以上文件不进行判断会报错Exception: “-[AppDelegate setWindow:]: unrecognized selector sent to instance
1 2 3 4 5 6 7 |
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { UIWindowScene *windowScene = (UIWindowScene *)scene; self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; ViewController *viewController = [[ViewController alloc] init]; self.window.rootViewController = viewController; [self.window makeKeyAndVisible]; } |
以上都通过ViewController.m来对背景色等进行初始化,因此需进行导入
1 |
#import "ViewController.h" |
CocoaPods
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 安装https://www.jianshu.com/p/45f2ec14644b pod init # 在项目目录下进行 CocoaPods 初始化 pod repo # 查看镜像源 # 修改镜像源 cd ~/.cocoapods/repos pod repo remove master git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master 在项目工程 podfile 的第一行添加source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' rm ~/Library/Caches/CocoaPods/search_index.json pod repo remove trunk # 搜索三方库 pod search 'AFNetworking' |
常见问题
1、NSLog 不输出
Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment Variables,取消对OS_ACTIVITY_MODE值为disable的勾选
2、Showing All Issues Undefined symbol: _kJPFNetworkDidReceiveMessageNotification
Build Settings中的 Build Active Architecture Only设置由NO改为YES
3、iframe 内获取WebView Cookie 问题
1 2 3 4 |
# android if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView,true); } |