Xcode:此编码器要求从initWithCoder返回替换的对象:

时间:2019-04-07 07:00:33

标签: ios swift

我正在用Swift 4.2编写iOS应用。

我用Xcode 10.1编写了它。 现在我更新到Xcode 10.2。 清除缓存>删除的派生数据文件夹>重建项目。

当我运行该项目时,它显示错误:

  

此编码器要求从initWithCoder返回替换的对象:

行: AppDelegate:

   private func configureInitialViewController()
    {
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = RootViewController()
        window?.makeKeyAndVisible()
    }

RootViewController:

  init() {
        Log.i("Show splash screen")
        if(!appDelegate().isShortCutNavigation){
            current = AppStoryboard.Main.viewController(viewControllerClass: SplashViewController.self)
        }else{
            current=appDelegate().baseNavigationController!
        }
        super.init(nibName:  nil, bundle: nil)
    }

它在这里崩溃:

 window?.makeKeyAndVisible()

StackTrace:

2019-04-07 12:29:10153 [RootViewController.swift]:37 15 init() -> Show splash screen
topDistance: 20.0
2019-04-07 12:29:19.046312+0530 Mutual Fund Development[6357:48600] [LayoutConstraints] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x600003853070 Macaw.SVGView:0x7fc2f1f208c0.width == 96   (inactive)>
    When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
2019-04-07 12:29:19.046534+0530 Mutual Fund Development[6357:48600] [LayoutConstraints] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x6000038530c0 Macaw.SVGView:0x7fc2f1f208c0.width == Macaw.SVGView:0x7fc2f1f208c0.height   (inactive)>
    When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
