After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView
Congratulation
The New version of Xcode (11.2.1) is available now which is the best way to get rid off this issue.
Workarounds
@Mojtaba Hosseini the solution I proposed was from the help and the participation from my side to my fellow developers over StackOverflow. You, me and all the rest of the developer here already know that when the new version is announced by Apple, this issue will be gone.
But Beside Everything
The solution aforementioned was definitely accepted by Apple Review as there is no private API involved at all. This approach is very similar to the creating property like
@interface UITextView (Layout)
Or
UITextView+Layout.h
So when you are creating property you are directly using APPLE Private Components and re-moduling them as per you depends or requirement.
The Simple Example is AMFNetworking classes
- (void)setImageWithURL:(NSURL *)url {
[self setImageWithURL:url placeholderImage:nil];
}
Hope I am done with the Allegation
The answer below was just some help from my side to enable developer to continue developing as you we initially proposed developer to roll back Xcode. This was a bad practice to download 8 GB Xcode again since we all know that the new version of Xcode will be released soon.
While it is fixed in Xcode 11.2.1, I got one solution for Xcode 11.2 by which you can get rid off this crash:
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)'
SOLUTION
Go to the Build Setting search for "DEAD_CODE_STRIPPING" and set it to NO
DEAD_CODE_STRIPPING = NO
Then
create files UITextViewWorkaround
UITextViewWorkaround.h
#import <Foundation/Foundation.h>
@interface UITextViewWorkaround : NSObject
+ (void)executeWorkaround;
@end
UITextViewWorkaround.m
#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);
#if DEBUG
printf("added %s dynamically\n", className);
#endif
}
}
}
@end
execute it in the app delegate
#import "UITextViewWorkaround.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[UITextViewWorkaround executeWorkaround];
return yes;
}
Compile the code and you will have a running app :)
Xcode still cause apps using UITextView to crash even after installing Xcode Version 11.2.1 (11B500)
To fix the above problem:
- I had to clear the derived data folder, go to path:
~/Library/Developer/Xcode/DerivedData. - And I did clean build folder using menu: Product -> Clean Build Folder(Shift + Command + K).
Now the app won't be crashed due to UITextView
issue.
App Works from Xcode, Crashes when uploaded to Apple and exported as Developer Release
This are some issue with xcode 10.2.1 (archiving or installing release build) .I recently faced the same issue. Try to archive or upload build using xcode 10.1 .It will solve your problem.
App crashes when opening after building it with Xcode 11.3.1
I managed to make it work. I had to use the SceneDelegate
to load the components to launch my app for iOS 13 while still supporting iOS 12 but I only managed to make it work after reading how to configure it properly.
So here is the result that worked for me:
SceneDelegate.swift:
import UIKit
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let env = Environment()
if let windowScene = scene as? UIWindowScene,
let loginVC = LoginModule().createModule(moduleData: LoginModuleData(env: env),
service: LoginService(env: env),
storageService: LocalStorageService(env: env)) {
self.window = UIWindow(windowScene: windowScene)
self.window!.rootViewController = UINavigationController(rootViewController: loginVC)
self.window!.makeKeyAndVisible()
}
}
}
AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 13.0, *) {} else {
let env = Environment()
if let app = UIApplication.shared.delegate as? AppDelegate,
let window = app.window,
let loginVC = LoginModule().createModule(moduleData: LoginModuleData(env: env),
service: LoginService(env: env),
storageService: LocalStorageService(env: env)) {
window.rootViewController = UINavigationController(rootViewController: loginVC)
window.makeKeyAndVisible()
}
}
return true
}
Why almost every app crashes after you set up the date far away?
All provisioning profiles except those issued by Apple when they sign your app for the App Store have an expiration date.
When you set your date forward you are setting it past the expiration date of your development provisioning profile. An app without a valid provisioning profile can't be launched.
Once a provisioning profile has been flagged by iOS as expired it won't be honoured, even if the date is set back; This is to prevent people from setting their device date backwards in order to run apps with expired profiles.
Related Topics
Change Lock Screen Background Audio Controls Text
How to Customize the Navigation Back Symbol and Navigation Back Text
Cocoa Touch: How to Change Uiview's Border Color and Thickness
Getting the Value of a Uitextfield as Keystrokes Are Entered
Make Custom Button on Tab Bar Rounded
Swift Merge Audio and Video Files into One Video
Ios7 Uiswitch Its Event Valuechanged: Calling Continuously Is This Bug or What..
How to Load Local PDF in Uiwebview in Swift
iOS 7.1 Uitextview Still Not Scrolling to Cursor/Caret After New Line
Swiftui: Make Scrollview Scrollable Only If It Exceeds the Height of the Screen
How to Use Sfsafariviewcontroller with Swiftui
How to Get Navigation Based Template Functionality in Swift Programming
Custom Cell Row Height Setting in Storyboard Is Not Responding
iPhone Sdk:How to Play Video Inside a View? Rather Than Fullscreen
Build Not Visible in Itunes Connect
Uploading Archive Error: "Missing iOS Distribution Signing Identity for ..."