Git Product home page Git Product logo

flwebview's Introduction

Note: This repository was written in Objective-C. A Swift version is available here.

This is an example Xcode project demonstrating how to use WKWebView in iOS 8 with a UIWebView fallback for earlier versions of iOS. A full discussion of this code is available here. Basically, we created a protocol that unifies the functionality we'd like to have in a WebView, and then created categories that ensure we have the proper methods in our UIWebView and WKWebView classes.

These are used in the ViewController viewDidLoad method to create a web view and add it to the active view. The code checks for WKWebKit and, if present, uses WKWebView. If it's not there, it defaults to UIWebView.

Usage

This is an example project but you should be able to build and test it with little setup. Obviously, as this is an iOS project the following steps apply to OS X. Assuming you have Ruby you can install homebrew if you don't have it already (just enter this in the terminal):

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then you can install xctool, Facebook's neat open source Xcode build tool:

brew install xctool

After that, you can run the test.sh script to build and test:

sh test.sh

There you go! Of course, you can this in Xcode, but this setup is great if you want to do some continuous integration, as Travis already has xctool installed by default.

Notes

If you're getting code signing errors with an Objective-C project in Travis, make sure that your build script specifies -sdk iphonesimulator and -test-sdk iphonesimulator. Also, if your .travis.yml file targets the script you're using locally (in our case, .travis.yml specifies script: sh test.sh) it makes the debug process a bit simpler.

Tests

As the goal of this project was not to create an example of good iOS testing, the tests for this repository are very minimal and largely serve largely to verify that we can build and deploy the application without issue. There are some tests to verify that we can instantiate a web view, but these are not particularly robust. You can find good information on unit testing in iOS from Apple's iOS Developer Library here.

Tools

  • travis-ci - Automated unit testing.
  • travis-lint - Local Travis settings validation.
  • xctool - Command-line iOS build scripts.
  • homebrew - OS X package management, used to install xctool.
  • ruby gem - Ruby package management, used to install travis-lint.

References

License

© 2014 Float. Shared under an MIT license. See license.md for details.

flwebview's People

Contributors

steverichey avatar edwardbx avatar waffle-iron avatar ngoctr avatar

Watchers

James Cloos avatar

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.