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?
The issue was fixed in Xcode 11.2.1.
EDIT: As the fix is now released, you should switch to that Xcode version and comment out this workaround. As Mojtaba Hosseini in his answer mentioned:
For the time until the fix was released by Apple, this was a good workaround to continue developing and testing.
For Xcode 11.2, based on the idea of Aftab Muhammed Khan and with the help of John Nimis I just tested the following code.
No change in the storyboard files necessary!
Edited my AppDelegate.swift file and added this class
and within the delegate call for "didFinishLaunchingWithOptions" call the workaround
1. Problem:
There is an issue with Xcode 11.2 wherein Storyboards containing a UITextView will cause the app to crash on OS versions earlier than iOS 13.2 if compiled with Xcode 11.2.
Check this apple documentation.
2. Solution:
The only solution is to update your Xcode to 11.2.1 or 11.3.
Xcode 11.2.1 was particularly released to fix this crash issue.
Check this apple documentation.
3. Suggestion:
I would suggest you to go with latest version of Xcode 11.3 since this supports developing apps for iOS 13.3 and also there are many new features. Check this apple documentation.
I used a successful workaround, but it was painful. This is the process that I followed:
TextView
. In my case:id
(in my case:id="782-j1-88c"
)Doing this fixed the issue for me with no loss in desired functionality. Fortunately I had only one
UITextView
to replace. Otherwise, this gets untenable.A quicker fix:
Add this code somewhere and then replace all storyboard instances to
FixedTextView
.Note: you will lose any attributes created in the storyboards. This could have serious implications (e.g. delegate setting, size, etc.)
Updated Solution: Update to Xcode 11.2.1. It works on iOS 11, 12 or 13 devices for me.
Refer to apple's documentation This update fixes a critical issue that could cause apps using UITextView to crash.
Old Solution: Downloaded Xcode 11.1 from https://developer.apple.com/download/more/ Switching back from 11.2 to 11.1 fixed the crash.
Also, for me even with Xcode 11.2, when I upgraded my iPhone to 13.2, that fixed the crash.
This issue was fixed in Xcode version 11.2.1, and called out in the release notes: