Coder Social home page Coder Social logo

rxwebkit's Introduction

RxWebKit

RxWebKit is a RxSwift wrapper for WebKit.

Carthage compatible Version License Platform

Example Usages

// MARK: Setup WKWebView

let webView = WKWebView(frame: self.view.bounds)
self.view.addSubview(webView)


// MARK: Observing properties

webView.rx.title
    .subscribe(onNext: {
        print("title: \($0)")
    })
    .disposed(by: disposeBag)

webView.rx.url
    .subscribe(onNext: {
        print("URL: \($0)")
    })
    .disposed(by: disposeBag)

Installation

CocoaPods

Add to Podfile:

pod 'RxWebKit'

Carthage

Add to Cartfile:

github "RxSwiftCommunity/RxWebKit"

Run carthage update --platform iOS

Add run script build phase /usr/local/bin/carthage copy-frameworks with input files being:

$(SRCROOT)/carthage/Build/iOS/RxWebKit.framework

Requirements

RxWebKit requires Swift 5.2.2 and dedicated versions of RxSwift 6.0.0

License

MIT

rxwebkit's People

Contributors

bobgodwinx avatar brenthargrave avatar daichiro avatar darquro avatar econa77 avatar freak4pc avatar jessehao avatar kchykt avatar mgor3k avatar monibu1548 avatar mrs- avatar neverwintermoon avatar shams-ahmed avatar shenyj avatar sy-hash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxwebkit's Issues

Question from RxSwift 5.0

Hello, I am using Pod RxWebKit when I am using RxSwift 5.0. The following is the error message:

屏幕快照 2019-05-15 上午9 44 25

I looked at the RxWebKit.podspec you wrote, s.version = "0.3.8", but I can only display it to version 0.3.7 using pod search RxWebKit, I swear I have pod setup CocoaPods ahead of time.

WX20190515-094722@2x

How can I solve it?

`webView.rx.didTerminate` crashed

webView.rx.didTerminate
            .do(onNext: { _ in log.error("didTerminate: subscribe") })
            .subscribe(onNext: { webView in webView.reload() })
            .disposed(by: rx.disposeBag)

When I run this codes in my Controller with webview crashed where the controller has not appeared!

If you use the properties implemented in RxWebKit together with the properties implemented in RxCocoa, it will crash.

Please check to the following log for the runtime.

2021-10-28 19:14:34.228664+0900 RxWebKitSample[2594:65726] RxCocoa/RxCocoa.swift:153: Fatal error: Failure converting from Optional(<RxCocoa.RxWKNavigationDelegateProxy: 0x600003ec4900>) to RxWKNavigationDelegateProxy
(lldb) 

The sample code is attached below.

import UIKit
import RxSwift
import RxCocoa
import RxWebKit
import WebKit

class ViewController: UIViewController {

    @IBOutlet weak var webView: WKWebView!
    let disposeBag = DisposeBag()

    override func viewDidLoad() {
        super.viewDidLoad()
        
        webView.load(URLRequest(url: URL(string: "https://google.com")!))
        
        webView.rx
            .didStartLoad // <- This property is implementing at the RxCocoa
            .subscribe { value in
                print("value: \(value)")
            }.disposed(by: disposeBag)
        
        webView.rx
            .didStartProvisionalNavigation // <- This property is implementing at the RxWebKit
            .asObservable()
            .subscribe { (webView: WKWebView, navigation: WKNavigation) in
                print("web: \(webView)")
                print("navigation: \(navigation)")
            }.disposed(by: disposeBag)
        // Do any additional setup after loading the view.
    }
}

The image of the runtime is attached below.

Screen Shot 2021-10-28 at 19 22 41

Error log bellow

Thread 1: Fatal error: Failure converting from Optional(<RxCocoa.RxWKNavigationDelegateProxy: 0x600003ec4900>) to RxWKNavigationDelegateProxy

Memory leak caused by invalid WKNavigationDelegateEvents

I am using RxWebKit 0.3.7 by Cocoapod 1.6.3, Xcode 11.1

While using RxWebkit, if the UINavigationDelegate observable is subcribed, the deinit is not called.

As a result of finding the cause, we found that the use of the "navigationEventWith" and "navigationFailEventWith" functions in the "WKNavigationDelegateEvents+Rx.swift" file resulted in circular reference.

Test case

Currently

This repo is missing specs and test cases on various point.

Required

  • Introduce Quick & nimble
  • Implement spec for all exposed properties and functions

Error uploading an app file containing RxWebKit 1.0.0 to appstoreconnect

I am using RxWebKit 1.0.0 by carthage 0.33.0, Xcode 10.2.1.

Two types of errors occurred when uploading app build file of containing RxWebKit 1.0.0 to appstoreconnect.

First:

It occurs in the validation when uploading to appstoreconnect)

