All Projects → lexrus → Mmdb Swift

lexrus / Mmdb Swift

Licence: apache-2.0
A tiny wrapper for libmaxminddb which allows you to lookup Geo data by IP address.

Programming Languages

c
50402 projects - #5 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to Mmdb Swift

Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (+18.92%)
Mutual labels:  geolocation, carthage
Diff
Simple diff library in pure Swift
Stars: ✭ 110 (-0.9%)
Mutual labels:  carthage
React Native Radar
React Native module for Radar, the leading geofencing and location tracking platform
Stars: ✭ 104 (-6.31%)
Mutual labels:  geolocation
Nvactivityindicatorview
A collection of awesome loading animations
Stars: ✭ 10,031 (+8936.94%)
Mutual labels:  carthage
Swift Screencapture
A Swift framework to easily capture the screen on OS X.
Stars: ✭ 105 (-5.41%)
Mutual labels:  carthage
Pincodeinputview
A input text view for entering pin code.
Stars: ✭ 108 (-2.7%)
Mutual labels:  carthage
Tkdotsegment
TKDotSegment is a segment with dot animation
Stars: ✭ 103 (-7.21%)
Mutual labels:  carthage
Device
Light weight tool for detecting the current device and screen size written in swift.
Stars: ✭ 1,503 (+1254.05%)
Mutual labels:  carthage
Laravel Geo Routes
GeoLocation restricted routes for Laravel
Stars: ✭ 110 (-0.9%)
Mutual labels:  geolocation
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+9545.05%)
Mutual labels:  carthage
Fscalendar
A fully customizable iOS calendar library, compatible with Objective-C and Swift
Stars: ✭ 9,829 (+8754.95%)
Mutual labels:  carthage
Ccnpreferenceswindowcontroller
CCNPreferencesWindowController is an Objective-C subclass of NSWindowController that automatically manages your custom view controllers for handling app preferences.
Stars: ✭ 105 (-5.41%)
Mutual labels:  carthage
Indoor Navigation Algorithms
This is a public repository of a Navigine company that develops different kinds of indoor positioning algorithms with the main focus on indoor navigation. Here we will step by step publish the source code of our algorithm starting with trilateration.
Stars: ✭ 108 (-2.7%)
Mutual labels:  geolocation
Connectivity
🌐 Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access.
Stars: ✭ 1,476 (+1229.73%)
Mutual labels:  carthage
Szmentionsswift
Library to help handle mentions
Stars: ✭ 109 (-1.8%)
Mutual labels:  carthage
Geo ip
Retreive the geolocation of an IP address based on the ipinfodb.com webservice
Stars: ✭ 103 (-7.21%)
Mutual labels:  geolocation
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+1287.39%)
Mutual labels:  carthage
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+33139.64%)
Mutual labels:  carthage
Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (+0%)
Mutual labels:  carthage
Randomkit
Random data generation in Swift
Stars: ✭ 1,458 (+1213.51%)
Mutual labels:  carthage

MMDB-Swift

Language Version Carthage Compatible SPM Compatible Platform

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.

Swift Package Manager

Package.swift

import PackageDescription

let package = Package(
          name: "YOUR_AWESOME_PROJECT",
       targets: [],
  dependencies: [
                  .Package(
                    url: "https://github.com/lexrus/MMDB-Swift",
               versions: "0.0.1" ..< Version.max
                  )
                ]
)

Usage

guard let db = MMDB("PATH_TO_THE_DATABASE") else {
  print("Failed to open DB.")
  return
}
if let country = db.lookup("8.8.4.4") {
  print(country)
}

This outputs:

{
  "continent": {
    "code": "NA",
    "names": {
      "ja": "北アメリカ",
      "en": "North America",
      "ru": "Северная Америка",
      "es": "Norteamérica",
      "de": "Nordamerika",
      "zh-CN": "北美洲",
      "fr": "Amérique du Nord",
      "pt-BR": "América do Norte"
    }
  },
  "isoCode": "US",
  "names": {
    "ja": "アメリカ合衆国",
    "en": "United States",
    "ru": "США",
    "es": "Estados Unidos",
    "de": "USA",
    "zh-CN": "美国",
    "fr": "États-Unis",
    "pt-BR": "Estados Unidos"
  }
}

Notice that country is a struct defined as:

public struct MMDBContinent {
  var code: String?
  var names: [String: String]?
}

public struct MMDBCountry: CustomStringConvertible {
  var continent = MMDBContinent()
  var isoCode = ""
  var names = [String: String]()
  ...
}

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].