Skip to content

Commit 9837187

Browse files
committed
Merge pull request #48 from mapbox/1ec5-tvos
Support tvOS, watchOS
2 parents ae180c1 + 742609a commit 9837187

File tree

9 files changed

+635
-7
lines changed

9 files changed

+635
-7
lines changed

MapboxGeocoder.swift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Pod::Spec.new do |s|
77
s.summary = "Mapbox Geocoding API for Swift and Objective-C."
88

99
s.description = <<-DESC
10-
MapboxGeocoder.swift makes it easy to connect your iOS or OS X application to the Mapbox Geocoding API. MapboxGeocoder.swift exposes the power of the Carmen geocoder through a simple API similar to Core Location’s CLGeocoder.
10+
MapboxGeocoder.swift makes it easy to connect your iOS, OS X, tvOS, or watchOS application to the Mapbox Geocoding API. MapboxGeocoder.swift exposes the power of the Carmen geocoder through a simple API similar to Core Location’s CLGeocoder.
1111
DESC
1212

1313
s.homepage = "https://www.mapbox.com/geocoding/"

MapboxGeocoder.xcodeproj/project.pbxproj

Lines changed: 426 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0730"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "DA5170C01CF253EE00CD6DCF"
18+
BuildableName = "MapboxGeocoder.framework"
19+
BlueprintName = "MapboxGeocoderTV"
20+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "DA5170C91CF253EE00CD6DCF"
36+
BuildableName = "MapboxGeocoderTests.xctest"
37+
BlueprintName = "MapboxGeocoderTVTests"
38+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
<MacroExpansion>
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "DA5170C01CF253EE00CD6DCF"
46+
BuildableName = "MapboxGeocoder.framework"
47+
BlueprintName = "MapboxGeocoderTV"
48+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
49+
</BuildableReference>
50+
</MacroExpansion>
51+
<AdditionalOptions>
52+
</AdditionalOptions>
53+
</TestAction>
54+
<LaunchAction
55+
buildConfiguration = "Debug"
56+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
57+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
58+
launchStyle = "0"
59+
useCustomWorkingDirectory = "NO"
60+
ignoresPersistentStateOnLaunch = "NO"
61+
debugDocumentVersioning = "YES"
62+
debugServiceExtension = "internal"
63+
allowLocationSimulation = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "DA5170C01CF253EE00CD6DCF"
68+
BuildableName = "MapboxGeocoder.framework"
69+
BlueprintName = "MapboxGeocoderTV"
70+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
<AdditionalOptions>
74+
</AdditionalOptions>
75+
</LaunchAction>
76+
<ProfileAction
77+
buildConfiguration = "Release"
78+
shouldUseLaunchSchemeArgsEnv = "YES"
79+
savedToolIdentifier = ""
80+
useCustomWorkingDirectory = "NO"
81+
debugDocumentVersioning = "YES">
82+
<MacroExpansion>
83+
<BuildableReference
84+
BuildableIdentifier = "primary"
85+
BlueprintIdentifier = "DA5170C01CF253EE00CD6DCF"
86+
BuildableName = "MapboxGeocoder.framework"
87+
BlueprintName = "MapboxGeocoderTV"
88+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
89+
</BuildableReference>
90+
</MacroExpansion>
91+
</ProfileAction>
92+
<AnalyzeAction
93+
buildConfiguration = "Debug">
94+
</AnalyzeAction>
95+
<ArchiveAction
96+
buildConfiguration = "Release"
97+
revealArchiveInOrganizer = "YES">
98+
</ArchiveAction>
99+
</Scheme>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0730"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "DA5170EA1CF2581900CD6DCF"
18+
BuildableName = "MapboxGeocoderWatch.framework"
19+
BlueprintName = "MapboxGeocoderWatch"
20+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<AdditionalOptions>
33+
</AdditionalOptions>
34+
</TestAction>
35+
<LaunchAction
36+
buildConfiguration = "Debug"
37+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
38+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
39+
launchStyle = "0"
40+
useCustomWorkingDirectory = "NO"
41+
ignoresPersistentStateOnLaunch = "NO"
42+
debugDocumentVersioning = "YES"
43+
debugServiceExtension = "internal"
44+
allowLocationSimulation = "YES">
45+
<MacroExpansion>
46+
<BuildableReference
47+
BuildableIdentifier = "primary"
48+
BlueprintIdentifier = "DA5170EA1CF2581900CD6DCF"
49+
BuildableName = "MapboxGeocoderWatch.framework"
50+
BlueprintName = "MapboxGeocoderWatch"
51+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
52+
</BuildableReference>
53+
</MacroExpansion>
54+
<AdditionalOptions>
55+
</AdditionalOptions>
56+
</LaunchAction>
57+
<ProfileAction
58+
buildConfiguration = "Release"
59+
shouldUseLaunchSchemeArgsEnv = "YES"
60+
savedToolIdentifier = ""
61+
useCustomWorkingDirectory = "NO"
62+
debugDocumentVersioning = "YES">
63+
<MacroExpansion>
64+
<BuildableReference
65+
BuildableIdentifier = "primary"
66+
BlueprintIdentifier = "DA5170EA1CF2581900CD6DCF"
67+
BuildableName = "MapboxGeocoderWatch.framework"
68+
BlueprintName = "MapboxGeocoderWatch"
69+
ReferencedContainer = "container:MapboxGeocoder.xcodeproj">
70+
</BuildableReference>
71+
</MacroExpansion>
72+
</ProfileAction>
73+
<AnalyzeAction
74+
buildConfiguration = "Debug">
75+
</AnalyzeAction>
76+
<ArchiveAction
77+
buildConfiguration = "Release"
78+
revealArchiveInOrganizer = "YES">
79+
</ArchiveAction>
80+
</Scheme>

