Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into remov…
Browse files Browse the repository at this point in the history
…e-swifter-from-mapbox-search-target

Conflicts:
	CHANGELOG.md
  • Loading branch information
aokj4ck committed Feb 7, 2024
2 parents 251bdcb + 742cf38 commit a70d443
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ jobs:
- parse-release-version
- run:
name: Check existing public release
command: curl -L https://api.mapbox.com/downloads/v2/carthage/search-sdk/MapboxSearch.json | grep -v "$VERSION"
# Escape the quotes to check for exact versions
command: curl -L https://api.mapbox.com/downloads/v2/carthage/search-sdk/MapboxSearch.json | grep -v \"$VERSION\"

build:
macos:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Guide: https://keepachangelog.com/en/1.0.0/
<!-- Add changes for active work here -->

- [Core] Remove Swifter library dependency from MapboxSearch target (only used in Test targets)
- [Core] Change AbstractSearchEngine.init `supportSBS: Bool = false` parameter to `apiType: ApiType = .SBS`. This changes the default API engine for discover/category and other API requests to SBS. Add ApiType enum to represent non-Autofill and non-PlaceAutocomplete SearchEngine API types.

## 2.0.0-rc.1

- [Discover] Fix charging station category canonical ID
- [SearchUI] Rename MapboxPanelController.Configuration to .PanelConfiguration. This disambiguates PanelConfiguration from the broader Configuration struct.
- [Core] Update SwiftLint to 0.54.0 and SwiftFormat to 0.52.11
Expand Down
4 changes: 2 additions & 2 deletions Examples/SearchExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.SearchExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -408,7 +408,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.SearchExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion MapboxSearch.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MapboxSearch'
s.version = '2.0.0-alpha.1'
s.version = '2.0.0'
s.summary = 'Search SDK for Mapbox Search API '

