SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 742 forks source link

Crash when loading XIBs #427

Closed cuba closed 3 years ago

cuba commented 3 years ago

When attempting to call the following:

let view = MessageView.viewFromNib(layout: .cardView)
var config = SwiftMessages.Config()
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
SwiftMessages.show(config: config, view: view)

The following exception is triggered:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <hidden> (loaded)' with name 'CardView''
terminating with uncaught exception of type NSException
CoreSimulator 732.18.0.2 - Device: iPod touch (7th generation) (17E36CA3-C244-41C1-A96D-96ED6137EC65) - Runtime: iOS 14.2 (18B5072e) - DeviceType: iPod touch (7th generation)

I don't personally use XIBs. But when loading resources in SPM you need to use Bundle.module to load resources. Not sure if this falls under this category.

There is also this PR which may be a solution to the issue: https://github.com/SwiftKickMobile/SwiftMessages/pull/424

wtmoose commented 3 years ago

What version of SwiftMessages are you using and how is it installed (e.g. CocoaPods, etc.)?

fbernaly commented 3 years ago

@wtmoose : I think I am getting the same error, I am updating my app, using Xcode 12.1, and SwiftMessages v8.0.2.

This is what the Xcode error says:

Compile XIB file CardView.xib

Failed to find or create execution context for description '<IBCocoaTouchPlatformToolDescription: 0x7fca31df1570> System content for IBCocoaTouchFramework-NineOneAndLater <IBScaleFactorDeviceTypeDescription: 0x7fca31d4d760> scaleFactor=2x, renderMode.identifier=(null)'.

Looking forward for #424 to be merged.

wtmoose commented 3 years ago

@fbernaly you didn't provide the info I asked for.

fbernaly commented 3 years ago

@wtmoose Xcode 12.1 SwiftMessages: v8.0.2. installed: Cocoapods iOS14

BTW, I cloned @cuba's branch (for #424) and changed my pod file to point to the path of the local copy, and that does not fix my issue.

wtmoose commented 3 years ago

@cuba if you’re using SPM, you’ve either got to following the instructions in #395 or use the unreleased version on the work/xcode12 branch.

wtmoose commented 3 years ago

Not sure what issue you're having, but try 8.0.3. I've tested it with CocoaPods, SPM and Carthage.

cuba commented 3 years ago

Yes, I see that there is a fix to the issue. Hopefully you guys will merge this fix sooner than later.