MapboxGeocoder/MBGeocodeOptions.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import Contacts
1+
#if !os(tvOS)
2+
import Contacts
3+
#endif
24

35
/**
46
A structure that specifies the criteria for results returned by the Mapbox Geocoding API.
@@ -98,6 +100,7 @@ public class ForwardGeocodeOptions: GeocodeOptions {
98100
self.init(queries: [query])
99101
}
100102

103+
#if !os(tvOS)
101104
/**
102105
Initializes a forward geocode options object with the given postal address object.
103106

@@ -108,6 +111,7 @@ public class ForwardGeocodeOptions: GeocodeOptions {
108111
let formattedAddress = CNPostalAddressFormatter().stringFromPostalAddress(postalAddress)
109112
self.init(query: formattedAddress.stringByReplacingOccurrencesOfString("\n", withString: ", "))
110113
}
114+
#endif
111115

112116
override var params: [NSURLQueryItem] {
113117
var params = super.params

MapboxGeocoder/MBPlacemark.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import Contacts
1+
#if !os(tvOS)
2+
import Contacts
3+
#endif
24

35
// MARK: Postal Address Properties
46

@@ -221,6 +223,7 @@ public class Placemark: NSObject, NSCopying, NSSecureCoding {
221223
return nil
222224
}
223225

226+
#if !os(tvOS)
224227
/**
225228
The placemark’s postal address.
226229

@@ -230,6 +233,7 @@ public class Placemark: NSObject, NSCopying, NSSecureCoding {
230233
public var postalAddress: CNPostalAddress? {
231234
return nil
232235
}
236+
#endif
233237

234238
/**
235239
A dictionary containing the Contacts keys and values for the placemark.
@@ -424,6 +428,7 @@ public class GeocodedPlacemark: Placemark {
424428
return scope == .Address ? lines : Array(lines.suffixFrom(1))
425429
}
426430

431+
#if !os(tvOS)
427432
@available(iOS 9.0, OSX 10.11, *)
428433
public override var postalAddress: CNPostalAddress? {
429434
let postalAddress = CNMutablePostalAddress()
@@ -452,6 +457,7 @@ public class GeocodedPlacemark: Placemark {
452457

453458
return postalAddress
454459
}
460+
#endif
455461

456462
public override var addressDictionary: [NSObject: AnyObject]? {
457463
var addressDictionary: [String: AnyObject] = [:]

MapboxGeocoder/MapboxGeocoder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#import <Foundation/Foundation.h>
22
#import <CoreLocation/CoreLocation.h>
3+
#if !TARGET_OS_TV
34
#import <Contacts/Contacts.h>
5+
#endif
46

57
FOUNDATION_EXPORT double MapboxGeocoderVersionNumber;
68

Podfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ target 'MapboxGeocoderMacTests' do
2020
platform :osx, '10.10'
2121
shared_test_pods
2222
end
23+
24+
target 'MapboxGeocoderTVTests' do
25+
platform :tvos, '9.0'
26+
shared_test_pods
27+
end

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[📱&nbsp;![iOS Build Status](https://www.bitrise.io/app/6cae401ec4c1d406.svg?token=MJnXK0c2x2tmTnmHSPtcFA&branch=master)](https://www.bitrise.io/app/6cae401ec4c1d406) &nbsp;&nbsp;&nbsp;
44
[🖥💻&nbsp;![OS X Build Status](https://www.bitrise.io/app/8413a6e577d6aa9a.svg?token=N1agv0mw75SOE_SykliueQ&branch=master)](https://www.bitrise.io/app/8413a6e577d6aa9a)
55

6-
MapboxGeocoder.swift makes it easy to connect your iOS or OS X application to the [Mapbox Geocoding API](https://www.mapbox.com/geocoding/). MapboxGeocoder.swift exposes the power of the [Carmen](https://github.com/mapbox/carmen) geocoder through a simple API similar to Core Location’s CLGeocoder.
6+
MapboxGeocoder.swift makes it easy to connect your iOS, OS X, tvOS, or watchOS application to the [Mapbox Geocoding API](https://www.mapbox.com/geocoding/). MapboxGeocoder.swift exposes the power of the [Carmen](https://github.com/mapbox/carmen) geocoder through a simple API similar to Core Location’s CLGeocoder.
77

88
MapboxGeocoder.swift pairs well with [MapboxDirections.swift](https://github.com/mapbox/MapboxDirections.swift), [MapboxStatic.swift](https://github.com/mapbox/MapboxStatic.swift), and the [Mapbox iOS SDK](https://www.mapbox.com/ios-sdk/) or [OS X SDK](https://github.com/mapbox/mapbox-gl-native/tree/master/platform/osx).
99

@@ -59,7 +59,9 @@ _Forward geocoding_ takes a human-readable query, such as a place name or addres
5959

6060
```swift
6161
// main.swift
62-
import Contacts
62+
#if !os(tvOS)
63+
import Contacts
64+
#endif
6365

6466
let options = ForwardGeocodeOptions(query: "200 queen street")
6567

@@ -79,17 +81,21 @@ let task = geocoder.geocode(options: options) { (placemarks, attribution, error)
7981
print("\(coordinate.latitude), \(coordinate.longitude)")
8082
// 45.270093, -66.050985
8183

84+
#if !os(tvOS)
8285
let formatter = CNPostalAddressFormatter()
8386
print(formatter.stringFromPostalAddress(placemark.postalAddress))
8487
// 200 Queen St
8588
// Saint John New Brunswick E2L 2X1
8689
// Canada
90+
#endif
8791
}
8892
```
8993

9094
```objc
9195
// main.m
96+
#if !TARGET_OS_TV
9297
@import Contacts;
98+
#endif
9399

94100
MBForwardGeocodeOptions *options = [[MBForwardGeocodeOptions alloc] initWithQuery:@"200 queen street"];
95101

@@ -112,11 +118,13 @@ NSURLSessionDataTask *task = [geocoder geocodeWithOptions:options
112118
NSLog(@"%f, %f", coordinate.latitude, coordinate.longitude);
113119
// 45.270093, -66.050985
114120

121+
#if !TARGET_OS_TV
115122
CNPostalAddressFormatter *formatter = [[CNPostalAddressFormatter alloc] init];
116123
NSLog(@"%@", [formatter stringFromPostalAddress:placemark.postalAddress]);
117124
// 200 Queen St
118125
// Saint John New Brunswick E2L 2X1
119126
// Canada
127+
#endif
120128
}];
121129
```
122130

0 commit comments

Comments
 (0)