# This description is used to generate tags and improve search results.
Expand Down
20 changes: 18 additions & 2 deletions MapboxSearch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
043A3D4D2B30F38300DB681B /* CoreAddress+AddressComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043A3D4C2B30F38300DB681B /* CoreAddress+AddressComponents.swift */; };
04C0848D2B4C82F3002F9C69 /* SdkInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C0848C2B4C82F3002F9C69 /* SdkInformation.swift */; };
04C127552B62F6BC00884325 /* ApiType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C127542B62F6BC00884325 /* ApiType.swift */; };
04C127582B62FFDB00884325 /* ApiType+Core.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C127572B62FFDB00884325 /* ApiType+Core.swift */; };
04E5FF962B48828500DADC18 /* SearchAddressCountry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E5FF952B48828500DADC18 /* SearchAddressCountry.swift */; };
04E5FF992B48829200DADC18 /* SearchAddressRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E5FF982B48829200DADC18 /* SearchAddressRegion.swift */; };
140D1BDC286DB479001A51C2 /* SearchResultAccuracy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 140D1BDB286DB479001A51C2 /* SearchResultAccuracy.swift */; };
Expand Down Expand Up @@ -480,6 +482,8 @@
/* Begin PBXFileReference section */
043A3D4C2B30F38300DB681B /* CoreAddress+AddressComponents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CoreAddress+AddressComponents.swift"; sourceTree = "<group>"; };
04C0848C2B4C82F3002F9C69 /* SdkInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SdkInformation.swift; sourceTree = "<group>"; };
04C127542B62F6BC00884325 /* ApiType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiType.swift; sourceTree = "<group>"; };
04C127572B62FFDB00884325 /* ApiType+Core.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ApiType+Core.swift"; sourceTree = "<group>"; };
04E5FF952B48828500DADC18 /* SearchAddressCountry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchAddressCountry.swift; sourceTree = "<group>"; };
04E5FF982B48829200DADC18 /* SearchAddressRegion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchAddressRegion.swift; sourceTree = "<group>"; };
140D1BDB286DB479001A51C2 /* SearchResultAccuracy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultAccuracy.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -895,6 +899,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
04C127562B62FFD000884325 /* Engine */ = {
isa = PBXGroup;
children = (
04C127572B62FFDB00884325 /* ApiType+Core.swift */,
);
path = Engine;
sourceTree = "<group>";
};
04E5FF972B48829200DADC18 /* Region */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1362,6 +1374,7 @@
isa = PBXGroup;
children = (
FEEDD2E32508DFE400DC0A98 /* AbstractSearchEngine.swift */,
04C127542B62F6BC00884325 /* ApiType.swift */,
FEEDD2D82508DFE400DC0A98 /* SearchEngine.swift */,
FEEDD2EB2508DFE400DC0A98 /* CategorySearchEngine.swift */,
04C0848C2B4C82F3002F9C69 /* SdkInformation.swift */,
Expand Down Expand Up @@ -1544,6 +1557,7 @@
FEEDD2C12508DFE400DC0A98 /* InternalAPI */ = {
isa = PBXGroup;
children = (
04C127562B62FFD000884325 /* Engine */,
148DE66E285777050085684D /* Common */,
F98BECBB2577B9150081D3BC /* Telemetry */,
FEEDD2C32508DFE400DC0A98 /* Array+Extensions.swift */,
Expand Down Expand Up @@ -2347,6 +2361,7 @@
F93DA6FF274E4B86005595B5 /* CoreSearchEngineStatics.swift in Sources */,
14F71865299FD4BD00D5BC2E /* PlaceAutocomplete+PlaceType.swift in Sources */,
F9F6378A25DD6A4E00C99904 /* FeedbackManager.swift in Sources */,
04C127582B62FFDB00884325 /* ApiType+Core.swift in Sources */,
148DE65D28574E6E0085684D /* AddressAutofill.swift in Sources */,
140E47A7298BCBDF00677E30 /* Discover+Query.swift in Sources */,
FEEDD3092508DFE400DC0A98 /* CodablePersistentService.swift in Sources */,
Expand Down Expand Up @@ -2440,6 +2455,7 @@
FEEDD3152508DFE400DC0A98 /* ServerSearchResult.swift in Sources */,
140E47A2298BC90E00677E30 /* Discover.swift in Sources */,
14FA65872953644400056E5B /* PlaceAutocomplete+Suggestion.swift in Sources */,
04C127552B62F6BC00884325 /* ApiType.swift in Sources */,
FE059C5A251A0AE6001F7701 /* SearchCategorySuggestionImpl.swift in Sources */,
FEEDD2F62508DFE400DC0A98 /* CoreSearchResultResponse.swift in Sources */,
FE260A6725C063880037B725 /* ReverseGeocodingOptions.swift in Sources */,
Expand Down Expand Up @@ -3103,7 +3119,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 2.0.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSearchDemoApplication;
Expand All @@ -3128,7 +3144,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 2.0.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSearchDemoApplication;
Expand Down
4 changes: 2 additions & 2 deletions MapboxSearchUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MapboxSearchUI'
s.version = '2.0.0-alpha.1'
s.version = '2.0.0'
s.summary = 'Search UI for Mapbox Search API'

# This description is used to generate tags and improve search results.
Expand All @@ -23,5 +23,5 @@ Card style custom UI with full search functionality powered by Mapbox Search API

s.vendored_frameworks = "**/#{s.name}.xcframework"

s.dependency 'MapboxSearch', "2.0.0-alpha.1"
s.dependency 'MapboxSearch', "2.0.0"
end
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ Once you've installed the prerequisites, no additional steps are needed: Open th
You can find the following documentation pages helpful:
- [Search SDK for iOS guide](https://docs.mapbox.com/ios/search/guides/)
- [MapboxSearch reference](https://docs.mapbox.com/ios/search/api/core/2.0.0-alpha.1/)
- [MapboxSearchUI reference](https://docs.mapbox.com/ios/search/api/ui/2.0.0-alpha.1/)
- [MapboxSearch reference](https://docs.mapbox.com/ios/search/api/core/2.0.0/)
- [MapboxSearchUI reference](https://docs.mapbox.com/ios/search/api/ui/2.0.0/)
## Project structure overview
Expand All @@ -108,13 +108,13 @@ MapboxSearchDemoApplication provides a Demo app wih MapboxSearchUI.framework pre
##### MapboxSearch
To integrate latest preview version of `MapboxSearch` into your Xcode project using CocoaPods, specify it in your `Podfile`:
```
pod 'MapboxSearch', ">= 2.0.0-alpha.1", "< 3.0"
pod 'MapboxSearch', ">= 2.0.0", "< 3.0"
```
##### MapboxSearchUI
To integrate latest preview version of `MapboxSearchUI` into your Xcode project using CocoaPods, specify it in your `Podfile`:
```
pod 'MapboxSearchUI', ">= 2.0.0-alpha.1", "< 3.0"
pod 'MapboxSearchUI', ">= 2.0.0", "< 3.0"
```
### Swift Package Manager
Expand Down
4 changes: 2 additions & 2 deletions Search Documentation.docc/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ To add the Mapbox Search SDK dependency with CocoaPods, you will need to configu
```ruby
use_frameworks!
target "TargetNameForYourApp" do
pod 'MapboxSearchUI', ">= 2.0.0-alpha.1", "< 3.0"
pod 'MapboxSearchUI', ">= 2.0.0", "< 3.0"
end
```

Expand All @@ -68,7 +68,7 @@ To add the Mapbox Search SDK dependency with CocoaPods, you will need to configu
```ruby
use_frameworks!
target "TargetNameForYourApp" do
pod 'MapboxSearch', ">= 2.0.0-alpha.1", "< 3.0"
pod 'MapboxSearch', ">= 2.0.0", "< 3.0"
end
```

Expand Down
14 changes: 14 additions & 0 deletions Sources/MapboxSearch/InternalAPI/Engine/ApiType+Core.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright © 2024 Mapbox. All rights reserved.

import Foundation

extension ApiType {
func toCore() -> CoreSearchEngine.ApiType {
switch self {
case .geocoding:
return .geocoding
case .SBS:
return .SBS
}
}
}
18 changes: 9 additions & 9 deletions Sources/MapboxSearch/PublicAPI/Engine/AbstractSearchEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class AbstractSearchEngine: FeedbackManagerDelegate {

var locationProviderWrapper: WrapperLocationProvider?

/// SearchEngine supports the latest Single-Box Search APIs
public let supportSBS: Bool
/// Provide a specific API type
public let apiType: ApiType

/// Location provider for search results `proximity` argument
public let locationProvider: LocationProvider?
Expand Down Expand Up @@ -54,27 +54,27 @@ public class AbstractSearchEngine: FeedbackManagerDelegate {
/// - locationProvider: Provider configuration of LocationProvider that would grant location data by default
/// - serviceProvider: Internal `ServiceProvider` for sharing common dependencies like favoritesService or
/// eventsManager
/// - supportSBS: enable support the latest Single-Box Search APIs
/// - apiType: choose which API provider to use through this search engine
init(
accessToken: String? = nil,
serviceProvider: ServiceProviderProtocol & EngineProviderProtocol,
locationProvider: LocationProvider? = DefaultLocationProvider(),
defaultSearchOptions: SearchOptions = SearchOptions(),
supportSBS: Bool = false
apiType: ApiType = .SBS
) {
guard let accessToken = accessToken ?? serviceProvider.getStoredAccessToken() else {
fatalError(
"No access token was found. Please, provide it in init(accessToken:) or in Info.plist at '\(accessTokenPlistKey)' key"
)
}

self.supportSBS = supportSBS
self.locationProvider = locationProvider
self.locationProviderWrapper = WrapperLocationProvider(wrapping: locationProvider)
self.eventsManager = serviceProvider.eventsManager
self.feedbackManager = serviceProvider.feedbackManager
self.defaultSearchOptions = defaultSearchOptions
self.engineApi = supportSBS ? .SBS : .geocoding
self.apiType = apiType
self.engineApi = apiType.toCore()

self.userActivityReporter = .getOrCreate(
for: .init(
Expand Down Expand Up @@ -110,19 +110,19 @@ public class AbstractSearchEngine: FeedbackManagerDelegate {
/// for `nil` argument
/// - locationProvider: Provider configuration of LocationProvider that would grant location data by default
/// - defaultSearchOptions: Default options to use when `nil` was passed to the `search(…: options:)` call
/// - supportSBS: enable support the latest Single-Box Search APIs
/// - apiType: choose which API provider to use through this search engine
public convenience init(
accessToken: String? = nil,
locationProvider: LocationProvider? = DefaultLocationProvider(),
defaultSearchOptions: SearchOptions = SearchOptions(),
supportSBS: Bool = false
apiType: ApiType = .SBS
) {
self.init(
accessToken: accessToken,
serviceProvider: ServiceProvider.shared,
locationProvider: locationProvider,
defaultSearchOptions: defaultSearchOptions,
supportSBS: supportSBS
apiType: apiType
)
}

Expand Down
12 changes: 12 additions & 0 deletions Sources/MapboxSearch/PublicAPI/Engine/ApiType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright © 2024 Mapbox. All rights reserved.

import Foundation

/// Determine which Mapbox API to use for a SearchEngine instance
public enum ApiType {
/// The Mapbox Geocoding (a.k.a V5) API - https://docs.mapbox.com/api/search/geocoding/
case geocoding

/// The Mapbox Single Box Search (a.k.a Federation API) - https://docs.mapbox.com/api/search/search/
case SBS
}
2 changes: 1 addition & 1 deletion Sources/MapboxSearch/PublicAPI/MapboxSearchVersion.swift
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/// Mapbox Search SDK version variable
public let mapboxSearchSDKVersion = "1.0.0-rc.8"
public let mapboxSearchSDKVersion = "2.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class Discover {
let searchEngine = CategorySearchEngine(
accessToken: accessToken,
locationProvider: locationProvider,
supportSBS: true
apiType: .SBS
)

let userActivityReporter = CoreUserActivityReporter.getOrCreate(
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxSearchUI/MapboxSearchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ extension MapboxSearchController: SearchCategoriesRootViewDelegate {
}

func userSelectedCategory(_ category: SearchCategory) {
let categoryName = categorySearchEngine.supportSBS ? category.canonicalId : category.legacyName
let categoryName = categorySearchEngine.apiType == .geocoding ? category.legacyName : category.canonicalId

categorySearchEngine.search(categoryName: categoryName, options: categorySearchOptions) { results in
switch results {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CategorySearchEngineIntegrationTests: MockServerTestCase {
lazy var searchEngine = CategorySearchEngine(
accessToken: "access-token",
locationProvider: DefaultLocationProvider(),
supportSBS: true
apiType: .SBS
)

func testCategorySearch() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ final class PlaceAutocompleteIntegrationTests: MockServerTestCase {
wait(for: [expectation], timeout: 5)

let selectionExpectation = XCTestExpectation(description: "Expecting selection result")
placeAutocomplete.select(suggestion: suggestion!) { result in
let unwrappedSuggestion = try XCTUnwrap(suggestion)
placeAutocomplete.select(suggestion: unwrappedSuggestion) { result in
switch result {
case .success(let resolvedSuggestion):
XCTAssertEqual(resolvedSuggestion.name, "San Francisco")
Expand Down Expand Up @@ -92,7 +93,8 @@ final class PlaceAutocompleteIntegrationTests: MockServerTestCase {

try server.setResponse(.retrieveMinsk)
let selectionExpectation = XCTestExpectation(description: "Expecting selection result")
placeAutocomplete.select(suggestion: suggestion!) { result in
let unwrappedSuggestion = try XCTUnwrap(suggestion)
placeAutocomplete.select(suggestion: unwrappedSuggestion) { result in
switch result {
case .success(let resolvedSuggestion):
XCTAssertEqual(resolvedSuggestion.name, "Minsk")
Expand Down Expand Up @@ -225,7 +227,8 @@ final class PlaceAutocompleteIntegrationTests: MockServerTestCase {

try server.setResponse(.retrievePoi)
let selectionExpectation = XCTestExpectation(description: "Expecting selection result")
placeAutocomplete.select(suggestion: suggestion!) { result in
let unwrappedSuggestion = try XCTUnwrap(suggestion)
placeAutocomplete.select(suggestion: unwrappedSuggestion) { result in
switch result {
case .success(let resolvedSuggestion):
XCTAssertEqual(resolvedSuggestion.name, "Starbucks")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SearchEngineIntegrationTests: MockServerTestCase {
lazy var searchEngine = SearchEngine(
accessToken: "access-token",
locationProvider: DefaultLocationProvider(),
supportSBS: true
apiType: .SBS
)

override func setUpWithError() throws {
Expand Down

0 comments on commit a70d443

Please sign in to comment.