Skip to content

Commit 745c9f1

Browse files
author
Bobby Sudekum
authored
Merge pull request #130 from mapbox/fred-objc
Expose reverse and forward initializers to Obj-C
2 parents 6ca1b86 + eb7da18 commit 745c9f1

File tree

3 files changed

+57
-10
lines changed

3 files changed

+57
-10
lines changed

MapboxGeocoder.xcodeproj/project.pbxproj

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
35506B8B200F856400629509 /* BridgingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35506B8A200F856400629509 /* BridgingTests.m */; };
11+
35506B8C200F856400629509 /* BridgingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35506B8A200F856400629509 /* BridgingTests.m */; };
12+
35506B8D200F856400629509 /* BridgingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35506B8A200F856400629509 /* BridgingTests.m */; };
1013
DA1AC0221E5C23B8006DF1D6 /* Contacts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1AC0211E5C23B8006DF1D6 /* Contacts.framework */; };
1114
DA1AC0241E5C2425006DF1D6 /* Contacts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1AC0231E5C2425006DF1D6 /* Contacts.framework */; };
1215
DA1AC0261E5C2436006DF1D6 /* Contacts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1AC0251E5C2436006DF1D6 /* Contacts.framework */; };
@@ -141,6 +144,7 @@
141144
/* End PBXCopyFilesBuildPhase section */
142145

