Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load the "errorIcon" image referenced from a nib in the bundle with identifier #96

Closed
mink-lparrouy opened this issue Jun 1, 2017 · 13 comments

Comments

@mink-lparrouy
Copy link

mink-lparrouy commented Jun 1, 2017

Hello,

I installed your library to display messages to my users. It works fine until today, i have a problem because your library cannot find the errorIcon :

Could not load the "errorIcon" image referenced from a nib in the bundle with identifier "org.cocoapods.SwiftMessages"
fatal error: unexpectedly found nil while unwrapping an Optional value

Xcode 8.3.2, Swift 3, CocoaPods 2.1.0

Thank you for your response

@wtmoose
Copy link
Member

wtmoose commented Jun 1, 2017

Maybe the device is jailbroken? See #9

@mink-lparrouy
Copy link
Author

I am running the application on the xcode simulator

@wtmoose
Copy link
Member

wtmoose commented Jun 1, 2017

This error isn't typical, so it would be helpful if you could provide more information. A good start would be to send the relevant code. But it could very well be some issue with the project configuration and packaging of the resources in the library, in which case the code probably won't be too useful and I may need you to help me reproduce it on my end.

A few suggestions:

  • Delete your derived data and try again.
  • Take a look at what changed between when it was working and when you started getting the error.

As a workaround, you can avoid using any resources from the SwiftMessages library. One simple fix should be to copy the image asset into your project and set it on the message view's iconImageView property directly. Calling the MessageView's configure methods is absolutely optional.

@mink-lparrouy
Copy link
Author

This is my function :

func errorSwiftMessage(message: String) {
        let view = MessageView.viewFromNib(layout: .MessageView)
        view.button?.isHidden = true
        view.configureTheme(.error)
        view.configureDropShadow()
        //view.iconImageView?.image = UIImage(named: "errorIcon")
        view.configureContent(title: "Erreur", body: message)
        SwiftMessages.show(view: view)
    }

I try to delete derived data and even load the icon in the function but still the same.

@mink-lparrouy
Copy link
Author

It's strange if I use my function in viewDidLoad it works. But I want to use it in a UITapGestureRecognizer. Unfortunatly I get the error

@mink-lparrouy
Copy link
Author

Ok I copy the xib file of MessageView in my project and it works !

@wtmoose wtmoose closed this as completed Jun 1, 2017
@dimohamdy
Copy link

any one solve this bug

@ghost
Copy link

ghost commented Nov 2, 2017

Same bug here. I did solved by moving all assets in to my project assets and change Return associated image code like this.

/// Returns the associated image.
    public var image: UIImage {
        if let image = UIImage(named: rawValue, in: Bundle.sm_frameworkBundle(), compatibleWith: nil).  {
            return image
        } else if let image = UIImage.init(named: rawValue){
            return image
        } else {
            return UIImage.init()
        }
    }

@kushal211
Copy link

@wtmoose I'm having the same issue with the image. I've used SwiftMessages to so many projects and never faced this issue but right now facing image not found issue with one of the projects. I'm using cocoapod version 1.3.1

One more thing you said that you've moved out all the assets from assets folder and added them separately. I've tried installing it to new sample project but images are still under the assets and not able to get the image from the bundle. For now, I'm moving out the images to my bundle and changing above code in pod file.

@wtmoose
Copy link
Member

wtmoose commented Nov 7, 2017

I've tried installing it to new sample project but images are still under the assets and not able to get the image from the bundle.

The fix isn't released yet. Did you install the head of the master branch?

@kushal211
Copy link

kushal211 commented Nov 8, 2017

Did you install the head of the master branch?

No, not from the head.

@wtmoose
Copy link
Member

wtmoose commented Nov 8, 2017

@kushal211 well there's your problem.

@kushal211
Copy link

@wtmoose Thanks! I've installed it from Head and images are there and working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants