A drop-in inline browser for your Swift iOS app.

Overview

SwiftWebVC

SwiftWebVC is a simple inline browser for your Swift iOS app.

SwiftWebVC

SwiftWebVC features:

  • iPhone and iPad distinct UIs
  • Full landscape orientation support
  • Back, forward, stop/refresh and share buttons
  • Open in Safari and Chrome UIActivities
  • Navbar title set to the currently visible web page
  • Talks with setNetworkActivityIndicatorVisible
  • 3 different themes to choose from when presented modally

SwiftWebVC

Installation

CocoaPods

  • SwiftWebVC is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftWebVC'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SwiftWebVC into your Xcode project using Carthage, specify it in your Cartfile:

github "meismyles/SwiftWebVC"

Run carthage update to build the framework and drag the built SwiftWebVC.framework into your Xcode project.

Manual

  • Add the SwiftWebVC/ folder into your project.

Usage

Just like any UIViewController, SwiftWebVC can be pushed into a UINavigationController stack:

let webVC = SwiftWebVC(urlString: "http://google.com")
self.navigationController?.pushViewController(webVC, animated: true)

It can be presented modally using SwiftModalWebVC:

let webVC = SwiftModalWebVC(urlString: "http://google.com")
self.present(webVC, animated: true, completion: nil)

Options

The share button can be disabled by passing a flag in to the constructor to specify this:

let webVC = SwiftWebVC(urlString: "http://google.com", sharingEnabled: false)

The same principal applies for the modal implementation also:

let webVC = SwiftModalWebVC(urlString: "http://google.com", sharingEnabled: false)

Modal Options Only

Themes may be chosen for the modal implementation. The default theme is Light-Blue. Other modal themes Light-Black and Dark may be chosen using one of the following instead:

let webVC = SwiftModalWebVC(urlString: "http://google.com", theme: .lightBlack)
let webVC = SwiftModalWebVC(urlString: "http://google.com", theme: .dark)

Delegate (Start/Finish Loading Callbacks)

SwiftWebVC also includes a delegate protocol that allows you to implement didStartLoading and didFinishLoading functions to determine when loading starts and finishes.

Note: This is currently only implemented for SwiftWebVC, not SwiftModalWebVC.

To implement this, after declaring your instance of SwiftWebVC, set it's delegate and implement the callback functions. For example:

Inititalisation

let webVC = SwiftWebVC(urlString: "https://www.google.com")
webVC.delegate = self
self.navigationController?.pushViewController(webVC, animated: true)

Delegate Implementation

extension ViewController: SwiftWebVCDelegate {
    
    func didStartLoading() {
        print("Started loading.")
    }
    
    func didFinishLoading(success: Bool) {
        print("Finished loading. Success: \(success).")
    }
}

SwiftWebVCActivity

Starting in iOS 6 Apple uses UIActivity to let you show additional sharing methods in share sheets. SwiftWebVC comes with "Open in Safari" and "Open in Chrome" activities. You can easily add your own activity by subclassing SwiftWebVCActivity which takes care of a few things automatically for you. Have a look at the Safari and Chrome activities for implementation examples.Typed

Credits

SwiftWebVC is a Swift implementation of Sam Vermette's SVWebViewController. Code transcription, updates and changes were carried out by Myles Ringle. The original SVWebViewController was brought to you by Sam Vermette and contributors to the project.

If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by creating new issues. If you're using SwiftWebVC in your project, attribution is always appreciated.

Thanks to Icons8 for the images.

Comments
  • Image assets for buttons aren't loaded

    Image assets for buttons aren't loaded

    Hi, I've tried adding SwiftWebVC to an empty project via CocoaPods but there is an issue with image assets in the bundle. It looks like once the pod is installed, image assets are not a part of the bundle anymore (although if you look on the filesystem, they are). The result is that the images aren't loaded when the browser view is displayed. Attached screenshot shows the issue.

    If you need more information, please let me know.

    swiftwebvc-issue

    bug help wanted 
    opened by srstanic 40
  • Title not centered

    Title not centered

    Seems like the title of subpages is not always centered. If I open the viewController as follows and navigate back and forth in the pages, sometimes the title is aligned left, instead of center (see screenshot below: Kontakte title in bar on top).

    UINavigationController(rootViewController: SwiftWebVC(urlString: "https://mandelkind.help/valletti"))

    simulator screen shot 26 06 2017 21 12 53

    opened by marbetschar 7
  • Crash on iOS11

    Crash on iOS11

    On iOS11 showing the browser crashes in SwiftWebVC.swift in method updateToolbarItems() on

    let refreshStopBarButtonItem: UIBarButtonItem = webView.isLoading ? stopBarButtonItem : refreshBarButtonItem
    

    with Thread 1: EXC_BAD_ACCESS (code=2, address=0x604000286f90) when the browser is first opened.

    bug urgent 
    opened by igorkulman 6
  • Dismissing SwiftModalWebVC does not stop webview

    Dismissing SwiftModalWebVC does not stop webview

    For example, if you are playing audio in a modal web VC and dismiss it the audio continues playing.

    I believe this is due to the doneButtonTapped method being handled by the child webViewController: SwiftWebVC

    opened by bchrobot 6
  • Blank screen with activity indicator issue for certain URL strings cases

    Blank screen with activity indicator issue for certain URL strings cases

    Version: 0.4.0

    I noticed there are two cases where your module gets stuck on a blank screen with a spinning Activity Indicator (see screenshot):

    simulator screen shot jun 12 2017 5 15 43 pm

    1. No schema
    let webVC = SwiftModalWebVC(urlString: "www.google.com")
    
    1. HTTP schema (not HTTPS)
    let webVC = SwiftModalWebVC(urlString: "http://www.google.com")
    

    I'm able to make this work if you create an iOS 8+ ATS exception for each HTTP domain or if you set NSAllowsArbitraryLoads.

    	<key>NSAppTransportSecurity</key>
    	<dict>
    		<key>NSAllowsArbitraryLoads</key>
    		<true/>
    	</dict>
    

    My question is: is there any way to allow HTTP links on WKWebView without doing the above?

    Thanks!

    enhancement 
    opened by apparition47 4
  • SwiftWebVC does not open clicked hyperlink

    SwiftWebVC does not open clicked hyperlink

    Opening the following link in SwiftWebVC and trying to open a hyperlink of that page does not work.

    http://site.petitrc.com/reglages/yokomo/SetupSheetsYokomoBD8.html

    bug 
    opened by MauriceHmb 4
  • Crash while using inside UIPagerViewController

    Crash while using inside UIPagerViewController

    When using your module inside UIPagerViewController app will crash. It happening because deinit method accessing lazy var that not initialized yet. So lazy var perform init and try to set deallocating object as delegate to WKWebView. UIPagerViewController requires two VC (in case when pager view displays only one VC at time), one of them will be unused and deallocated before loadView() was called.

    investigate 
    opened by kei-sidorov 2
  • Dismiss button on `SwiftModalWebVC`

    Dismiss button on `SwiftModalWebVC`

    Hey @meismyles

    I've noticed that the modal version of the browser uses a V icon for dismissing the modal view instead of the more traditional and well-established X.

    Is this something that you could change or at least make configurable?

    enhancement 
    opened by attheodo 2
  • Xcode doesn't recognise the SwiftWebVC class

    Xcode doesn't recognise the SwiftWebVC class

    Whenever I try to instantiate the SwiftWebVC or any other class I get a compiler error that it isn't recognized. Even tough the assets are recognized.

    Am I missing something, is this a known issue because this currently renders the the whole framework unusable for me.

    screen shot 2018-06-21 at 12 43 35
    opened by kristofk 1
  • handle js

    handle js

    inSwiftWebVC.swift, i have added config as follw

    public class SwiftWebVC: UIViewController,WKScriptMessageHandler {
    public var jsHandler:((WKScriptMessage)->())?
    ...
    }
    
    lazy var webView: WKWebView = {
            let configuration = WKWebViewConfiguration()
            configuration.userContentController.add(self, name: "wawa")
            var tempWebView = WKWebView(frame: UIScreen.main.bounds, configuration: configuration)
            tempWebView.uiDelegate = self
            tempWebView.navigationDelegate = self
            return tempWebView;
        }()
    
    public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
            if self.jsHandler != nil {
                self.jsHandler!(message)
            }
        }
    

    and it just fail to work, maybe i need help.

    opened by Cj370118568 1
  • SwiftWebVC never loads some urls, Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

    SwiftWebVC never loads some urls, Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

    Trying SwiftWebVC out for the first time and I'm having a problem loading certain pages. This is how I show it:

    let webVC = SwiftWebVC(urlString: "http://www.udwa.org/our-union/")
    webVC.delegate = self
    self.navigationController?.pushViewController(webVC, animated: true)
    
    

    The delegate call back tells me that it started loading, after 30 seconds I get the following in the console:

    2017-10-14 11:57:05.941522-0700 udw[61741:29492827] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service 2017-10-14 11:57:05.942308-0700 udw[61741:29492827] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service

    I tried several other URLs:

    1. https://www.google.com/ : worked, doesn't print the WebContent error above
    2. https://github.com/meismyles/SwiftWebVC : worked, doesn't print the WebContent error above
    3. http://www.inadaydevelopment.com : failed. This is my company's website, a WP site hosted in Google's cloud.
    4. http://herdboss.com/ : failed. This is another company I'm part of, a drupal site hosted at Rackspace.
    5. http://garyjohnston.com/ : failed. A friend's website, a WP site. Not sure where it's hosted, but it's a different server from 3 and 4 above.

    I get the same behavior when using the SwiftModalWebVC.

    Any help is appreciated.

    screen shot 2017-10-14 at 11 48 30 am
    opened by kennywyland 1
  • Address bar added

    Address bar added

    The most important feature of the browser was missing - the address bar. With this PR I added an address bar that can be easily replaced with the usual title

    opened by matthiasnagel 0
  • Does SwiftWebVC use UIWebView?

    Does SwiftWebVC use UIWebView?

    Hello,

    I recently received an email from Apple saying:

    The App Store will no longer accept new apps using UIWebView as of April 2020, and existing apps must remove the deprecated API by December 2020. Migrate to the more secure and reliable WKWebView as soon as possible.

    Does SwiftWebVC still use UIWebView? I can see one reference to it in the code - https://github.com/meismyles/SwiftWebVC/blob/0.4.2/SwiftWebVC/SwiftModalWebVC.swift#L20

    opened by craig65535 1
