Swiftpack.co - objectia/objectia-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by objectia.
objectia/objectia-swift v1.0.0
Swift client for Objectia API
⭐️ 0
🕓 4 years ago
.package(url: "https://github.com/objectia/objectia-swift.git", from: "v1.0.0")

objectia-swift

Build Status

Swift client for Objectia API®

Documentation

See the Swift API docs.

Installation

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/objectia/objectia-swift.git", .upToNextMajor(from: "1.0.0"))

and then specify "Objectia" as a dependency of the Target in which you wish to use Objectia. Here's an example

// swift-tools-version:4.0 
import PackageDescription

let package = Package(
    name: "MyPackage",
    products: [
        .library(
            name: "MyPackage",
            targets: ["MyPackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/objectia/objectia-swift.git", .upToNextMajor(from: "1.0.0"))
    ],
    targets: [
        .target(
            name: "MyPackage",
            dependencies: ["Objectia"])
    ]
)

Then run swift package update to install or update the dependencies.

Accio

Accio is a dependency manager based on SwiftPM which can build frameworks for iOS/macOS/tvOS/watchOS. Therefore the integration steps of Objectia are exactly the same as described above. Once your Package.swift file is configured, run accio update instead of swift package update.

CocoaPods

To use CocoaPods, add the following entry in your Podfile:

pod 'Objectia', '~> 1.0'

Then run pod install.

In any file you'd like to use Objectia in, don't forget to import the framework with import Objectia.

Carthage

To use Carthage, make the following entry in your Cartfile:

github "objectia/objectia-swift" ~> 1.0

Then run carthage update.

Requirements

  • Apple Xcode 10.0 or later with Swift 4.0+

Usage

The library needs to be configured with your account's API key. Get your own API key by signing up for a free Objectia account.

import Foundation
import Objectia

extension String: Error {}

do {
    guard let apiKey = ProcessInfo.processInfo.environment["OBJECTIA_APIKEY"] else {
        throw "API key not set"
    }
    try ObjectiaClient.initialize(apiKey: apiKey) 
    let location = try GeoLocation.get(ip: "8.8.8.8")
    print("Country code:", location!.countryCode!)
} catch let err as ObjectiaError {
    print("Request failed:", err) 
} catch {
    print("Error:", error) 
}

License and Trademarks

Copyright (c) 2018-19 UAB Salesfly.

Licensed under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Objectia is a registered trademark of UAB Salesfly.

GitHub

link
Stars: 0
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Release 1.0.0
4 years ago

Initial release

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics