Skip to content

Commit

Permalink
Merge pull request #15 from lexrus/no_bundled_db
Browse files Browse the repository at this point in the history
Remove bundled Geolite2 db due to license change
  • Loading branch information
lexrus authored Jan 4, 2020
2 parents dbf2b01 + 8b698b4 commit 3901d0e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 75 deletions.
5 changes: 1 addition & 4 deletions MMDB-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MMDB-Swift"
s.version = "0.4.0"
s.version = "0.5.0"
s.summary = "A wrapper for MaxMind DB"
s.description = <<-DESC
A tiny wrapper for libmaxminddb which allows you to lookup
Expand All @@ -27,9 +27,6 @@ Pod::Spec.new do |s|
s.ios.public_header_files = "Sources/libmaxminddb/*.h", "Sources/MMDB.h"
s.osx.public_header_files = "Sources/libmaxminddb/*.h", "Sources/MMDB.h"

s.prepare_command = "./update_database.sh"
s.resource = "Sources/libmaxminddb/GeoLite2-Country.mmdb"

s.framework = "Foundation"
s.requires_arc = true
end
47 changes: 5 additions & 42 deletions MMDB.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
366F5FE91F052F7F00DE3883 /* MMDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D716CB471C23A58700D89B5C /* MMDB.framework */; };
366F5FF81F05301400DE3883 /* MMDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D716CB541C23A5DC00D89B5C /* MMDB.framework */; };
366F5FFE1F05302300DE3883 /* MMDBTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366F5FE61F052F7F00DE3883 /* MMDBTests.swift */; };
36D1827B23C0688C002E42A5 /* GeoLite2-Country.mmdb in Resources */ = {isa = PBXBuildFile; fileRef = D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */; };
36D1827C23C0688D002E42A5 /* GeoLite2-Country.mmdb in Resources */ = {isa = PBXBuildFile; fileRef = D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */; };
D716CB5C1C23A65200D89B5C /* maxminddb.c in Sources */ = {isa = PBXBuildFile; fileRef = D73CAECC1C21A7A2000C2132 /* maxminddb.c */; };
D716CB5D1C23A65200D89B5C /* maxminddb_unions.c in Sources */ = {isa = PBXBuildFile; fileRef = D716CB3F1C2269D200D89B5C /* maxminddb_unions.c */; };
D716CB5E1C23A65D00D89B5C /* MMDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = D716CB321C21432C00D89B5C /* MMDB.swift */; };
D716CB5F1C23A66C00D89B5C /* MMDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = D716CB321C21432C00D89B5C /* MMDB.swift */; };
D716CB601C23A66C00D89B5C /* maxminddb.c in Sources */ = {isa = PBXBuildFile; fileRef = D73CAECC1C21A7A2000C2132 /* maxminddb.c */; };
D716CB611C23A66C00D89B5C /* maxminddb_unions.c in Sources */ = {isa = PBXBuildFile; fileRef = D716CB3F1C2269D200D89B5C /* maxminddb_unions.c */; };
D736A97E1C23B59D0070EAA3 /* GeoLite2-Country.mmdb in Resources */ = {isa = PBXBuildFile; fileRef = D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */; };
D736A97F1C23B59F0070EAA3 /* GeoLite2-Country.mmdb in Resources */ = {isa = PBXBuildFile; fileRef = D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */; };
D736A9811C23B7D40070EAA3 /* maxminddb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = D73CAECE1C21A7B0000C2132 /* maxminddb_config.h */; settings = {ATTRIBUTES = (Public, ); }; };
D736A9821C23B7D40070EAA3 /* maxminddb-compat-util.h in Headers */ = {isa = PBXBuildFile; fileRef = D73CAED11C21AAEA000C2132 /* maxminddb-compat-util.h */; settings = {ATTRIBUTES = (Public, ); }; };
D736A9831C23B7D40070EAA3 /* maxminddb.h in Headers */ = {isa = PBXBuildFile; fileRef = D73CAECF1C21A7B0000C2132 /* maxminddb.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -71,9 +71,6 @@
D73CAECF1C21A7B0000C2132 /* maxminddb.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = maxminddb.h; sourceTree = "<group>"; };
D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */ = {isa = PBXFileReference; lastKnownFileType = file; path = "GeoLite2-Country.mmdb"; sourceTree = "<group>"; };
D73CAED11C21AAEA000C2132 /* maxminddb-compat-util.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "maxminddb-compat-util.h"; sourceTree = "<group>"; };
D77179AE1EF800B300E25F23 /* MMDB-Swift.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = "MMDB-Swift.podspec"; sourceTree = "<group>"; };
D77179AF1EF800B300E25F23 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
D77179B01EF800B300E25F23 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
D7999FEC2307B8B4003EB8CC /* data-pool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "data-pool.h"; sourceTree = "<group>"; };
D7999FED2307B8B4003EB8CC /* data-pool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "data-pool.c"; sourceTree = "<group>"; };
D7999FF22307B9D7003EB8CC /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -118,6 +115,7 @@
366F5FE51F052F7F00DE3883 /* MMDBTests */ = {
isa = PBXGroup;
children = (
D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */,
366F5FF71F05301400DE3883 /* Info-OSX.plist */,
366F5FE81F052F7F00DE3883 /* Info-iOS.plist */,
366F5FE61F052F7F00DE3883 /* MMDBTests.swift */,
Expand All @@ -136,9 +134,6 @@
D716CB311C21432C00D89B5C /* libmaxminddb */,
366F5FE51F052F7F00DE3883 /* MMDBTests */,
D716CB301C21432C00D89B5C /* Products */,
D77179AE1EF800B300E25F23 /* MMDB-Swift.podspec */,
D77179AF1EF800B300E25F23 /* Package.swift */,
D77179B01EF800B300E25F23 /* README.md */,
);
sourceTree = "<group>";
};
Expand All @@ -156,7 +151,6 @@
D716CB311C21432C00D89B5C /* libmaxminddb */ = {
isa = PBXGroup;
children = (
D73CAED01C21AA9A000C2132 /* GeoLite2-Country.mmdb */,
D73CAED11C21AAEA000C2132 /* maxminddb-compat-util.h */,
D73CAECC1C21A7A2000C2132 /* maxminddb.c */,
D73CAECF1C21A7B0000C2132 /* maxminddb.h */,
Expand Down Expand Up @@ -254,7 +248,6 @@
isa = PBXNativeTarget;
buildConfigurationList = D716CB4C1C23A58700D89B5C /* Build configuration list for PBXNativeTarget "MMDB-iOS" */;
buildPhases = (
366F5FDD1F05152C00DE3883 /* ShellScript */,
D716CB421C23A58700D89B5C /* Sources */,
D716CB431C23A58700D89B5C /* Frameworks */,
D716CB441C23A58700D89B5C /* Headers */,
Expand All @@ -273,7 +266,6 @@
isa = PBXNativeTarget;
buildConfigurationList = D716CB591C23A5DC00D89B5C /* Build configuration list for PBXNativeTarget "MMDB-OSX" */;
buildPhases = (
366F5FDE1F0515CD00DE3883 /* ShellScript */,
D716CB4F1C23A5DC00D89B5C /* Sources */,
D716CB501C23A5DC00D89B5C /* Frameworks */,
D716CB511C23A5DC00D89B5C /* Headers */,
Expand Down Expand Up @@ -343,63 +335,34 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
36D1827B23C0688C002E42A5 /* GeoLite2-Country.mmdb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
366F5FF11F05301400DE3883 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
36D1827C23C0688D002E42A5 /* GeoLite2-Country.mmdb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D716CB451C23A58700D89B5C /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D736A97E1C23B59D0070EAA3 /* GeoLite2-Country.mmdb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D716CB521C23A5DC00D89B5C /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D736A97F1C23B59F0070EAA3 /* GeoLite2-Country.mmdb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
366F5FDD1F05152C00DE3883 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ ! -f $SRCROOT/Sources/libmaxminddb/GeoLite2-Country.mmdb ] || [ $CONFIGURATION == \"Release\" ]; then\n $SRCROOT/update_database.sh\nfi";
};
366F5FDE1F0515CD00DE3883 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ ! -f $SRCROOT/MMDB/GeoLite2-Country.mmdb ] || [ $CONFIGURATION == \"Release\" ]; then\n $SRCROOT/update_database.sh\nfi";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
366F5FE01F052F7F00DE3883 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

A tiny wrapper for [libmaxminddb](https://github.com/maxmind/libmaxminddb) which allows you to lookup Geo data by IP address.

This product includes [GeoLite2 data](http://dev.maxmind.com/geoip/geoip2/geolite2/) created by MaxMind, available from [http://www.maxmind.com](http://www.maxmind.com).
---

**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/).

## CocoaPods

Expand Down Expand Up @@ -60,7 +62,7 @@ let package = Package(
## Usage

``` swift
guard let db = MMDB() else {
guard let db = MMDB("PATH_TO_THE_DATABASE") else {
print("Failed to open DB.")
return
}
Expand Down
7 changes: 2 additions & 5 deletions Sources/MMDB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ final public class MMDB {
fileprivate typealias ListPtr = UnsafeMutablePointer<MMDB_entry_data_list_s>
fileprivate typealias StringPtr = UnsafeMutablePointer<String>

public init?(_ filename: String? = nil) {
if let filename = filename, openDB(atPath: filename) { return }

let path = Bundle(for: MMDB.self).path(forResource: "GeoLite2-Country", ofType: "mmdb")
if let path = path, openDB(atPath: path) { return }
public init?(_ filename: String) {
if openDB(atPath: filename) { return }

return nil
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Tests/MMDBTests/MMDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MMDBTests: XCTestCase {

override func setUp() {
super.setUp()
database = MMDB()
database = MMDB(Bundle(for: MMDBTests.self).path(forResource: "GeoLite2-Country", ofType: "mmdb")!)
}

func testExample() {
Expand Down
21 changes: 0 additions & 21 deletions update_database.sh

This file was deleted.

0 comments on commit 3901d0e

Please # to comment.