Releases(0.4.2)
Owner
Myles Ringle
Myles Ringle
Sample project for select specific Web Browser on iOS.

Sample project for select specific Web Browser on iOS.

Toru Kageyama 0 Oct 24, 2021
PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item.

PTPopupWebView PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item. Requirement iOS 8.0 Inst

Takeshi Watanabe 117 Dec 3, 2022
Otafuku provides utility classes to use WKWebView in Swift.

Otafuku Otafuku provides utility classes to use WKWebView. Features WebViewUIController to handle WKUIDelegate methods by presenting an alert as usual

Kazunobu Tasaka 52 Apr 3, 2021
A drop-in inline browser for your iOS app.

SVWebViewController SVWebViewController is a simple inline browser for your iOS 7 app. SVWebViewController features: iPhone and iPad distinct UIs full

Transit 2.6k Dec 14, 2022
Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.

SwiftUI Matched Inline Title Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen i

Seb Jachec 19 Oct 9, 2022
Swift-picker-views - inline single and multi picker views for UIKit. Without tableview! Easy and simple

swift-picker-views Inline single and multiple picker views for UIKit. No tablevi

IBRAHIM YILMAZ 2 Jan 31, 2022
Subclass of UITextField that shows inline suggestions while typing.

AutocompleteField Subclass of UITextField that shows inline suggestions while typing. Plug and play replacement for UITextField. Delimiter support. Pe

Filip Stefansson 663 Dec 6, 2022
Erik is an headless browser based on WebKit. An headless browser allow to run functional tests, to access and manipulate webpages using javascript.

Erik Erik is a headless browser based on WebKit and HTML parser Kanna. An headless browser allow to run functional tests, to access and manipulate web

Eric Marchand 544 Dec 30, 2022
Erik is an headless browser based on WebKit. An headless browser allow to run functional tests, to access and manipulate webpages using javascript.

Erik Erik is a headless browser based on WebKit and HTML parser Kanna. An headless browser allow to run functional tests, to access and manipulate web

Eric Marchand 544 Dec 30, 2022
FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

null 10 Dec 11, 2022
A small Swift tool/server to serve DocC archives to your browser

servedocc Small Swift script to serve "DocC" archives, a format to document Swift frameworks and packages: Documenting a Swift Framework or Package. N

DocZ 8 Jan 29, 2022
A Powerful Private Browser Developed to Truly Protect your Data

SnowHaze SnowHaze is the first and only iOS browser that truly protects your data! Designed for best possible privacy and security and made to be easi

SnowHaze 115 Nov 6, 2022
A Simple way help you drop or drag your source (like UIImage) between different App.

A Simple way help you drop or drag your source (like UIImage) between different App.

逸风 13 Nov 24, 2022
FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app

native_drag_n_drop A package that allows you to add native drag and drop support

Alex Rabin 21 Dec 21, 2022
Drop in user input validation for your iOS apps.

Validator Validator is a user input validation library written in Swift. It's comprehensive, designed for extension, and leaves the UI up to you. Here

Adam Waite 1.4k Dec 29, 2022
Drag and drop between your apps in split view mode on iOS 9

SplitViewDragAndDrop Easily add drag and drop to pass data between your apps Setup Add pod 'SplitViewDragAndDrop' to your Podfile or copy the "SplitVi

Mario Iannotta 324 Nov 22, 2022
PRGTipView is a drop-in solution for adding onboarding tips to your apps

PRGTipView PRGTipView is a drop-in solution for adding onboarding tips to your apps. It supports: Title, detail and dismissal button Give focus on a p

Iannis Spiropoulos 25 Aug 12, 2022
FlightTicketBrowser - A SwiftUI sample app for flight ticket browser

FlightTicketBrowser This app is a SwiftUI sample app for flight ticket browser.

Takuya Aso 6 Nov 14, 2022
SwiftWebKit - This app look like a browser, but you can navigate between 2 sites

import UIKit import WebKit My first app for WebKit. This app look like a browser

Ahmet Onur Şahin 3 Apr 18, 2022