With the recent update on Xcode 9 Beta and iOS11 preview, there are some changes to SFSafariViewController init
methods.
@available(iOS 11.0, *)
public init(url URL: URL, configuration: SFSafariViewController.Configuration)
@available(iOS, introduced: 9.0, deprecated: 11.0)
public convenience init(url URL: URL, entersReaderIfAvailable: Bool)
There is one new init
method that is supported from iOS11 onwards while the currently available init method will be deprecated by iOS11. The problem is that the current method is not exposed and could not be overwritten. This forces the use of the new init
method if we want to use the beta to run the existing project. Has anyone found a way to use the existing init
method in the new Xcode Beta?
Edit: For clarification, this is a snippet of the init
method in my subclass
class BPSafariViewController: SFSafariViewController {
override init(url URL: URL, entersReaderIfAvailable: Bool) {
super.init(url: URL, entersReaderIfAvailable: entersReaderIfAvailable)
if #available(iOS 10.0, *) {
preferredControlTintColor = UIColor.BPUIColor()
} else {
view.tintColor = UIColor.BPUIColor()
}
}
}
I have found a possible solution relying on another convenience
method. Although I cannot use entersReaderIfAvailable
option, it works for my app for now.
convenience init(url URL: URL) {
self.init(url: URL)
//code
}