Skip to content

Commit ef178fb

Browse files
authored
Merge pull request #15 from what3words/staging
MT-6899 core lib update does not support cocoapods
2 parents a83c2ba + 15fe9a5 commit ef178fb

29 files changed

+1132
-4179
lines changed

Documentation/api-sdk-compatibility.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,4 @@ Here are definitions of the `W3WProtocolV4` available functions:
160160
*/
161161
func availableLanguages(completion: @escaping W3WLanguagesResponse)
162162
163-
/**
164-
Verifies that the text is a valid three word address that successfully represents a square on earth.
165-
- parameter text: The text to search through
166-
- parameter completion: returns true if the address is a real three word address
167-
*/
168-
func isValid3wa(words: String, completion: @escaping (Bool) -> ())
169-
170163
```

Package.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ let package = Package(
1111
products: [
1212
// Products define the executables and libraries a package produces, and make them visible to other packages.
1313
.library(name: "W3WSwiftApi", targets: ["W3WSwiftApi"]),
14-
.library(name: "W3WSwiftVoiceApi", targets: ["W3WSwiftVoiceApi"]),
1514
],
1615

1716
dependencies: [
1817
// Dependencies declare other packages that this package depends on.
19-
.package(url: "https://github.com/what3words/w3w-swift-core.git", "1.0.0" ..< "2.0.0")
18+
.package(url: "https://github.com/what3words/w3w-swift-core.git", "1.0.0" ..< "2.0.0"),
19+
.package(url: "https://github.com/what3words/w3w-swift-voice-api.git", "1.0.0" ..< "2.0.0")
20+
2021
],
2122

2223
targets: [
23-
.target(name: "W3WSwiftApi", dependencies: ["W3WSwiftVoiceApi", .product(name: "W3WSwiftCore", package: "w3w-swift-core")]),
24-
.target(name: "W3WSwiftVoiceApi", dependencies: [.product(name: "W3WSwiftCore", package: "w3w-swift-core")]),
25-
.testTarget(name: "w3w-swift-wrapperTests", dependencies: ["W3WSwiftApi"]),
26-
.testTarget(name: "w3w-swift-wrapper-voiceTests", dependencies: ["W3WSwiftVoiceApi"]),
24+
.target(name: "W3WSwiftApi", dependencies: [
25+
.product(name: "W3WSwiftCore", package: "w3w-swift-core"),
26+
.product(name: "W3WSwiftVoiceApi", package: "w3w-swift-voice-api")
27+
]),
28+
.testTarget(name: "w3w-swift-wrapperTests", dependencies: ["W3WSwiftApi"])
2729
]
2830
)

README.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# <img valign='top' src="https://what3words.com/assets/images/w3w_square_red.png" width="64" height="64" alt="what3words">&nbsp;w3w-swift-wrapper
44

5-
A swift library to use the what3words [REST API](https://docs.what3words.com/api/v3/), and the what3words [VoiceAPI](https://developer.what3words.com/voice-api).
5+
A Swift library for interacting with the what3words [REST API](https://docs.what3words.com/api/v3/) and [VoiceAPI](https://developer.what3words.com/voice-api).
66

77
# Overview
88

@@ -17,13 +17,13 @@ The what3words Swift API wrapper gives you programmatic access to
1717

1818
The main API swift wrapper object is `What3WordsV3` and provides the above functionality. There is also a higher level `W3WAutosuggestHelper` that does a lot of the work of calling the API for text field autosuggest functionality. This is particularly helpful if you want to add what3words to your existing autocomplete code. A tutorial can be found [here](Documentation/tutorial-as-helper.md).
1919

20-
Even higher level UI functionality can be found in our UI components library, [w3w-swift-components](https://github.com/what3words/w3w-swift-components), found on GitHub. Notably our `W3WAutosuggestTextField` inherits `UITextField` and adds three word address autocomplete functionality.
20+
For even higher-level UI components, check out our [w3w-swift-components](https://github.com/what3words/w3w-swift-components) library on GitHub, including `W3WAutosuggestTextField` which extends `UITextField` to add three-word address autocomplete functionality.
2121

22-
#### TLDR:
22+
#### Quick Start:
2323

24-
You can find a short tutorial [here](Documentation/tutorial.md) that will show you how to get minimally set up and running.
24+
You can find a quick-start tutorial [here](Documentation/tutorial.md) to help you get set up and running with the basics.
2525

26-
#### Objective-C
26+
#### Objective-C Compatibility
2727

2828
This package also contains an Objective-C compatible version, `What3WordsObjC` - see the `ObjectiveC` project in [Examples/ObjectiveC/ObjectiveC.xcodeproj](./Examples/ObjectiveC/ObjectiveC.xcodeproj)
2929

@@ -43,7 +43,7 @@ To use this library you’ll need a what3words API key, which can be signed up f
4343

4444
# Examples
4545

46-
Examples for this package can be ofund in our exmaples repository:
46+
Examples of this package can be found in our examples repository:
4747
[https://github.com/what3words/w3w-swift-samples](https://github.com/what3words/w3w-swift-samples)
4848

4949
# Installation
@@ -58,27 +58,34 @@ https://github.com/what3words/w3w-swift-wrapper.git
5858

5959
#### CocoaPods (iOS 9+, OS X 10.10+)
6060

61-
You can use CocoaPods to install w3w-swift-wrapper by adding it to the target in your Podfile:
61+
You can use CocoaPods to install the `w3w-swift-wrapper` by adding it to the target in your Podfile:
6262

6363
```
6464
pod 'W3WSwiftApi', :git => 'https://github.com/what3words/w3w-swift-wrapper.git'
65+
```
66+
or, if you would like to use both the W3WSwiftApi and W3WSwiftVoiceApi libraries:
67+
68+
```
69+
pod 'W3WSwiftApi', :git => 'https://github.com/what3words/w3w-swift-wrapper.git'
70+
pod 'W3WSwiftVoiceApi', :git => 'https://github.com/what3words/w3w-swift-voice-api.git'
71+
6572
```
6673

6774
## Usage
6875

6976
### Import
7077

71-
In any file you use the what3words API in, import the following:
78+
In any file where you use the What3words API, import the following:
7279

73-
```swift
80+
```
7481
import W3WSwiftApi
82+
import W3WSwiftVoiceApi
7583
import CoreLocation
7684
```
7785

