如何解决 NSInternalInconsistencyException: 原因: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'

How to solve NSInternalInconsistencyException: reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'

我在使用 OPPWAMobile 支付库时得到一个 NSInternalInconsistencyException。我需要以某种方式将 name 传递给 OPPPaymentSchemeViewController,以便它传递给 initWithNibName。但我不确定如何在 Xcode.

中做到这一点

我已经检查过这个 stack overflow solution 但没有帮助,因为我没有直接访问视图控制器的权限。

我确定 nib 名称是某个 属性 文件的一部分,但我找不到它。

关于如何做到这一点有什么想法吗?

2021-06-22 08:24:27.468604+0300 Runner[6738:85985] *** Assertion failure in -[UINib initWithNibName:directory:bundle:], UINib.m:97
2021-06-22 08:25:12.078452+0300 Runner[6738:85985] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff20422fba __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff20193ff5 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff20422de3 +[NSException raise:format:] + 0
    3   Foundation                          0x00007fff207748e7 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
    4   UIKitCore                           0x00007fff242b63de -[UINib initWithNibName:directory:bundle:] + 309
    5   UIKitCore                           0x00007fff242b6489 +[UINib nibWithNibName:bundle:] + 76
    6   OPPWAMobile                         0x00000001067e9736 -[OPPPaymentSchemeViewController registerTableViewCellNibs] + 153
    7   OPPWAMobile                         0x00000001067e9389 -[OPPPaymentSchemeViewController viewDidLoad] + 157
    8   UIKitCore                           0x00007fff23f806a9 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 88
    9   UIKitCore                           0x00007fff23f8504c -[UIViewController loadViewIfRequired] + 1084
    10  UIKitCore                           0x00007fff23f85436 -[UIViewController view] + 27
    11  UIKitCore                           0x00007fff23ec6559 -[UINavigationController _preferredContentSizeForcingLoad:] + 198
    12  UIKitCore                           0x00007fff23e64354 -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 64
    13  UIKitCore                           0x00007fff23e6018f __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.466 + 178
    14  UIKitCore                           0x00007fff24bb1e36 -[_UIAfterCACommitBlock run] + 54
    15  UIKitCore                           0x00007fff246d01f8 _runAfterCACommitDeferredBlocks + 333
    16  UIKitCore                           0x00007fff246c01e4 _cleanUpAfterCAFlushAndRunDeferredBlocks + 221
    17  UIKitCore                           0x00007fff246f1a36 _afterCACommitHandler + 85
    18  CoreFoundation                      0x00007fff2038fd31 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    19  CoreFoundation                      0x00007fff2038a542 __CFRunLoopDoObservers + 541
    20  CoreFoundation                      0x00007fff2038aaf5 __CFRunLoopRun + 1129
    21  CoreFoundation                      0x00007fff2038a1a7 CFRunLoopRunSpecific + 567
    22  GraphicsServices                    0x00007fff2b874d85 GSEventRunModal + 139
    23  UIKitCore                           0x00007fff246c14df -[UIApplication _run] + 912
    24  UIKitCore                           0x00007fff246c639c UIApplicationMain + 101
    25  Runner                              0x00000001064fec8b main + 75
    26  libdyld.dylib                       0x00007fff2025abbd start + 1
)
libc++abi: terminating with uncaught exception of2021-06-22 08:25:12.691736+0300 Runner[6738:88777] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
 type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'
terminating with uncaught exception of type NSException

我发现了问题。我需要在 Target->General->Frameworks, Libraries and Embedded Content 下将 OPPWAMobile.xcframework 标记为“嵌入并签名”。

当我阅读 Apple documentation 关于 nibName 为 nil 时 initWithNibName:bundle: 的行为时,我怀疑这可能是问题所在。

If you specify nil for the nibName parameter and you do not override the loadView method, the view controller searches for a nib file as described in the nibName property.

这意味着我遇到了异常,因为框架找不到必要的 nib 文件。

您已在项目中添加 OPPWAMobile-Resources.bundle