Things take time

[Swift] Error : terminating with uncaught exception of type NSException[Xcode 11.2/iOS 13.2 미만 버전 앱 죽는 현상] 본문

iOS (기능)

[Swift] Error : terminating with uncaught exception of type NSException[Xcode 11.2/iOS 13.2 미만 버전 앱 죽는 현상]

겸손할 겸 2019. 11. 7. 16:51

[에러]

 

엑스코드, OS를 업데이트하고나서 앱들을 실행하다 앱이 죽는 현상 발견, 다행히 맥부기 카페에서 어떤 분이 알려주셨다.

 

https://stackoverflow.com/questions/58657087/after-upgrading-to-xcode-11-2-from-xcode-11-1-app-crashes-due-to-uitextlayoutv

 

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: *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named

stackoverflow.com

 

문제의 원인은 UITextLayoutView 클래스를 불러오지못해 나오는 문제라고하는데, 해결방법은 스택오버플로에 있다.


간단히, NSObject 상속 클래스를 만들고, static함수로 앱이 시작되는 AppDelegate의 didFinish 함수 제일 밑(리턴 전에) 함수를 호출한다.

import UIKit

@objc
class UITextViewError: NSObject {
    static func executeWorkaround() {
        if #available(iOS 13.2, *) {
        } else {
            let className = "_UITextLayoutView"
            let theClass = objc_getClass(className)
            if theClass == nil {
                let classPair: AnyClass? = objc_allocateClassPair(UIView.self, className, 0)
                objc_registerClassPair(classPair!)
            }
        }
    }
}
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        ...
        ...
        UITextViewError.executeWorkaround()
        return true
    }

추가

위의 코드로 수정, 컴파일은 문제 없으나 배포할 때, 해당 엑스코드 버전으로는 제출할 수 없으니 이전 것, 혹은 12.1.1을 사용하라고 한다.

어차피 12.1.1로 가면 해당 에러 사리질것 처럼 보인다. 알려진 이슈에서 말하듯

 

즉, 업데이트를 기다리자. 아니면 배포 전 업데이트를 해도 상관없겠다. 

 

https://developer.apple.com/download/

 

로그인 - Apple

 

idmsa.apple.com