corin8823 / Popover

Popover is a balloon library like Facebook app. It is written in pure swift.
MIT License
2.11k stars 327 forks source link

Build Error #70

Closed BhaktiKarva closed 7 years ago

BhaktiKarva commented 7 years ago

Helo, I just installed version 1.0.4 because I am using Swift 3.0 I tried to build the project but it gives me error in the Popover.swift file at - self.showAsDialog(contentView, inView: UIApplication.shared.keyWindow!) error - 'shared' is unavailable. Use view controller based solutions where appropriate instead.

Please help.

BhaktiKarva commented 7 years ago

1

corin8823 commented 7 years ago

Can I call UIApplication.shared on your project. If it can not be called, there is a possibility that it is not swift3.0

BhaktiKarva commented 7 years ago

I checked and I cannot call UIApplication.shared. Actually I am using this in a custom-keyboard extension and not in the main app. Is that why I am facing this issue?

BhaktiKarva commented 7 years ago

How can I change it to use in the keyboard extension. any help would be greatly appreciated.

corin8823 commented 7 years ago

https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionOverview.html#//apple_ref/doc/uid/TP40014214-CH2-SW2

Access a sharedApplication object, and so cannot use any of the methods on that object

corin8823 commented 7 years ago

You may be able to build it if you delete the code below

  open func showAsDialog(_ contentView: UIView) {
    guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else {
        return
    }
    self.showAsDialog(contentView, inView: rootView)
  }

  open func show(_ contentView: UIView, fromView: UIView) {
    guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else {
        return
    }
    self.show(contentView, fromView: fromView, inView: rootView)
  }
BhaktiKarva commented 7 years ago

But will it work as expected?

corin8823 commented 7 years ago

Internally it gets the key window and just calls the following func show(_ contentView: UIView, fromView: UIView, inView: UIView)

BhaktiKarva commented 7 years ago

So i can call this function instead of show(_ contentView: UIView, fromView: UIView) to show the popup?

BhaktiKarva commented 7 years ago

It works 👍 Thank you so much :)

corin8823 commented 7 years ago

very good! It may correspond in the future for app extension.