2019-04-07 12:29:19.090004+0530 Mutual Fund Development[6357:48600] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001156096fb __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x0000000113826ac5 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000115609555 +[NSException raise:format:] + 197
    3   UIFoundation                        0x000000011b5b589c UINibDecoderDecodeObjectForValue + 827
    4   UIFoundation                        0x000000011b5b5af9 UINibDecoderDecodeObjectForValue + 1432
    5   UIFoundation                        0x000000011b5b5554 -[UINibDecoder decodeObjectForKey:] + 251
    6   UIKitCore                           0x000000011e10b705 -[UIView initWithCoder:] + 802
    7   UIFoundation                        0x000000011b5b5852 UINibDecoderDecodeObjectForValue + 753
    8   UIFoundation                        0x000000011b5b5554 -[UINibDecoder decodeObjectForKey:] + 251
    9   UIKitCore                           0x000000011d8f0b41 -[UIRuntimeConnection initWithCoder:] + 178
    10  UIFoundation                        0x000000011b5b5852 UINibDecoderDecodeObjectForValue + 753
    11  UIFoundation                        0x000000011b5b5af9 UINibDecoderDecodeObjectForValue + 1432
    12  UIFoundation                        0x000000011b5b5554 -[UINibDecoder decodeObjectForKey:] + 251
    13  UIKitCore                           0x000000011d8ee3f1 -[UINib instantiateWithOwner:options:] + 1216
    14  UIKitCore                           0x000000011d66b3af -[UIViewController _loadViewFromNibNamed:bundle:] + 382
    15  UIKitCore                           0x000000011d66bd39 -[UIViewController loadView] + 177
    16  UIKitCore                           0x000000011d66c048 -[UIViewController loadViewIfRequired] + 172
    17  UIKitCore                           0x000000011d66c868 -[UIViewController view] + 27
    18  Mutual Fund Development             0x000000010f47af82 $s23Mutual_Fund_Development18RootViewControllerC11viewDidLoadyyF + 706
    19  Mutual Fund Development             0x000000010f47b454 $s23Mutual_Fund_Development18RootViewControllerC11viewDidLoadyyFTo + 36
    20  UIKitCore                           0x000000011d66c43b -[UIViewController loadViewIfRequired] + 1183
    21  UIKitCore                           0x000000011d66c868 -[UIViewController view] + 27
    22  UIKitCore                           0x000000011dca4c33 -[UIWindow addRootViewControllerViewIfPossible] + 122
    23  UIKitCore                           0x000000011dca5327 -[UIWindow _setHidden:forced:] + 289
    24  UIKitCore                           0x000000011dcb7f86 -[UIWindow makeKeyAndVisible] + 42
    25  Mutual Fund Development             0x000000010f6df815 $s23Mutual_Fund_Development11AppDelegateC30configureInitialViewController33_37D752FE1FBE453CFB8DA463593A941BLLyyF + 533
    26  Mutual Fund Development             0x000000010f6de2d8 $s23Mutual_Fund_Development11AppDelegateC18didFinishLaunching33_37D752FE1FBE453CFB8DA463593A941BLLySbSDySo29UIApplicationLaunchOptionsKeyaypGSg_So0O0CtF + 1544
    27  Mutual Fund Development             0x000000010f6d95ac $s23Mutual_Fund_Development11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtF + 60
    28  Mutual Fund Development             0x000000010f6d9684 $s23Mutual_Fund_Development11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtFTo + 196
    29  UIKitCore                           0x000000011dc66311 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 280
    30  UIKitCore                           0x000000011dc67cad -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3932
    31  UIKitCore                           0x000000011dc6d0c6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1617
    32  UIKitCore                           0x000000011d4b26d6 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 904
    33  UIKitCore                           0x000000011d4bafce +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
    34  UIKitCore                           0x000000011d4b22ec -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
    35  UIKitCore                           0x000000011d4b2c48 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1091
    36  UIKitCore                           0x000000011d4b0fba __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 782
    37  UIKitCore                           0x000000011d4b0c71 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433
    38  UIKitCore                           0x000000011d4b59b6 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 576
    39  UIKitCore                           0x000000011d4b6610 _performActionsWithDelayForTransitionContext + 100
    40  UIKitCore                           0x000000011d4b571d -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223
    41  UIKitCore                           0x000000011d4ba6d0 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
    42  UIKitCore                           0x000000011dc6b9a8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 514
    43  UIKitCore                           0x000000011d822dfa -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
    44  FrontBoardServices                  0x0000000120a43125 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
    45  FrontBoardServices                  0x0000000120a4ced6 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 283
    46  FrontBoardServices                  0x0000000120a4c700 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
    47  libdispatch.dylib                   0x0000000116c0bdb5 _dispatch_client_callout + 8
    48  libdispatch.dylib                   0x0000000116c0f2ba _dispatch_block_invoke_direct + 300
    49  FrontBoardServices                  0x0000000120a7e146 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
    50  FrontBoardServices                  0x0000000120a7ddfe -[FBSSerialQueue _performNext] + 451
    51  FrontBoardServices                  0x0000000120a7e393 -[FBSSerialQueue _performNextFromRunLoopSource] + 42
    52  CoreFoundation                      0x0000000115570be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    53  CoreFoundation                      0x0000000115570463 __CFRunLoopDoSources0 + 243
    54  CoreFoundation                      0x000000011556ab1f __CFRunLoopRun + 1231
    55  CoreFoundation                      0x000000011556a302 CFRunLoopRunSpecific + 626
    56  GraphicsServices                    0x000000011b2592fe GSEventRunModal + 65
    57  UIKitCore                           0x000000011dc6eba2 UIApplicationMain + 140
    58  Mutual Fund Development             0x000000010f6e0fcb main + 75
    59  libdyld.dylib                       0x0000000116c80541 start + 1
    60  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

2 个答案:

答案 0 :(得分:0)

尝试一下,我认为您没有提供情节提要标识符名称。

    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let rootViewController = storyboard.instantiateViewControllerWithIdentifier("YourStoryboardID")

    self.window?.rootViewController = rootViewController
    self.window?.makeKeyAndVisible()

希望这会有所帮助。

答案 1 :(得分:0)

在我的情况下,我正在使用“ InputMask”库 我必须将广告连播更新为pod 'InputMask', '4.3.0'版,这对我来说就是解决方案。

我希望这会有所帮助。