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

image not loaded correctly from real device #55

Closed
jaimeagudo opened this issue Jan 9, 2017 · 10 comments
Closed

image not loaded correctly from real device #55

jaimeagudo opened this issue Jan 9, 2017 · 10 comments

Comments

@jaimeagudo
Copy link

The following code works just fine (except for the warning I mentioned on #53) on the simulator

      let config = SwiftMessages.defaultConfig()
        config.presentationStyle = style
        config.dimMode = .gray(interactive: true)
        config.duration = .forever


        
        let view = MessageView.viewFromNib(layout: .CardView )
        view.configureTheme(.info)
        view.configureDropShadow()
        // Hide when message view tapped
        view.tapHandler = { _ in
            SwiftMessages.hide()
        }

        // image with an emoji character.
        let iconText = ":wink:".emojiUnescapedString
        view.configureContent(title: title, body: body, iconImage: nil, iconText: iconText, buttonImage: nil, buttonTitle: "Got it", buttonTapHandler: { _ in
            SwiftMessages.hide()
        })
        SwiftMessages.show(config: config, view: view)

However on the real device it makes the app to crash with this error

Could not load the "errorIcon" image referenced from a nib in the bundle with identifier "org.cocoapods.SwiftMessages"

First of all it's weird is moaning about the error icon when the requested would be the info one
(if any) it seems to ignore that iconImage: nil on the parameters list

Anyway I checked out it's in the assets file and I even have dropped a UIViewController with an image referring that same icon to check it's present within the app assets, I can see the image just fine on the storyboard referring it from the IB but it fails to resolve at runtime, in the simulator or the real device.

Thanks for your time guys

@jaimeagudo
Copy link
Author

screen shot 2017-01-09 at 10 15 11
screen shot 2017-01-09 at 10 15 44

@wtmoose
Copy link
Member

wtmoose commented Jan 9, 2017

Make sure you're on CocoaPods 1.0.1 or later. If not, update CocoaPods, do a full clean, pod install, and try again.

@jaimeagudo
Copy link
Author

Thanks for replying so fast @wtmoose ! I got Installing SwiftMessages 3.1.3, pod --version 1.1.1 but it didn't help.

I copied and pasted the assets to my project and now I see the UImageView I manually added to a UIViewController but nothing changed regarding the SwiftMessages, it keeps searching the assets from the "org.cocoapods.SwiftMessages" bundle, going to copy over the .xib for now

@jaimeagudo
Copy link
Author

this is my clean script btw, it didn't help neither

$ cat ./clean.sh 
#!/bin/sh
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/library/Developer/Xcode/DerivedData/*

@jaimeagudo
Copy link
Author

copying over the whole project doesn't work neither :\

Unknown class _TtC13SwiftMessages11MessageView in Interface Builder file.
2017-01-09 11:32:27.746 myApp[3353:589959] Failed to set (bounceAnimationOffset) user defined inspected property on (UIView): [<UIView 0x125abadf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key bounceAnimationOffset.
2017-01-09 11:32:27.747 myApp[3353:589959] Failed to set (statusBarOffset) user defined inspected property on (UIView): [<UIView 0x125abadf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key statusBarOffset.
2017-01-09 11:32:27.749 myApp[3353:589959] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x125abadf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key backgroundView.'
*** First throw call stack:
(0x182828f5c 0x197d13f80 0x182828c1c 0x18369f534 0x188088b08 0x18822b4b8 0x182752acc 0x188229ea0 0x18822c12c 0x1001a7804 0x1001a7bdc 0x100158558 0x10010e858 0x1001b12d0 0x1000f6eb4 0x1000f6b18 0x1000f6c10 0x18081c1d8 0x1880c7c10 0x1881e4000 0x1880cadf8 0x187eab0a4 0x187eaae90 0x187eaa974 0x18081e1a4 0x187eaa4d4 0x187db9324 0x187db91ac 0x18084429c 0x187589040 0x102489d30 0x10248f780 0x1827e0258 0x1827de0c0 0x18270cdc0 0x18dba8088 0x187de6f60 0x100154280 0x1985328b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

@jaimeagudo
Copy link
Author

My device is jailbroken, I didn't realise of #12 despite I used the github search upfront. 👎 for github search, will try that branch and let you know how it goes.

@jaimeagudo
Copy link
Author

the jailbreak1 is pretty old, I tried to just copy over the Resources folder with the .nib & png to the latest master and it doesn't work neither but now I get just a fatal error: unexpectedly found nil while unwrapping an Optional value.

I personally don't see why it would be better to scale super precisely to any screen resolution for optional icons that may or may not appear for a few seconds vs. making an app crash because of an auxiliary feature on jailbroken devices which are not a few https://www.quora.com/What-percentage-of-iPhones-have-been-jailbroken. Just suggesting, thanks A LOT for sharing your work anyway

@jaimeagudo
Copy link
Author

Btw, I removed the reference to the icons on the .nib's UIImageViews on my tests, no luck, so I drop it here

@wtmoose
Copy link
Member

wtmoose commented Jan 9, 2017

SwiftMessages doesn't attempt to find the included images in the main bundle, so I would not be surprised if this line doesn't work for you:

view.configureTheme(.info)

A workaround would be to replace the above line with your own configure method that sets the colors, icons, etc. to your liking.

I didn't understand your comment about scaling super precisely.

@wtmoose
Copy link
Member

wtmoose commented Jan 13, 2017

Closing this as a duplicate of #9.

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

2 participants