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

fix: fixed Xcode 14 build error #1238

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ios/Classes/Types/UserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ import WebKit

public class UserScript : WKUserScript {
var groupName: String?

private var contentWorldWrapper: Any?
@available(iOS 14.0, *)
lazy var contentWorld: WKContentWorld = WKContentWorld.page
var contentWorld: WKContentWorld {
get {
if let value = contentWorldWrapper as? WKContentWorld {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep lazy behaviour i'd suggest the following implementation

if contentWorldWrapper == nil {
    contentWorldWrapper = WKContentWorld.page
}
return contentWorldWrapper as! WKContentWorld

, but yours is safer

return value
}
return .page
}
set { contentWorldWrapper = newValue }
}


public override init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool) {
super.init(source: source, injectionTime: injectionTime, forMainFrameOnly: forMainFrameOnly)
Expand Down