本文翻譯自:After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView
After upgrading to Xcode 11.2 from Xcode 11.1 my app crashes: 從Xcode 11.1升級到Xcode 11.2之後,我的應用崩潰了:
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found; ***由於未捕獲的異常'NSInvalidUnarchiveOperationException'而終止應用程序,原因:'由於未找到名爲_UITextLayoutView的類,因此無法實例化名爲_UITextLayoutView的類; 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? 如何防止此崩潰?
參考:https://stackoom.com/question/3y7O3/從Xcode-升級到Xcode-後-由於-UITextLayoutView-應用程序崩潰
This is because of xCode update to 11.2 version. 這是因爲xCode更新到11.2版本。 Try with an older xCode version to see if is still crashing. 嘗試使用較舊的xCode版本,以查看是否仍然崩潰。 Apple don't have a fix for this yet. 蘋果尚未對此進行修復。
在低於iOS 13的版本上進行測試時,它與通過Storyboard添加的UITextView有關。我認爲這是Xcode 11.2中的錯誤,因爲以前的版本沒有問題。
在iOS 13.1上看到相同的問題...在iOS 13.2上工作正常
As a "quick" fix you can add the UITextView
directly from the code and not via IB. 作爲「快速」修復,您可以直接從代碼中而不是通過IB添加UITextView
。 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. 雖然從我的角度來看,最好回滾到以前的Xcode /等待新的Xcode。
This bug is fixed in Xcode 11.2.1. 此錯誤已在Xcode 11.2.1中修復 。 So you can download and use it from here. 因此,您可以從此處下載並使用它。
Storyboards containing a UITextView will no longer cause the app to crash on operating system versions earlier than iOS 13.2, tvOS 13.2, or macOS 10.15.2. 包含UITextView的情節提要板將不再導致應用程序在iOS 13.2,tvOS 13.2或macOS 10.15.2之前的操作系統版本上崩潰。 (56808566, 56873523) (56808566,56873523)
if you ever try to submit your app that build with Xcode 11.2 to the AppStore, you will be rejected: 如果您曾經嘗試將使用Xcode 11.2構建的應用提交到AppStore,則將被拒絕:
App Store Connect Operation Warning App Store Connect操作警告
WARNING ITMS-90703 : "Deprecated Xcode Build. Due to resolved app archives issues, we have deprecated Xcode 11.2 on November 5, 2019. Download Xcode 11.2.1 or newer, rebuild your app and resubmit." 警告ITMS-90703 :「不建議使用Xcode Build。由於已解決的應用程序存檔問題,我們已於2019年11月5日棄用了Xcode 11.2。下載Xcode 11.2.1或更高版本,重建您的應用程序並重新提交。」
So all workarounds done with the Xcode 11.2 is useless 因此,使用Xcode 11.2完成的所有變通辦法都沒有用
Roll back to previous Xcode release version from: Rollback is not an option anymore and AppStore will reject any build with Xcode below 11.2.1 take a look at this 回滾到之前的Xcode 發佈版本從:回滾是不是一種選擇了和AppStore的將拒絕任何的Xcode構建以下11.2.1 看看這個
https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_11.1/Xcode_11.1.xiphttps://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_11.1/Xcode_11.1.xip
Note that you should use Safari to download it and you must first login to Apple developer portal . 請注意,您應該使用Safari下載它,並且必須首先登錄到Apple開發人員門戶 。
You can find all other Xcode versions and other resources link (including release and beta versions) here at https://developer.apple.com/download/more 您可以在https://developer.apple.com/download/more上找到所有其他Xcode版本和其他資源鏈接(包括髮行版和Beta版)。
This is very hard but working workaround. 這非常困難,但是可以解決。 Replace all UITextView
s in storyboard s and Xib s with the pure code version. 用純代碼版本替換Storyboard和Xib中的所有UITextView
。
Note that this bug is found and fixed by Apple 請注意,此錯誤已由Apple找到並修復。
Also earlier, the bug was confirmed by Apple Staff edford 同樣, 該錯誤已由Apple Staff edford確認
UITextView
子類UITextView
UITextView
objects 將其分配給所有UITextView
對象 Head to the @aftab muhammed khan answer for Objective-C and @MikRo answer for Swift adapted version 轉到Objective-C的@aftab muhammed khan 答案和Swift適應版本的 @MikRo 答案
Even if these last two swizzling workarounds are not using Apple private API , they will be rejected in AppStore because Apple will not accept builds with Xcode versions under 11.2.1 ! 即使這最後兩個麻煩的解決方法沒有使用Apple私有API ,它們也會在AppStore中被拒絕 ,因爲Apple不會接受11.2.1下的Xcode版本的構建 !
And once again: 再一次: