{"id":13423370,"url":"https://github.com/lexrus/MMDB-Swift","last_synced_at":"2025-03-15T17:31:41.976Z","repository":{"id":62446913,"uuid":"48214188","full_name":"lexrus/MMDB-Swift","owner":"lexrus","description":"A tiny wrapper for libmaxminddb which allows you to lookup Geo data by IP address.","archived":false,"fork":false,"pushed_at":"2020-12-10T16:09:12.000Z","size":21123,"stargazers_count":123,"open_issues_count":3,"forks_count":61,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-05T04:12:42.625Z","etag":null,"topics":["carthage","geolite2","geolocation","maxmind","swift"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lexrus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-18T04:20:40.000Z","updated_at":"2024-08-09T16:00:51.000Z","dependencies_parsed_at":"2022-11-01T23:05:51.132Z","dependency_job_id":null,"html_url":"https://github.com/lexrus/MMDB-Swift","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexrus%2FMMDB-Swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexrus%2FMMDB-Swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexrus%2FMMDB-Swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexrus%2FMMDB-Swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lexrus","download_url":"https://codeload.github.com/lexrus/MMDB-Swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243766826,"owners_count":20344819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","geolite2","geolocation","maxmind","swift"],"created_at":"2024-07-31T00:00:32.990Z","updated_at":"2025-03-15T17:31:41.613Z","avatar_url":"https://github.com/lexrus.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# MMDB-Swift\n\n![Language](https://img.shields.io/badge/language-Swift%205-orange.svg)\n[![Version](https://img.shields.io/cocoapods/v/MMDB-Swift.svg?style=flat)](http://cocoapods.org/pods/MMDB-Swift)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-✓-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![SPM Compatible](https://img.shields.io/badge/SPM-✓-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n![Platform](https://img.shields.io/badge/platform-iOS%7COSX%7CLinux-lightgrey.svg)\n\n\nA tiny wrapper for [libmaxminddb](https://github.com/maxmind/libmaxminddb) which allows you to lookup Geo data by IP address.\n\n---\n\n**NOTE** From `v0.5.0`, MMDB-Swift no longer bundles [GeoLite2 database](http://dev.maxmind.com/geoip/geoip2/geolite2/) due to the license change. Developers should download the binary version from the [Maxmind website](http://dev.maxmind.com/geoip/geoip2/geolite2/).\n\n## CocoaPods\n\nMMDB-Swift is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile:\n\n``` ruby\nplatform :ios, '8.0'\nuse_frameworks!\npod \"MMDB-Swift\"\n```\n\nThen, run the following command:\n\n``` bash\npod install\n```\n\n## Carthage\n\nTo integrate MMDB-Swift into your Xcode project using Carthage, add the following line to your `Cartfile`:\n\n``` \ngithub \"lexrus/MMDB-Swift\"\n```\n\nRun `carthage update` to build the frameworks and drag the built `MMDB.framework` into your Xcode project.\n\n## Swift Package Manager\n\nPackage.swift\n\n``` swift\nimport PackageDescription\n\nlet package = Package(\n          name: \"YOUR_AWESOME_PROJECT\",\n       targets: [],\n  dependencies: [\n                  .Package(\n                    url: \"https://github.com/lexrus/MMDB-Swift\",\n               versions: \"0.0.1\" ..\u003c Version.max\n                  )\n                ]\n)\n```\n\n\n## Usage\n\n``` swift\nguard let db = MMDB(\"PATH_TO_THE_DATABASE\") else {\n  print(\"Failed to open DB.\")\n  return\n}\nif let country = db.lookup(\"8.8.4.4\") {\n  print(country)\n}\n```\n\nThis outputs:\n\n``` json\n{\n  \"continent\": {\n    \"code\": \"NA\",\n    \"names\": {\n      \"ja\": \"北アメリカ\",\n      \"en\": \"North America\",\n      \"ru\": \"Северная Америка\",\n      \"es\": \"Norteamérica\",\n      \"de\": \"Nordamerika\",\n      \"zh-CN\": \"北美洲\",\n      \"fr\": \"Amérique du Nord\",\n      \"pt-BR\": \"América do Norte\"\n    }\n  },\n  \"isoCode\": \"US\",\n  \"names\": {\n    \"ja\": \"アメリカ合衆国\",\n    \"en\": \"United States\",\n    \"ru\": \"США\",\n    \"es\": \"Estados Unidos\",\n    \"de\": \"USA\",\n    \"zh-CN\": \"美国\",\n    \"fr\": \"États-Unis\",\n    \"pt-BR\": \"Estados Unidos\"\n  }\n}\n```\n\nNotice that country is a struct defined as:\n\n``` swift\npublic struct MMDBContinent {\n  var code: String?\n  var names: [String: String]?\n}\n\npublic struct MMDBCountry: CustomStringConvertible {\n  var continent = MMDBContinent()\n  var isoCode = \"\"\n  var names = [String: String]()\n  ...\n}\n```\n\n## Author\n\n[Lex Tang](https://github.com/lexrus) (Twitter: [@lexrus](https://twitter.com/lexrus))\n\n## License\n\nMMDB-Swift is available under the [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). See the [LICENSE](https://github.com/lexrus/MMDB-Swift/blob/master/LICENSE) file for more info.\n\nThe GeoLite2 databases are distributed under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexrus%2FMMDB-Swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flexrus%2FMMDB-Swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexrus%2FMMDB-Swift/lists"}