SwiftKickMobile / SwiftMessages

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

Crash on Xcode 11 GM #339

Closed eirikvaa closed 5 years ago

eirikvaa commented 5 years ago

We're making sure our application is compatible with iOS 13. Using Xcode 11 GM and SwiftMessages 7.0.0. This crashes and gives EXC_BAD_ACCESS:

let view = MessageView.viewFromNib(layout: .messageView)
view.titleLabel?.textColor = .lightGray

Also trying to access .bodyTitle, .button, et cetera crashes.

eirikvaa commented 5 years ago

Never mind, I did a Clean and it worked. Sorry! :')

Ezor commented 4 years ago

Hello, I still have this EXC_BAD_ACCESS issue on iOS 13.0 Simulator only

Using Xcode 11 GM

@objc open class Messenger : NSObject {
    @objc open class func showStatusBarMessage(_ msg: String, sender: UIViewController, selector: Selector) {
        let status = MessageView.viewFromNib(layout: .messageView)
        //status.button?.isHidden = true
        status.backgroundView.backgroundColor = UIColor.white
        status.iconImageView?.tintColor = UIColor(red: 0.11, green: 0.47, blue: 0.89, alpha: 1.0)
        status.iconImageView?.image = UIImage(named: "1567-refresh-2")
        //status.iconImageView?.isHidden = true
        status.configureDropShadow()
        status.titleLabel?.isHidden = true
        status.bodyLabel?.textColor = UIColor.black
        status.iconLabel?.isHidden = true
        //[UIColor colorWithRed:0.11 green:0.47 blue:0.89 alpha:1.0]
        status.button?.setTitleColor(UIColor(red: 0.11, green: 0.47, blue: 0.89, alpha: 1.0), for: .normal)
        //status.button?.setTitle(R.string.localizable.close(), for: .normal)
        status.button?.setTitle("Télécharger", for: .normal)
        status.button?.addTarget(sender, action: selector, for: .touchUpInside)
        status.configureContent(body: msg)

        var statusConfig = SwiftMessages.defaultConfig
        statusConfig.presentationStyle = .bottom
        //statusConfig.presentationContext = .window(windowLevel: UIWindowLevelNormal)
        statusConfig.duration = .seconds(seconds: 4)
        SwiftMessages.show(config: statusConfig, view: status)
    }

    @objc open class func hide() {
        SwiftMessages.hide()
    }
}
wtmoose commented 4 years ago

@Ezor please make sure you’re on SwiftMessages 7.0.1, clean your project, and let me know what line of code is crashing.

A couple of unrelated tips:

  1. On Github, use ````swift at the beginning of your code block to enable syntax highlighting (as you can see above – I edited your post).
  2. You can eliminate most of the code in showStatusBarMessage by copying MessageView.nib into your project and modifying it directly (e.g. just delete elements you aren’t using, change colors, adjust margins, etc.).
Ezor commented 4 years ago

I just found the issue. My project was set to compile using Swift 4.2. I set to use Swift 5.0 (as SwiftMessages) and the problem is gone.