升级 Xcode11.0之后出现的问题解决

4,235 阅读1分钟

1:升级完成直接系统崩溃

报错

 **Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'**

大意就是应用程序在uiapplication上调用了statusBar或者statusBarWindowiOS 13不让用了。 原因:是在系统中有调用

 UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
 statusBar.backgroundColor = [UIColor clearColor];

去掉这句就好了。

2:跑起来发现用presentViewController调用的样式都变了。

差了以下iOS13都更新了哪些细节。所见到的那种叫Sheet弹窗

弹框默认样式对比
显然有个样式控制弹出的界面是否是全屏,应该是去找个枚举值,并且应该枚举值里有个是sheet的。 在UIViewController中找到了

typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
    UIModalPresentationFullScreen = 0,
    UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
    UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
    UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)),
    UIModalPresentationCustom API_AVAILABLE(ios(7.0)),
    UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)),
    UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)),
    UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos),
    UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos),
    UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,
    UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,
};

将跳转的controller手动设置成全屏就好了

  UINavigationController  *nav = [[UINavigationController alloc] initWithRootViewController:controller];
 nav.modalPresentationStyle = UIModalPresentationFullScreen;

3:使用textField扩展方法闪退

报错信息

** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextView placeholderLabel]: unrecognized selector sent to instance 0x7fcfbd8ad000'

根本原因是ios13不允许使用KVO的方式进行属性的修改。 在代码中使用了

 color = [textField valueForKeyPath:@"_placeholderLabel.textColor"];

4:使用Xcode11打包报错

error: Multiple commands produce ****:
1) Target '***' (project '***') has copy command from ***'
2) That command depends on command in Target '***' (project '***'): script phase “[CP] Copy Pods Resources”

这个是因为本地文件有重复。存在原因是Xcode11之前的Xcode的bug。在引入Pod的时候bundle文件还需在外部手动引入以下。Xcode11修改了这个问题就导致有两个bundle的存在。如果队友没有升级Xcode可以通过配置 File ->WorkSpace Settings...设置

修改设置