我的应用程序在模拟器上运行完美,但是当我在我的物理设备上启动它时,我得到了这个异常:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/E1868188-8412-40F9-AD77-B4CA9DA47415/Aremiti.app> (loaded)' with name '0mX-RV-bpN-view-yyb-5A-n89''
*** First throw call stack:
(0x184b52fe0 0x1835b4538 0x184b52f28 0x18b18a600 0x18afeb2d4 0x18adb546c 0x18ad84c6c 0x18ac83b68 0x18ac83a9c 0x1000e5494 0x1000e34a4 0x1000e3524 0x18b18b8d8 0x18b2d9a50 0x18b2d9790 0x18b18b57c 0x18b18bd1c 0x18b2d9a50 0x18b2d9bc8 0x18b2d9790 0x18b18a8bc 0x18b444f54 0x18af08488 0x18acf4e94 0x18af070c4 0x18af1bd18 0x18af04474 0x1866fb884 0x1866fb6f0 0x1866fbaa0 0x184b0142c 0x184b00d9c 0x184afe9a8 0x184a2eda4 0x18acee384 0x18ace9058 0x1000f62b8 0x183a3d59c)
libc++abi.dylib: terminating with uncaught exception of type NSException
我知道在 xcode 之外更改文件名时可能会抛出此错误。但是,我没有触及任何文件名。
最佳答案
let customView = Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?[0] as! myClass
你的 Nib 名称可能是错误的......请检查你的 Nib 名称..你应该在 loadNibNamed
中包含 SomeNib.xib
您还应该检查您的 SomeNib.xib
是否复制到项目目标的 Build Phases
部分的 Copy Bundle Resources
中?
关于swift - 无法在 bundle 中加载 NIB - swift 3(仅限物理设备),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44770042/