
28 February 2025 Leave a comment Xcode
Upgrading to Xcode 11.2 from Xcode 11.1 has led to a common issue where apps crash with the error:
“Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found.”
This problem arises when the class needs to be defined in source code or linked from a library.
Understanding the Issue
This crash is typically due to changes in Xcode 11.2 that affect how certain classes are handled, particularly _UITextLayoutView
.
The immediate solution is to update to Xcode 11.2.1, which addresses this issue directly.
Solution: Update to Xcode 11.2.1
The most straightforward and effective solution to resolve this crash is to update your Xcode to version 11.2.1. This update includes a fix for the issue, allowing your app to run without encountering the _UITextLayoutView
error.
Temporary Workaround for Xcode 11.2
If updating immediately is not feasible, there is a workaround to prevent the crash in Xcode 11.2. This involves modifying your code to dynamically create and register the missing class. Here’s a step-by-step guide:
Steps to Implement the Workaround
- Go to the Build Settings and set
DEAD_CODE_STRIPPING
to No. - Create a file named
UITextViewWorkaround.h
with the following content: - Create a corresponding implementation file
UITextViewWorkaround.m
: - Execute this workaround in your app delegate:
#import <Foundation/Foundation.h>
@interface UITextViewWorkaround : NSObject
+ (void)executeWorkaround;
@end
#import "UITextViewWorkaround.h"
#import <objc/runtime.h>
@implementation UITextViewWorkaround
+ (void)executeWorkaround {
if (@available(iOS 13.2, *)) {
} else {
const char *className = "_UITextLayoutView";
Class cls = objc_getClass(className);
if (cls == nil) {
cls = objc_allocateClassPair([UIView class], className, 0);
objc_registerClassPair(cls);
}
}
}
@end
#import "UITextViewWorkaround.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[UITextViewWorkaround executeWorkaround];
return YES;
}
Conclusion
While the best course of action is to update to Xcode 11.2.1, the workaround provided can be used as a temporary measure to keep your app running smoothly. It’s important to stay updated with the latest versions to ensure compatibility and performance.
Automating Testing with Repeato
As you navigate these updates and potential issues, consider using Repeato to automate your testing process. Repeato is a no-code test automation tool that supports iOS, Android, and web apps. It allows for fast test recording, editing, and execution, leveraging computer vision and AI. By integrating Repeato into your development workflow, you can efficiently handle testing and ensure your app remains robust across updates.
Like this article? there’s more where that came from!
- Resolving the “xcrun: error: invalid active developer path” Error on macOS
- Adding Existing Frameworks in Xcode 4: A Comprehensive Guide
- Disabling ARC for a Single File in Xcode: A Step-by-Step Guide
- Resolving the Xcode-Select Active Developer Directory Error
- Resolving the “Multiple Commands Produce” Error in Xcode 10