Latest 0.1.3
Homepage https://github.com/Raizlabs/Geode
License MIT
Platforms ios 9.0, requires ARC
Frameworks CoreLocation
Authors ,

Build Status
Carthage compatible
CocoaPods compatible

Location management made easy.

Swift Compatibility

Geode is available for both Swift 2.3 and 3.0. The master branch is Swift
3.0-only, and will not receive any 2.x compatibility changes. The swift-2.3
branch exists for projects that must use Swift 2. This branch is frozen at
version 0.1.3, and will not receive further updates.

Installation with Carthage

Carthage is a decentralized dependency manager that automates the process of
adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following commands:

brew update
brew install carthage

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

github "Raizlabs/Geode"

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

Installation with CocoaPods

CocoaPods is a dependency manager for Cocoa projects.
You can install it with the following command:

$ gem install cocoapods

To integrate Geode into your Xcode project using CocoaPods, specify it in
your Podfile:

platform :ios, '10.0'
use_frameworks!

pod 'Geode'

Then, run the following command:

$ pod install

Usage

One-shot Location Access

iOS 9 introduced the ability to request the one-time delivery of the user’s
current location. This approach does not keep location services running
longer than what is necessary to obtain a location fix. One common use case
is to tie a location update to an action so that the user can refresh their
location as needed:

import Geode

let locator = Geode.GeoLocator(.oneShot)

@IBAction func updateLocationAction() {
    locator.requestLocationUpdate { location in
        debugPrint("Current location: (location)")
    }
}

Continuous Location Access

Continuous location access (the only method available prior to iOS 9)
supplies location updates to your application as the user’s position changes.
This approach will provide you with the most current location data at the
expense of increased battery usage.

You might, for example, tie location monitoring to a view controller’s
lifecycle:

import Geode

let locator = Geode.GeoLocator(.continuous)

override func viewDidLoad() {
    super.viewDidLoad()

    locator.startMonitoring { location in
        debugPrint("Current location: (location)")
    }
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated: animated)

    locator.stopMonitoring()
}

Logging

One of the most effective ways to debug location services is to log from your
CLLocationManagerDelegate. Geode’s implementation is instrumented with
numerous log statements, all of which delegate to a logHandler callback that
is nil by default. This allows for easy integration with existing logging
frameworks (e.g. CocoaLumberjack).

public typealias LogHandler = (_ message: @autoclosure () -> String, _ level: LogLevel, _ file: StaticString, _ line: UInt) -> Void

The message parameter is passed as a closure, which allows us to potentially
avoid any unnecessary string processing if the log level is not set high enough.
A simple logging implementation might look like the following:

locator.logHandler = { (_ message: @autoclosure () -> String, _ level: LogLevel, _ file: StaticString, _ line: UInt) in
    debugPrint("[GEODE] (String(describing: level).uppercased()) (file) L(line): (message())")
}

Maintainers

License

Geode is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "Geode",
    "version": "0.1.3",
    "summary": "Location management made easy.",
    "description": "Geode is a Swift library that simplifies managing location access.",
    "homepage": "https://github.com/Raizlabs/Geode",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "John Watson": "[email protected]",
        "Raizlabs": null
    },
    "social_media_url": "http://twitter.com/Raizlabs",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/Raizlabs/Geode.git",
        "tag": "v0.1.3"
    },
    "source_files": "Source/**/*.{h,swift}",
    "requires_arc": true,
    "frameworks": "CoreLocation"
}

Pin It on Pinterest

Share This