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

swift messages error #128

Closed
Ahmedshubber opened this issue Oct 5, 2017 · 16 comments
Closed

swift messages error #128

Ahmedshubber opened this issue Oct 5, 2017 · 16 comments

Comments

@Ahmedshubber
Copy link

@srstanic @defagos @raven @qx89l4 @triskybro I updated this project using cocoapods to the latest version after upgrading to xcode 9. I use swiftmessages all over my project and this is by far the best alert I've ever seen. The old version worked perfectly but this version crashes when I try to display the alert. can you help me. I think there is a bug in this project.

@wtmoose
Copy link
Member

wtmoose commented Oct 5, 2017

Please provide the relevant code and the crash log.

@logicsb
Copy link

logicsb commented Oct 5, 2017

I've same error. In my case, the crash is on Theme.swift line 37.
I think that the path of the images are wrong and return a nil UIImage.

    /// Returns the associated image.
    public var image: UIImage {        
        return UIImage(named: rawValue, in: Bundle.sm_frameworkBundle(), compatibleWith: nil)!
    }

@wtmoose
Copy link
Member

wtmoose commented Oct 5, 2017

Does the demo project work?

@Ahmedshubber
Copy link
Author

Ahmedshubber commented Oct 5, 2017 via email

@wtmoose
Copy link
Member

wtmoose commented Oct 5, 2017

I'm asking you and/or @logicsb to test the demo project and tell me if it works.

It doesn't crash for me, so I'm going to need you to work with me to figure out what's going on. I can't do anything with the limited amount of information you've given me so far.

  1. Whats the stack trace?
  2. What device or simulator are you using?
  3. What Xcode build are you using?
  4. What version of CocoaPods are you using?
  5. Have you tried deleting your derived data?
  6. Have you tried reinstalling pods?
  7. What does your SwiftMessages code look like?
  8. Can you send me a sample project that crashes?

@ajithrnayak
Copy link

I'm seeing this crash as well. It crashes since following line returns nil and is force unwrapped.
UIImage(named: rawValue, in: Bundle.sm_frameworkBundle(), compatibleWith: nil)

I'm using Xcode 9 and iPhone 8 - iOS 11.0 simulator. Cocoapod version 1.3.1.
I tried reproducing using the demo project as well as by using the pod in a single view new sample project. It didn't crash!
Not sure what is wrong here! Is it possible Xcode doesn't recognises images from Asset catalog for some reasons?

@wtmoose
Copy link
Member

wtmoose commented Oct 15, 2017

@ajithrnayak The original poster hasn't provided a stack trace, so I have no reason to believe that you are seeing the same crash.

But, I suggest clearing your derived data and doing a pod install. If it still crashes, grab the SwiftMessages.framework file out of the derived data and attach it here so I can take a look.

@ajithrnayak
Copy link

@wtmoose Here's the stack trace

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x000000011243a060 libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage(Swift.StaticString, Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 96
  * frame #1: 0x000000010eed1126 SwiftMessages`Icon.image.getter(self=info) at Theme.swift:37
    frame #2: 0x000000010eed4e54 SwiftMessages`IconStyle.image(theme=info, self=default) at Theme.swift:52
    frame #3: 0x000000010eea28fc SwiftMessages`MessageView.configureTheme(theme=info, iconStyle=default, self=0x00007f980af04e50) at MessageView.swift:256
    frame #4: 0x000000010735f884 App-Dev`StatusBanner.showBanner(config=App_Dev.StatusBannerConfig @ 0x00007fff58f1d230, tapHandler=nil, self=0x00007f9811916a00) at StatusBanner.swift:73
    frame #5: 0x000000010724b9cb App-Dev`BlueprintEditorViewController.showAlertBanner(message="In order to get started you need to create or select a report above", autoHide=true, self=0x00007f9811916a00) at BlueprintEditorViewController.swift:581

I suggest clearing your derived data and doing a pod install
Tried it before posting. Also, updated to latest release version. I made a hot fix by setting iconStyle to none.

Attaching the SwiftMessages.framework file here.
SwiftMessages.framework.zip

@woyhat
Copy link

woyhat commented Nov 3, 2017

It seems that it's all related: #96, #12, #31, #55, #9. I have the same problem. It crashes with Could not load the "errorIcon" image referenced from a nib in the bundle with identifier "org.cocoapods.SwiftMessages" on return UIImage(named: rawValue, in: Bundle.sm_frameworkBundle(), compatibleWith: nil)!
My device is not jailbroken, Xcode 9.0.1 (9A1004), Cocoapods 1.2 (I use Cocoapods app).

@wtmoose
Copy link
Member

wtmoose commented Nov 3, 2017

@woyhat @ajithrnayak could one of you guys step through the sm_frameworkBundle and tell me which line it returns on? It would be helpful to know if the correct bundle is being found. (It should return on line 15 for a CocoaPods install).

@wtmoose
Copy link
Member

wtmoose commented Nov 3, 2017

@woyhat @ajithrnayak I have created a branch work/assets with errorIcon moved out of the asset catalog. If someone can validate both of the following test scenarios, I will move all assets out of the catalog:

  1. Verify that the statement Icon.error.image DOESN'T crash the app.
  2. Verify that the statement Icon.warning.image DOES crash the app.

@woyhat
Copy link

woyhat commented Nov 3, 2017

@wtmoose yes, correct bundle is being found - SwiftMessages.bundle at if let on line 15. And yes, the branch fixes the crash, as errorIcon can be found in SwiftMessages.bundle directly. It doesn't find warningIcon in SwiftMessages.bundle/Assets.car. Any ideas why?

@wtmoose
Copy link
Member

wtmoose commented Nov 3, 2017

@woyhat I don't know. You can try running this from your bundle folder and see if the images are there:

xcrun --sdk iphoneos assetutil --info Assets.car

I did this for the framework attached above and errorIcon is there. So my best guess is it's either caused by certain project configurations or an iOS bug.

@wtmoose
Copy link
Member

wtmoose commented Nov 5, 2017

Fix on head of master if anyone wants to verify.

@woyhat
Copy link

woyhat commented Nov 6, 2017

As expected it fixes the issue. I've just verified it by switching between 4.0.0 and 4.0.1.

@wtmoose
Copy link
Member

wtmoose commented Nov 15, 2017

Fixed in 4.1.0 release

@wtmoose wtmoose closed this as completed Nov 15, 2017
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

5 participants