143146
/* Begin PBXFileReference section */
147+
35506B8A200F856400629509 /* BridgingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BridgingTests.m; sourceTree = "<group>"; };
144148
DA1AC0211E5C23B8006DF1D6 /* Contacts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Contacts.framework; path = System/Library/Frameworks/Contacts.framework; sourceTree = SDKROOT; };
145149
DA1AC0231E5C2425006DF1D6 /* Contacts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Contacts.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Contacts.framework; sourceTree = DEVELOPER_DIR; };
146150
DA1AC0251E5C2436006DF1D6 /* Contacts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Contacts.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.1.sdk/System/Library/Frameworks/Contacts.framework; sourceTree = DEVELOPER_DIR; };
@@ -376,6 +380,7 @@
376380
DA210BAA1CB4BE73008088FD /* ForwardGeocodingTests.swift */,
377381
DDF1E84C1BD6F7BA00C40C78 /* ReverseGeocodingTests.swift */,
378382
DA4D90061DD63AEC006EC71A /* PlacemarkScopeTests.swift */,
383+
35506B8A200F856400629509 /* BridgingTests.m */,
379384
DDF1E84E1BD6F7BA00C40C78 /* Info.plist */,
380385
DDF1E8571BD700EB00C40C78 /* Fixtures */,
381386
);
@@ -622,15 +627,15 @@
622627
};
623628
DA51709E1CF1B18F00CD6DCF = {
624629
CreatedOnToolsVersion = 7.3.1;
625-
LastSwiftMigration = 0910;
630+
LastSwiftMigration = 0920;
626631
};
627632
DA5170C01CF253EE00CD6DCF = {
628633
CreatedOnToolsVersion = 7.3.1;
629634
LastSwiftMigration = 0910;
630635
};
631636
DA5170C91CF253EE00CD6DCF = {
632637
CreatedOnToolsVersion = 7.3.1;
633-
LastSwiftMigration = 0910;
638+
LastSwiftMigration = 0920;
634639
};
635640
DA5170EA1CF2581900CD6DCF = {
636641
CreatedOnToolsVersion = 7.3.1;
@@ -650,7 +655,7 @@
650655
};
651656
DDF1E8491BD6F7BA00C40C78 = {
652657
CreatedOnToolsVersion = 7.0.1;
653-
LastSwiftMigration = 0910;
658+
LastSwiftMigration = 0920;
654659
};
655660
};
656661
};
@@ -843,6 +848,7 @@
843848
isa = PBXSourcesBuildPhase;
844849
buildActionMask = 2147483647;
845850
files = (
851+
35506B8C200F856400629509 /* BridgingTests.m in Sources */,
846852
DA5170B61CF1B1EF00CD6DCF /* ReverseGeocodingTests.swift in Sources */,
847853
DA4D90081DD63AEC006EC71A /* PlacemarkScopeTests.swift in Sources */,
848854
DA5170B41CF1B1EF00CD6DCF /* GeocoderTests.swift in Sources */,
@@ -866,6 +872,7 @@
866872
isa = PBXSourcesBuildPhase;
867873
buildActionMask = 2147483647;
868874
files = (
875+
35506B8D200F856400629509 /* BridgingTests.m in Sources */,
869876
DA5170E11CF2542800CD6DCF /* ReverseGeocodingTests.swift in Sources */,
870877
DA4D90091DD63AEC006EC71A /* PlacemarkScopeTests.swift in Sources */,
871878
DA5170DF1CF2542800CD6DCF /* GeocoderTests.swift in Sources */,
@@ -920,6 +927,7 @@
920927
isa = PBXSourcesBuildPhase;
921928
buildActionMask = 2147483647;
922929
files = (
930+
35506B8B200F856400629509 /* BridgingTests.m in Sources */,
923931
DDF1E84D1BD6F7BA00C40C78 /* ReverseGeocodingTests.swift in Sources */,
924932
DA4D90071DD63AEC006EC71A /* PlacemarkScopeTests.swift in Sources */,
925933
DA210BAB1CB4BE73008088FD /* ForwardGeocodingTests.swift in Sources */,
@@ -1033,6 +1041,7 @@
10331041
isa = XCBuildConfiguration;
10341042
buildSettings = {
10351043
CLANG_ANALYZER_NONNULL = YES;
1044+
CLANG_ENABLE_MODULES = YES;
10361045
CODE_SIGN_IDENTITY = "-";
10371046
COMBINE_HIDPI_IMAGES = YES;
10381047
DEBUG_INFORMATION_FORMAT = dwarf;
@@ -1046,6 +1055,7 @@
10461055
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
10471056
PRODUCT_NAME = MapboxGeocoderTests;
10481057
SDKROOT = macosx;
1058+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
10491059
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
10501060
SWIFT_VERSION = 4.0;
10511061
};
@@ -1055,6 +1065,7 @@
10551065
isa = XCBuildConfiguration;
10561066
buildSettings = {
10571067
CLANG_ANALYZER_NONNULL = YES;
1068+
CLANG_ENABLE_MODULES = YES;
10581069
CODE_SIGN_IDENTITY = "-";
10591070
COMBINE_HIDPI_IMAGES = YES;
10601071
COPY_PHASE_STRIP = NO;
@@ -1145,6 +1156,7 @@
11451156
isa = XCBuildConfiguration;
11461157
buildSettings = {
11471158
CLANG_ANALYZER_NONNULL = YES;
1159+
CLANG_ENABLE_MODULES = YES;
11481160
DEBUG_INFORMATION_FORMAT = dwarf;
11491161
FRAMEWORK_SEARCH_PATHS = (
11501162
"$(inherited)",
@@ -1156,6 +1168,7 @@
11561168
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
11571169
PRODUCT_NAME = MapboxGeocoderTests;
11581170
SDKROOT = appletvos;
1171+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
11591172
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
11601173
SWIFT_VERSION = 4.0;
11611174
TVOS_DEPLOYMENT_TARGET = 9.0;
@@ -1166,6 +1179,7 @@
11661179
isa = XCBuildConfiguration;
11671180
buildSettings = {
11681181
CLANG_ANALYZER_NONNULL = YES;
1182+
CLANG_ENABLE_MODULES = YES;
11691183
COPY_PHASE_STRIP = NO;
11701184
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
11711185
FRAMEWORK_SEARCH_PATHS = (
@@ -1474,6 +1488,7 @@
14741488
DDF1E8531BD6F7BA00C40C78 /* Debug */ = {
14751489
isa = XCBuildConfiguration;
14761490
buildSettings = {
1491+
CLANG_ENABLE_MODULES = YES;
14771492
DEBUG_INFORMATION_FORMAT = dwarf;
14781493
FRAMEWORK_SEARCH_PATHS = (
14791494
"$(inherited)",
@@ -1484,6 +1499,7 @@
14841499
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
14851500
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
14861501
PRODUCT_NAME = "$(TARGET_NAME)";
1502+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
14871503
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
14881504
SWIFT_VERSION = 4.0;
14891505
};
@@ -1492,6 +1508,7 @@
14921508
DDF1E8541BD6F7BA00C40C78 /* Release */ = {
14931509
isa = XCBuildConfiguration;
14941510
buildSettings = {
1511+
CLANG_ENABLE_MODULES = YES;
14951512
COPY_PHASE_STRIP = NO;
14961513
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
14971514
FRAMEWORK_SEARCH_PATHS = (

MapboxGeocoder/MBGeocodeOptions.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ open class ForwardGeocodeOptions: GeocodeOptions {
128128

129129
- parameter query: A place name or address to search for. The query may have a maximum of 20 words or numbers; it may have up to 256 characters including spaces and punctuation.
130130
*/
131-
public convenience init(query: String) {
131+
@objc public convenience init(query: String) {
132132
self.init(queries: [query])
133133
}
134134

@@ -139,7 +139,7 @@ open class ForwardGeocodeOptions: GeocodeOptions {
139139
- parameter postalAddress: A `CNPostalAddress` object to search for.
140140
*/
141141
@available(iOS 9.0, OSX 10.11, *)
142-
public convenience init(postalAddress: CNPostalAddress) {
142+
@objc public convenience init(postalAddress: CNPostalAddress) {
143143
let formattedAddress = CNPostalAddressFormatter().string(from: postalAddress)
144144
self.init(query: formattedAddress.replacingOccurrences(of: "\n", with: ", "))
145145
}
@@ -176,7 +176,7 @@ open class ReverseGeocodeOptions: GeocodeOptions {
176176

177177
- parameter coordinate: A coordinate pair to search for.
178178
*/
179-
public convenience init(coordinate: CLLocationCoordinate2D) {
179+
@objc public convenience init(coordinate: CLLocationCoordinate2D) {
180180
self.init(coordinates: [coordinate])
181181
}
182182

@@ -185,7 +185,7 @@ open class ReverseGeocodeOptions: GeocodeOptions {
185185

186186
- parameter location: A `CLLocation` object to search for.
187187
*/
188-
public convenience init(location: CLLocation) {
188+
@objc public convenience init(location: CLLocation) {
189189
self.init(coordinate: location.coordinate)
190190
}
191191
}
@@ -210,7 +210,7 @@ open class ForwardBatchGeocodeOptions: ForwardGeocodeOptions, BatchGeocodeOption
210210

211211
- parameter queries: An array of up to 50 place names or addresses to search for. An individual query may have a maximum of 20 words or numbers; it may have up to 256 characters including spaces and punctuation.
212212
*/
213-
public override init(queries: [String]) {
213+
@objc public override init(queries: [String]) {
214214
super.init(queries: queries)
215215
}
216216
}
@@ -225,7 +225,7 @@ open class ReverseBatchGeocodeOptions: ReverseGeocodeOptions, BatchGeocodeOption
225225

226226
- parameter coordinates: An array of up to 50 coordinate pairs to search for.
227227
*/
228-
public override init(coordinates: [CLLocationCoordinate2D]) {
228+
@objc public override init(coordinates: [CLLocationCoordinate2D]) {
229229
super.init(coordinates: coordinates)
230230
}
231231

@@ -234,7 +234,7 @@ open class ReverseBatchGeocodeOptions: ReverseGeocodeOptions, BatchGeocodeOption
234234

235235
- parameter location: An array of up to 50 `CLLocation` objects to search for.
236236
*/
237-
public convenience init(locations: [CLLocation]) {
237+
@objc public convenience init(locations: [CLLocation]) {
238238
self.init(coordinates: locations.map { $0.coordinate })
239239
}
240240
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#import <XCTest/XCTest.h>
2+
@import MapboxGeocoder;
3+
4+
@interface BridgingTests : XCTestCase
5+
@end
6+
7+
@implementation BridgingTests
8+
9+
- (void)setUp {
10+
[super setUp];
11+
// Put setup code here. This method is called before the invocation of each test method in the class.
12+
}
13+
14+
- (void)testReverseGeocodingOptions {
15+
XCTAssertNotNil([[MBReverseGeocodeOptions alloc] initWithCoordinate:CLLocationCoordinate2DMake(0, 0)]);
16+
}
17+
18+
- (void)testForwardGeocodingOptions {
19+
XCTAssertNotNil([[MBForwardGeocodeOptions alloc] initWithQuery:@"Golden Gate Bridge"]);
20+
}
21+
22+
- (void)testMBGeocoder {
23+
XCTAssertNotNil([[MBGeocoder alloc] initWithAccessToken:@"pk.foo"]);
24+
}
25+
26+
- (void)testMBPlacemark {
27+
XCTAssertNotNil([MBPlacemark alloc]);
28+
}
29+
30+
@end

0 commit comments

Comments
 (0)