0

I try to use SwiftMessages into my Swift iOS project.

SwiftMessages has been installed with pod in version 6.0

When I use a sample code like this :

    let error = MessageView.viewFromNib(layout: .cardView)
    error.configureTheme(.error)
    error.configureContent(title: "Error", body: "Something is horribly wrong!")
    error.button?.setTitle("Stop", for: .normal)
    SwiftMessages.show(view: error)

Until now, it's ok !

But when I try to use SwiftMessages.Config() or SwiftMessages.defaultConfig like this :

    let warning = MessageView.viewFromNib(layout: .cardView)
    warning.configureTheme(.warning)
    warning.configureDropShadow()

    let iconText = ["", "", "", ""].sm_random()!
    warning.configureContent(title: "Warning", body: "Consider yourself warned.", iconText: iconText)
    warning.button?.isHidden = true
    var warningConfig = SwiftMessages.defaultConfig
    warningConfig.presentationStyle = .top
    //warningConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
    SwiftMessages.show(config: warningConfig, view: warning)

I obtain an Exec Bad Access on the SwiftMessages.show(config: warningConfig, view: warning)

More over, it does not recognize the property presentationContext, that's why the line is in comment in my code. However this property is listed here : https://github.com/SwiftKickMobile/SwiftMessages

So, is there something wrong in my code, or is there a bug inside the framework ?

gduh
  • 1,079
  • 12
  • 30
  • Looks like you have some derived data related to newest version of pod. Try to clean up derived data or implicitly specify pod namespace before calling config func. – hbk Oct 05 '18 at 15:51
  • I already tried to clean my project and derived data without any success. – gduh Oct 05 '18 at 18:43
  • Try pod install without SwiftyMessage pod and then within – hbk Oct 05 '18 at 19:02
  • Thanks for your help, finally as suggesting by @Timothy it was a problem with compatibility Swift's version. – gduh Oct 05 '18 at 19:16

1 Answers1

4

Sounds like your app is on Swift 4.1 or lower. The Swift compatibility is as follows:

  • Swift 4.2 -> SwiftMessages 6
  • Swift 4.1 or lower -> SwiftMessages 5
Timothy Moose
  • 9,895
  • 3
  • 33
  • 44