Monday, January 11, 2016

A Faster Hybrid App for the New Year

Mobile-phone-New-year-2016-wallpapers-themes-iphone-android

Background

In case you missed it, the official release of Cordova iOS 4.0.0 was announced in December (and subsequently 4.0.1). It’s important to emphasize it not only due to it being a major version change but due to the significant app performance benefits it enables. By updating your iOS apps to Cordova 4.x, you’re immediately eligible to take advantage of iOS’s nitro-powered WKWebView.

Prior to this version there was a way to do it (as noted in my post here), but it required some hoop jumping and was not without its caveats. Now however, we’re happy to promote this new version to help you easily take advantage of all the goodness the WKWebView has to offer.

In this post I’ll show you how to use this latest version in a new project and an existing project as well as help troubleshoot some things you may run into depending on your current environment. Much of the information here is available elsewhere too but it’s scattered between the Apache Cordova blog, JIRA issues and the Cordova docs so I decided to summarize it all in this post for a one stop reference.

Cordova and the WebView

As most of you may know, Cordova has always supported the iOS UIWebView by default, which was the only webview class available until iOS8 was released. Due to reasons discussed here, Cordova was unable to support the WKWebView fully and cleanly until this latest release. In Cordova 4.0.x, the UIWebView is still currently the default for backwards-compatibility reasons. But now using the pluggable webviews first implemented in cordova-android 4.0.0 with support for Crosswalk), it can easily be swapped to use the WKWebView instead by simply adding a plugin (cordova-plugin-wkwebview-engine).

Use in a New Project

Add the iOS platform with the latest keyword

$ cordova platform add ios@latest

You could also add a specific version using:

$ cordova platform add ios@4.0.1

Use in an Existing Project

Before updating an existing project to Cordova iOS 4+, you need to be sure to remove the existing iOS platform. Run the following commands to remove the previous iOS version and add the latest:

$ cordova platform remove ios
$ cordova platform add ios@latest

TROUBLESHOOTING: If you forget to remove the previous ios version you will get an error like the following upon build:


MainViewController.m:109:19: error: no visible @interface for ‘CDVViewController’ declares the selector ‘webViewDidFinishLoad:’ return [super webViewDidFinishLoad:theWebView];

ios-deploy version

Cordova iOS 4.0.0 is dependent on ios-deploy version 1.8.0 or greater. If you have anything less you will get an error like the following and will be asked to install the latest when you run your app.

ERROR running one or more of the platforms: Cordova needs ios-deploy version 1.8.0 or greater, you have version 1.7.0. Please download, build and install version 1.8.0 or greater from http://ift.tt/1i0fD0H into your path, or do 'npm install -g ios-deploy'

To fix it run:

$ npm install -g ios-deploy

TROUBLESHOOTING: If you receive an error like this after running the above:

2016-01-07 14:57:07.873 xcodebuild[32761:1714037] *** Assertion failure in -[SimServiceContext reloadServiceIfMovedOrAbortIfWeAreInvalid], /BuildRoot/Library/Caches/http://ift.tt/1OKZtMN
** INTERNAL ERROR: Uncaught exception **
Exception: The loaded com.apple.CoreSimulator.CoreSimulatorService job does not match our expectations: versionOfLoadedJob: (null), our version: 201.3S

Visit this link and try running it with the following flags instead:

$ sudo npm install -g ios-deploy --unsafe-perm=true --allow-root

Use WKWebView

Once you get through installing all the latest Cordova iOS and ios-deploy versions, the last step is to add the WKWebView Engine plugin to ensure the faster webview is used for your app.

$ cordova plugin add cordova-plugin-wkwebview-engine --save

Once added, your app will automatically use it instead of the UIWebView by default when it runs and the plugin will be saved to the config.xml file.

Important Notes

  • Whitelist Plugin no longer needed – It’s included in cordova-ios 4.0.0 and greater automatically, but you’ll still need to set up your whitelist in the config.xml as described by the guide here.

    Also on a related note, iOS App Transport Security support is now added to the plist automatically for you by the CLI as of Cordova CLI version 5.4.0. The settings will be added to the .plist based on what you specified for your <allow-*> tags in the config.xml.

    For example, adding the following to your config.xml:

    <allow-navigation href="http://devgirl.org" />

    results in the following plist keys/values outlined in red below:

    plist

    or raw source values:

    <key>NSAppTransportSecurity</key>
    <dict>
     <key>NSExceptionDomains</key>
     <dict>
       <key>devgirl.org</key>
       <dict>
         <key>NSExceptionAllowsInsecureHTTPLoads</key>
         <true/>
       </dict>
     </dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
    </dict>
    
  • InAppBrowser Update – The InAppBrowser plugin was updated to support 4.0.0+ and is also backwards compatible with Cordova iOS 3+. If your project uses it, remove and add the latest with:
    $ cordova plugin remove cordova-plugin-inappbrowser
    $ cordova plugin add cordova-plugin-inappbrowser --save
    
  • iPhone 6s and iPhone 6s Plus Simulator targets – If you’re reading this soon after this post goes live, the support for the iPhone 6s and 6s Plus target in the simulator may not be supported yet even if it’s displayed in the list returned when you run the cordova run --list command. The fix will be in the next release, see this link for details.

Feedback

Please feel free to comment here with any additional notes or troubleshooting tips you may have found helpful as well.


by Holly Schinsky via Devgirl's Weblog

Kuiloa

Kuiloa is a mexican design & development agency since 2011.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Living Eden Designs

Your one stop decorating resource for all your soft furnishing needs. We provide all kinds of soft furnishings and accessories such as curtains, upholstery, pelmets, valances, blinds, drapes, hooks, tassels and rods.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

ALR Technologies

ALR TECHNOLOGIES SDN BHD is a leading and professional automation control products supplier and solutions company. As an authorized distributor of GE products,


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Javier Marin. Terra.

Official website of the art exhibition Javier Marín. Terra. Material as Idea.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Google Fit for Android: An Overview

Learn the First Best Practices for Rails and RSpec

Writing code without testing can be a deceptively smooth ride; one that, unfortunately, comes to a screeching halt when you start working with other developers. This tutorial is aimed at helping Ruby on Rails developers (especially the new folks) in setting up an RSpec test suite using best practices, in the Behaviour Driven Development way. I know that testing can be pain when you are just getting into it. There are lots of resources online to help you on this journey. I am hopeful this will be of benefit to new Ruby on Rails developers since I just started getting into testing myself.

In this tutorial we will learn the following:
* How to setup - RSpec, Capybara, Shoulda-Matchers, Database Cleaner
* How to create a factory using Factory Girl Rails and Faker
* How to write Model Specs
* How to write Controller Specs
* How to write Feature Specs
* How to check spec coverage using SimpleCov

Continue reading %Learn the First Best Practices for Rails and RSpec%


by Kingsley Silas via SitePoint