A tiny wrapper for libmaxminddb which allows you to lookup Geo data by IP address.
NOTE From v0.5.0, MMDB-Swift no longer bundles GeoLite2 database due to the license change. Developers should download the binary version from the Maxmind website.
CocoaPods
MMDB-Swift is available through CocoaPods. To install it, simply add the following line to your Podfile:
platform :ios, '8.0'
use_frameworks!
pod "MMDB-Swift"
Then, run the following command:
pod install
Carthage
To integrate MMDB-Swift into your Xcode project using Carthage, add the following line to your Cartfile:
github "lexrus/MMDB-Swift"
Run carthage update to build the frameworks and drag the built MMDB.framework into your Xcode project.
public struct MMDBContinent {
var code: String?
var names: [String: String]?
}
public struct MMDBCountry: CustomStringConvertible {
var continent = MMDBContinent()
var isoCode = ""
var names = [String: String]()
...
}
MMDB-Swift
A tiny wrapper for libmaxminddb which allows you to lookup Geo data by IP address.
NOTE From
v0.5.0
, MMDB-Swift no longer bundles GeoLite2 database due to the license change. Developers should download the binary version from the Maxmind website.CocoaPods
MMDB-Swift is available through CocoaPods. To install it, simply add the following line to your Podfile:
Then, run the following command:
Carthage
To integrate MMDB-Swift into your Xcode project using Carthage, add the following line to your
Cartfile
:Run
carthage update
to build the frameworks and drag the builtMMDB.framework
into your Xcode project.Swift Package Manager
Package.swift
Usage
This outputs:
Notice that country is a struct defined as:
Author
Lex Tang (Twitter: @lexrus)
License
MMDB-Swift is available under the Apache License Version 2.0. See the LICENSE file for more info.
The GeoLite2 databases are distributed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.