简体   繁体   English

Xcode 11.4 和 iOS 13.4 打破了项目中的 Objective-C 类别

[英]Xcode 11.4 and iOS 13.4 breaks the Objective-C Categories in Project

I have a project which the code base is in Objective-C.我有一个代码库在 Objective-C 中的项目。 Ever since iOS 13, due to the changes in modalPresentationStyle, the app got changed into the new behaviour of modalStyles.从 iOS 13 开始,由于 modalPresentationStyle 的变化,应用程序变成了 modalStyles 的新行为。 Due to the requirements of the company and the client, the modalPresentationStyle should remain in fullscreen.由于公司和客户的要求,modalPresentationStyle 应该保持全屏。

To fix this a couple months ago we created an Objective-C Category file which extends the functionality of UIViewController.为了解决这个问题,几个月前我们创建了一个扩展 UIViewController 功能的 Objective-C 类别文件。 In this class we implemented two methods to be inherited into every vc in the project:在这个类中我们实现了两个方法来继承到项目中的每个vc中:

- (UIModalPresentationStyle)modalPresentationStyle
{
    return UIModalPresentationFullScreen;
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

By adding this two methods to the ObjC category let us add this configuration only once, in this file, and it replicates automatically into the VCs.通过将这两种方法添加到 ObjC 类别中,我们只需在此文件中添加一次此配置,它就会自动复制到 VC 中。 We didn't want to write this methods in every vc, it are only written if an exception needs to be added.我们不想在每个 vc 中都写这个方法,它只在需要添加异常时才写。

This worked for us in the versions leading up to this weeks update.这在导致本周更新的版本中对我们有用。

After Xcode and iOS got updated, to 11.4 and 13.4 respectively the behaviour of this category broke.在 Xcode 和 iOS 分别更新到 11.4 和 13.4 后,该类别的行为中断了。 Now this methods are not automatically called by the viewcontrollers when they are instantiated.现在,这些方法在实例化时不会被视图控制器自动调用。

I don't know if it is related to the an entry of the release notes which states:我不知道它是否与发行说明的条目有关,其中指出:

"Creating an Objective-C category file by choosing File > New > File no longer creates a file that includes an import of the AppKit framework. (55977950) (FB7346800)" “通过选择 File > New > File 创建 Objective-C 类别文件不再创建包含 AppKit 框架导入的文件。(55977950) (FB7346800)”

This broke a lot of projects that need to be updated in the coming days.这打破了许多需要在未来几天更新的项目。

I had the same problem,using class_replaceMethod can solve the problem.我有同样的问题,使用 class_replaceMethod 可以解决问题。 If the xcode version of your release is not 11.4 then this is not a problem:如果您发布的 xcode 版本不是 11.4,那么这不是问题:

[self swizzleInstanceSelector:NSSelectorFromString(@"modalPresentationStyle") withSelector:@selector(uiviewController_modalPresentationStyle)];
- (UIModalPresentationStyle)uiviewController_modalPresentationStyle {
    return UIModalPresentationFullScreen;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xcode 11.4 Quick help in objective-C langage, instead of swift Language, for firebase API with Cocoapods (iOS 13.4 App) - Xcode 11.4 Quick help in objective-C langage, instead of swift Language, for firebase API with Cocoapods (iOS 13.4 App) 在Xcode 6中的现有Objective-C iOS项目中使用JUCE模块 - Using JUCE Modules in an existing Objective-C iOS project in Xcode 6 ios / xcode / objective-c:UIPickerView不显示 - ios/xcode/objective-c: UIPickerView Not Displaying 在 Xcode 11.4/iOS 13.4 中,我发现 NSUserActivity 并不总是响应 setSuggestedInvocationPhrase - In Xcode 11.4/iOS 13.4 I'm finding that NSUserActivity doesn't always respond to setSuggestedInvocationPhrase objc_copyClassList:更新到 iOS 13.4 / XCode 11.4 后崩溃 EXC_BAD_INSTRUCTION - objc_copyClassList: crash EXC_BAD_INSTRUCTION after update to iOS 13.4 / XCode 11.4 Swift Combine 属性继承在 Xcode 11.4 beta 2 / iOS 13.4 上抛出“致命错误:调用已删除方法” - Swift Combine properties inheritance throws 'Fatal error: Call of deleted method' on Xcode 11.4 beta 2 / iOS 13.4 在iOS项目Objective-C中插入SDK - insert sdk in ios project objective-c 如何在objective-c项目中使用swift类别? - How to use swift categories in objective-c project? iOS Objective-C:如何在Xcode项目中同时具有启动xib文件和静态启动图像? - iOS Objective-C: How to have both Launch xib file and static launch images in Xcode project? 使用Objective-C在iOS警报消息中添加换行符 - Adding line breaks in iOS alert messages using Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM