After upgrading to Xcode 11.2 from Xcode 11.1 my app crashes:
*** 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)'
Why is this happening? How can I prevent this crash?
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
Or
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
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:
SOLUTION
Go to the Build Setting search for "DEAD_CODE_STRIPPING" and set it to NO
Then
UITextViewWorkaround.h
UITextViewWorkaround.m
Compile the code and you will have a running app :)
I've adapted khan's Obj-C solution to Swift:
Call it at the end of
didFinishLaunchingWithOptions
inAppDelegate
.Thanks @Aftab!
11.2.1 GM seed resolves this issue
(and it can be used to publish to App Store)
Go to https://developer.apple.com/download/. Download Xcode 11.2.1 GM seed
Release notes confirm it fixes this error:
You can go to download the last Xcode beta release (11.2.1 GM) from Apple developer website.
Here the direct link
Update: Fixed!
As a "quick" fix you can add the
UITextView
directly from the code and not via IB. At least it worked for me. Though from my point of view it's better to rollback to previous Xcode/wait for the new one.