NDT7 0.0.1-beta.4

NDT7 0.0.1-beta.4

Maintained by Miguel Nieto.



NDT7 0.0.1-beta.4

  • By
  • Miguel Nieto

NDT7 iOS

branch travis-ci codacy sonarcloud codecov
develop Build Status Coverage Status
master Build Status Codacy Badge Quality Gate Coverage Status

Bugs Vulnerabilities Maintainability Reliability Security

Average time to resolve an issue Percentage of issues still open Measurement Lab Apache License Platform Carthage Compatible CocoaPods Compatible

Table of Contents

Introduction

"Measure the Internet, save the data, and make it universally accessible and useful."

NDT7 provides a framework to measure the download and upload speed.

Current supported features

  • Download Speed Test. Beta version.
  • Upload Speed Test. Beta version.
  • Download Speed Test
  • Upload Speed Test

Requirements

  • iOS 10.0+ / macOS 10.14.0+ / appleTV 10.0+ / watchOS 3.0+
  • Xcode 10.2+
  • Swift 5.0+

Documentation

Visit the NDT7 documentation for instructions and browsing api references.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website.

platform :ios, '10.0'
use_frameworks!

target 'NDT7 example' do
  pod 'NDT7', '0.0.1-beta.4'
end

Then, run the following command:

$ pod install

Carthage

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

Create a Cartfile and add the following line:

github "m-lab/ndt7-client-ios" ~> 0.0.1-beta.4

Next, run the following command:

$ carthage update

Check out the Carthage docs ยป for more info.

Manual Installation

Adding all swift files

Add all *.swift files from Sources directory into your project.

Embedded Framework

Step 1. Add as a git Submodule

Add NDT7 as a submodule to your local git repo with the following command:

$ git submodule add [email protected]:m-lab/ndt7-client-ios

Step 2. Drag NDT7.xcodeproj to your project

Drag the NDT7.xcodeproj into the Project Navigator of you application's Xcode project.

Step 3. Embed the framework

Under "General" tab from your project, add the NDT7 framework as an embedded binary. You'll see different frameworks depending if you need it for iOS, macOS or appleTV.

Setup and usage

Setup

The only setup needed for debugging purpose is to enable logging if needed.

NDT7.loggingEnabled = true

If specific settings are needed for the testing configuration, you can define an NDT7Settings object, otherwise, use the default one with NDT7Settings().

In the next section, "Start speed test", we'll show all the steps needed to start a test.

Start speed test

The next example show the whole process for a download and upload speed test.

  1. Setup all the functions needed for NDT7Test delegate.
  2. Create the settings for testing. NDT7Settings.
  3. Create a NDT7Test object with NDT7Settings already created.
  4. Setup a delegation for NDT7Test to get the test information.
  5. Start speed test for download and/or upload.
import UIKit
import NDT7

class ViewController: UIViewController {

    var ndt7Test: NDT7Test?

    override func viewDidLoad() {
        super.viewDidLoad()
        // For debugging purpose you can enable logs for NDT7 framework.
        NDT7.loggingEnabled = true
        startTest()
    }

    func startTest() {
        // 2. Create the settings for testing. NDT7Settings.
        let settings = NDT7Settings()
        // 3. Create a NDT7Test object with NDT7Settings already created.
        ndt7Test = NDT7Test(settings: settings)
        // 4. Setup a delegation for NDT7Test to get the test information.
        ndt7Test?.delegate = self
        // 5. Start speed test for download and/or upload.
        ndt7Test?.startTest(download: true, upload: true) { [weak self] (error) in
            guard self != nil else { return }
            if let error = error {
                print("NDT7 iOS Example app - Error during test: \(error.localizedDescription)")
            } else {
                print("NDT7 iOS Example app - Test finished.")
            }
        }
    }

    func cancelTest() {
        ndt7Test?.cancel()
    }
}

// 1. Setup all the functions needed for NDT7Test delegate.
extension ViewController: NDT7TestInteraction {

    func test(kind: NDT7TestConstants.Kind, running: Bool) {
    }

    func measurement(origin: NDT7TestConstants.Origin, kind: NDT7TestConstants.Kind, measurement: NDT7Measurement) {
    }

    func error(kind: NDT7TestConstants.Kind, error: NSError) {
    }
}

License

NDT7 iOS client is released under the Apache License, Version 2.0. See LICENSE for details.