/Cronet.framework

This package makes it easy to use Chromium's networking stack in your iOS applications

Primary LanguageShellOtherNOASSERTION

Cronet: Chromium's networking stack for your iOS applications

Build Status Version License Platform

Cronet is the Chromium network stack made available to iOS apps as a library.

Cronet takes advantage of multiple technologies that reduce the latency and increase the throughput of the network requests that your app needs to work.

This is the same networking stack that is used in the Chrome browser by over a billion people. Cronet has support for both Android and iOS.

This package makes it easy to use Cronet in your iOS apps.

Note: You will have to disable bitcode on your target.

Table of contents

Features

  • Protocol support

    Cronet natively supports the HTTP, HTTP/2, and QUIC protocols.

  • Request prioritization

    The library allows you to set a priority tag for the requests. The server can use the priority tag to determine the order in which to handle the requests.

  • Resource caching

    Cronet can use an in-memory or disk cache to store resources retrieved in network requests. Subsequent requests are served from the cache automatically.

  • Asynchronous requests

    Network requests issued using the Cronet Library are asynchronous by default. Your worker threads aren't blocked while waiting for the request to come back.

  • Data compression

    Cronet supports data compression using the Brotli Compressed Data Format.

What is this repo?

You may be wondering, if Cronet is a chromium libary, what is this repo about?

That is right, Cronet is a chromium library and this repo doesn't add or modify any chromium code. For that fact this repo doesn't even have any code. This repo is about making Cronet easier to use in your iOS app if you are not a google employee.

As some one of HN succiently said:

Chromium is a fairly typical google project where the recommended first step to building it is to become a google employee but some alternative workarounds are also available if that's not practical.

More precisely this repo:

  1. Fetches unofficial cronet build artificats that chromium publishes.
  2. Merge the iphoneos and iphonesimulator frameworks together using lipo for both static and dynamic builds
  3. Publishes a github release with the static, dymanic and dysm archives attached to the release on github
  4. Publishes the static version of the module to cocoapods under Cronet

Installing

  1. Make sure bitcode is disabled on the target you want to link Cronet with.
  2. Link Cronet.framework into your iOS app's workspace/project either using cocoapods or manually linking the framework.

Using Cocoapods

  1. Add pod 'Cronet' under your desired target in your Podfile:
  2. Run pod install

Manual Installataion

  1. Download the appropriate archive that you want to use from the latest release
  2. Extarct the archive and copy the Cronet.framewrok folder into your project by dragging the folder into your project in Xcode. Make sure to select Copy items if needed in the dialog that pops up
  3. In your Target -> Build Phase -> Link Binary With Libraries add SystemConfiguration.framework
  4. In your Target -> Build Settings -> Other Linker Flags add -lc++

Usage

Initialize cronet somewhere in your app's start flow. For example, in:

- (BOOL)application:... didFinishLaunchingWithOptions:...

Add:

[Cronet setHttp2Enabled:YES];
[Cronet setQuicEnabled:YES];
[Cronet setBrotliEnabled:YES];
[Cronet start];
[Cronet registerHttpProtocolHandler];

For a complete list of initilization options see Cronet.h

Known Issues

  1. Cronet library is not available in a bitcode enabled version. So you must disable bitcode in your target to use it.
  2. Some NSURLSession*Delegate callback's don't work when cronet is registered as a protocol handler in that session.
  3. Dsym is only available for dynamic framework.

License

See the LICENSE file for more info.