7886
##### Note:
7987

80-
* If you are using CocoaPods use `import what3words` instead.
81-
* If you are using this package's Voice API features on device, you should include Microphone permissions:
88+
* If you are using this package's Voice API features on your device, you should include Microphone permissions:
8289

8390
<img src="Documentation/plist2.png" width="75%">
8491

@@ -104,7 +111,7 @@ let api = What3WordsV3(apiKey: "YourApiKey", apiUrl: "https://api.yourserver.com
104111

105112
# Functions
106113

107-
Each call takes a completion block as the last parameter. This allows Swift's trailing closure syntax to be used. The closure's parameters contain the results. If there was a problem with any call, it will be indicated by the [error object](#errors).
114+
Each call takes a completion block as the last parameter. This allows Swift's trailing closure syntax to be used. The closure's parameters contain the results. If there is a problem with any call, it will be indicated by the [error object](#errors).
108115

109116
## Convert To 3 Word Address
110117

@@ -122,7 +129,7 @@ api.convertTo3wa(coordinates: coords, language: W3WApiLanguage(locale: "en")) {
122129

123130
## Convert To Coordinates
124131

125-
Convert a 3 word address to a position, expressed as coordinates of latitude and longitude. This function takes the words parameter as a string of 3 words `'table.book.chair'`. The values returned from the `convertToCoordinates` method are described in the [API documentation](https://docs.what3words.com/api/v3/#convert-to-coords).
132+
Convert a 3 word address into geographic coordinates, represented by latitude and longitude. This function takes the words parameter as a string of 3 words `'table.book.chair'`. The values returned from the `convertToCoordinates` method are described in the [API documentation](https://docs.what3words.com/api/v3/#convert-to-coords).
126133

127134
##### Code Example:
128135
```swift
@@ -135,7 +142,7 @@ api.convertToCoordinates(words: "filled.count.soap") { square, error in
135142

136143
Returns a list of 3 word addresses based on user input and other parameters.
137144

138-
This method provides corrections for the following types of input error:
145+
This method provides corrections for the following types of input errors:
139146

140147
* typing errors
141148
* spelling errors
@@ -144,17 +151,16 @@ This method provides corrections for the following types of input error:
144151

145152
The `autosuggest` method determines possible corrections to the supplied 3 word address string based on the probability of the input errors listed above and returns a ranked list of suggestions. This method can also take into consideration the geographic proximity of possible corrections to a given location to further improve the suggestions returned.
146153

147-
* voice
154+
* Voice
148155

149-
If you have a VoiceAPI enabled account, you may also call `autosuggest` with audio data for voice recognition. In order for this to work, you must add a Voice API plan to [your account](https://accounts.what3words.com/billing).
156+
If you have a VoiceAPI-enabled account, you may also call `autosuggest` with audio data for voice recognition. For this to work, you must add a Voice API plan to [your account](https://accounts.what3words.com/billing).
150157
There is a minimal [example of this below](#voice-example), but detailed information can be found [here](Documentation/README.voiceAPI.md)
151158

152159
### Input 3 word address
153160

154161
You will only receive results back if the partial 3 word address string you submit contains the first two words and at least the first character of the third word; otherwise an error message will be returned.
155162

156-
To check if your address string meets this criteria, we provide a simple function that employs our regex to help you recognise the three word addresses. It is called `isPossible3wa`, but please note that it only indicates if the input is three potential words separated by two w3w separators. It WILL NOT tell you if it is a real three word address in world. The following `if` evaluates to `true`.
157-
163+
To verify if your address string meets the required format, we offer a simple function called `isPossible3wa`. This function uses our regex to identify potential three word addresses, confirming only if the input consists of three words separated by two what3words separators. Please note that it does not validate whether the input is an actual three word address in the world. The following `if` statement will return `true.`
158164
```
159165
if api.isPossible3wa(text: "xxx.xxx.x") {
160166
print("Input is in the form of a three word address")
@@ -168,7 +174,7 @@ Or if you prefer, you can simply use our regex. Example code can be found in our
168174

169175
### Clipping
170176

171-
We provide various `clip` policies to allow you to filter by a geographic area. We recommend that you use the clipping to give a more targeted set of results to your user. You can clip by country, or by geographical box, circle or polygon. Do this via the `W3WOptions` and pass it into the autosuggest call (see example below).
177+
We provide various `clip` policies to allow you to filter by a geographic area. We recommend that you use the clipping options to give a more targeted set of results to your user. You can clip by country, or by geographical box, circle or polygon. Do this via the `W3WOptions` and pass it into the autosuggest call (see example below).
172178

173179
### Focus
174180

@@ -179,7 +185,7 @@ The values returned from the `autosuggest` method are described in the [what3wor
179185

180186
### Usage
181187

182-
The first parameter is the partial three words, or voice data. The second optional parameter is the options for the autosuggest function. The last parameter is the completion block.
188+
The first parameter is the partial three words or voice data. The second optional parameter is the options for the autosuggest function. The last parameter is the completion block.
183189

184190
#### Example One
185191
```swift
@@ -234,7 +240,7 @@ api.autosuggest(audio: microphone, options: .voiceLanguage(W3WApiLanguage(locale
234240
}
235241
```
236242

237-
Also, `W3WMicrophone` has a callback closure `W3WMicrophone.volumeUpdate: (Double) -> ()` that provides amplitude information useful for animating user feedback. See the the [Voice API example](./Examples/VoiceAPI/VoiceAPI.xcodeproj), and more information is avialable in the [VoiceAPI README](Documentation/README.voiceAPI.md).
243+
Also, `W3WMicrophone` has a callback closure `W3WMicrophone.volumeUpdate: (Double) -> ()` that provides amplitude information useful for animating user feedback. See the [Voice API example](./Examples/VoiceAPI/VoiceAPI.xcodeproj), and more information is available in the [VoiceAPI README](Documentation/README.voiceAPI.md).
238244

239245
## Available Languages
240246

@@ -255,7 +261,7 @@ For the available Voice API languages call `api.availableVoiceLanguages(completi
255261

256262
## Grid Section
257263

258-
Returns a section of the 3m x 3m what3words grid for a given area. The requested box must not exceed 4km from corner to corner, or a BadBoundingBoxTooBig error will be returned. Latitudes must be >= -90 and <= 90, but longitudes are allowed to wrap around 180. To specify a bounding-box that crosses the anti-meridian, use longitude greater than 180. Example value: 50.0, 179.995, 50.01, 180.0005.
264+
Returns a section of the 3m x 3m what3words grid for a given area. The requested box must not exceed 4km from corner to corner, or a BadBoundingBoxTooBig error will be returned. Latitudes must be >= -90 and <= 90, but longitudes are allowed to wrap around 180. To specify a bounding box that crosses the anti-meridian, use a longitude greater than 180. Example value: 50.0, 179.995, 50.01, 180.0005.
259265

260266
The grid is returned as `[W3WLine]?` and each `W3WLine` contains a `start` and `end` variable, both of type `CLLocationCoordinate2D`.
261267

@@ -279,7 +285,7 @@ These are some functions that will search or validate three word addresses.
279285

280286
#### isPossible3wa(text: String) -> Bool
281287

282-
Checks to see if the text follows the form of a three word address via regex, that is, a word followed by a separator followed by a word followed by a separator followed by a word. A word is defined as series of letters that belong to any writing system.
288+
Check to see if the text follows the form of a three word address via regex, that is, a word followed by a separator followed by a word followed by a separator followed by a word. A word is defined as series of letters that belong to any writing system.
283289
This does not validate the address as being a real location on the earth, just that it follows the textual form of one. For example, xx.xx.xx would pass this test even though it is not a valid address.
284290

285291
```Swift
@@ -304,7 +310,7 @@ api.isValid3wa(words: "filled.count.soap") { valid in
304310

305311
#### findPossible3wa(text: String) -> [String]
306312

307-
Finds any number of possible three word addresses in a block of text. The term "possible three word addresses" refers to text that matches the regex used in isPossible3wa(), that is, these are pieces of text that appear to be three word address, but have not been veified against the engine as representing an actual place on earth.
313+
Finds any number of possible three word addresses in a block of text. The term "possible three word addresses" refers to text that matches the regex used in isPossible3wa(), that is, these are pieces of text that appear to be three word addresses, but have not been verified against the engine as representing an actual place on earth.
308314

309315
```Swift
310316
let twas = api.findPossible3wa(text: "This is a filled.count.soap sentence with index.home.raft fun in it nowhere near grilled.cheese.sandwhich")
@@ -330,7 +336,7 @@ api.convertTo3wa(coordinates: CLLocationCoordinate2D(latitude: 51.4243877, longi
330336
}
331337
```
332338

333-
Api call errors are of type `W3WError` enum and the voice `autosuggest` call returns a `W3WVoiceError` enum.
339+
API call errors are of type `W3WError` enum and the voice `autosuggest` call returns a `W3WVoiceError` enum.
334340

335341
<a name="sdk"></a>
336342
## SDK Compatibility
@@ -344,4 +350,4 @@ Below is a table of which SDK version is compatible with which API wrapper versi
344350
| w3w-swift-wrapper | SDK Version |
345351
| ----------------- | ----------------- |
346352
| v3.8.2 and lower | v3.8.0 and lower |
347-
| v3.9.0 and higher | v4.0.0 and higher |
353+
| v3.9.0 and higher | v4.0.0 and higher |

0 commit comments

Comments
 (0)