ERROR ITMS-90206: "Invalid Bundle. The bundle at 'MyApp.app/Frameworks/RxWebKit.framework' contains disallowed file 'Frameworks'."
2019-06-10 07:14:44.225 altool[5834:27200] *** Error: Errors uploading '/Users/vagrant/deploy/MyApp.ipa': (
    "Error Domain=ITunesTransporterErrorDomain Code=-18000 \"ERROR ITMS-90206: \"Invalid Bundle. The bundle at 'MyApp.app/Frameworks/RxWebKit.framework' contains disallowed file 'Frameworks'.\"\" UserInfo={NSLocalizedRecoverySuggestion=ERROR ITMS-90206: \"Invalid Bundle. The bundle at 'MyApp.app/Frameworks/RxWebKit.framework' contains disallowed file 'Frameworks'.\", NSLocalizedDescription=ERROR ITMS-90206: \"Invalid Bundle. The bundle at 'Hagoita.app/Frameworks/RxWebKit.framework' contains disallowed file 'Frameworks'.\", NSLocalizedFailureReason=ERROR ITMS-90206: \"Invalid Bundle. The bundle at 'MyApp.app/Frameworks/RxWebKit.framework' contains disallowed file 'Frameworks'.\"}"
)

I solved the problem after removed below build option for Target: RxWebKit

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES

I referred to https://stackoverflow.com/a/35751497

Second:

It occurs after upload to appstoreconnect (received via email).

We identified one or more issues with a recent delivery for your app, "MyApp" 1.0.4 (1). Please correct the following issues, then upload again.

ITMS-90511: CFBundleIdentifier Collision - The Info.plist CFBundleIdentifier value 'mokumoku.RxWebKit' of 'MyApp.app/Frameworks/RxWebKit.framework' is already in use by another application.

I solved the problem by
INFOPLIST_FILE = Example/Info.plist;
with
INFOPLIST_FILE = RxWebKit/Info.plist;for Target: RxWebKit

I will send a PullRequest containing those fix, if that's OK.

update to swift 5

RxSwift already released its version to support Swift 5. When will RxWebKit support Swift 5? We are encountering compatibility issues already related to Swift 5 migration. Thanks!

Crash in certain versions

Hello! There are two crash issues that leave an issue

Crash on Xcode 11.3, simulator iPhone 5 (10.3.1), Carthage Build, RxWebKit 1.0.1

First

If you open the sample app and press Auth Challenge from the menu, you will get a crash like the picture below

스크린샷 2020-01-02 오후 2 47 10

second

Pressing Other Events in the menu causes the following crash

스크린샷 2020-01-02 오후 2 47 42

I wanted to find the cause of the second crash but haven't found it yet. 😥

Hello! Why you guys observe URL changes through KVO?

I'm just curious about why use KVO instead of trigger observer from webView delegate implement.
My friends always said: RxSwift is slow because Swift bridges to Objc.

And I found a issue and PR attempt to put this function into RxCocoa.
Why the code is not in the repo anymore?
issue-838

I'm still wondering about which way is better.

Thanks for your answer !!

Build and error on Xcode14

static let decidePolicyNavigationResponse = #selector(WKNavigationDelegate.webView(_:decidePolicyFor:decisionHandler:) as ((WKNavigationDelegate) -> (WKWebView, WKNavigationResponse, @escaping(WKNavigationResponsePolicy) -> Void) -> Void)?) 
static let decidePolicyNavigationAction = #selector(WKNavigationDelegate.webView(_:decidePolicyFor:decisionHandler:) as ((WKNavigationDelegate) -> (WKWebView, WKNavigationAction, @escaping(WKNavigationActionPolicy) -> Void) -> Void)?)

Xcode Version: 14
RxWebKit: 2.0.0
build and show "Type of expression is ambiguous without more context" error message
Screen Shot 2022-09-14 at 4 31 59 PM

Support for WebKit's delegtes

Right now RxWebKit supports only properties taken directly from WKWebView. When I started playing around more extensively with WebKit I started missing stuff from WKNavigationDelegate and WKUIDelegate.
Is there any specific reason why RxWebKit doesn't implement proxies for those delegates, or is it only because you didn't need them?
I'd love to see official implementation for those proxy delegates 😉 If you're willing to add them I'd be happy to implement them! Just let me know 🙌

Update podspec

The latest version of RxWebKit on Cocoapods is 0.3.3 which isn't installable with RxSwift/RxCocoa 3.2.0. We're needing to reference the latest commit in our podfile to get it installing.
Could a new podspec release be done?
Same issue as RxMKMapView RxSwiftCommunity/RxMKMapView#20

decidePolicyNavigationAction is not called.

In my project decidePolicyNavigationAction is needed for the cases, when javascript wants iOS to open external links to navigate to safari. I have already tested this function with simple delegates, and it works. However, in rx extension it does not.

Screen Shot 2021-12-02 at 11 13 33 AM

Has anybody else faced this issue before ?

Observing WKWebView url breaks loading content in the web view

I'm instantiating a web view, registering to observe its url, and loading a request in my view controller's view did load. When I comment out the line subscribing to observe it, it loads fine. Any idea what could be going on?

class TestViewController {
    var webView: WKWebView!
    let bag = DisposeBag()
    func viewDidLoad() {
        super.viewDidLoad()
        self.webView = WKWebView(frame: self.view.bounds)
        self.webView.rx.url.subscribe { print($0) }.disposed(by: self.bag)
        self.webView.load(URLRequest(url: URL(string: "https://github.com")!))
    }
}

I set a breakpoint and saw it print the first item, a nil url, but it never called it again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.