Skip to content

Commit

Permalink
Merge branch 'main' into replace-offlineindexobserver-with-offlineeng…
Browse files Browse the repository at this point in the history
…ineready-flag
  • Loading branch information
aokj4ck authored Apr 19, 2024
2 parents 816285e + b30ea74 commit 4a3f2b6
Show file tree
Hide file tree
Showing 41 changed files with 103 additions and 56 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ Guide: https://keepachangelog.com/en/1.0.0/

- [Offline] Add `AbstractSearchEngine.offlineEngineReady` to mark when offline searches are ready.

- [SearchResult] Add support for `mapboxId` field when availalbe.
- [FavoriteRecord] Add support for `mapboxId` field when availalbe.
- [HistoryRecord] Add support for `mapboxId` field when availalbe.
- [Discover] Add more complete support for `mapboxId` field in Result subtype when availalbe.
- [Address Autofill] Add more complete support for `mapboxId` field in Result and Suggestion subtypes when availalbe.
- [Place Autocomplete] Add more complete support for `mapboxId` field in Result and Suggestion subtypes when availalbe.
- [Demo] Add `mapboxId` table view cell to PlaceAutocomplete detail view controller when available.

- [Offline] Remove `CoreOfflineIndexChangeEventType` extension previously used for development.
- [Core] Remove usages of `@_implementationOnly import` due to compilation issue.

- [Offline] Add optional `language` parameter to SearchOfflineManager.createTilesetDescriptor and SearchOfflineManager.createPlacesTilesetDescriptor functions.
- [Tests] Add Spanish language offline search test.

Expand All @@ -21,6 +32,7 @@ Guide: https://keepachangelog.com/en/1.0.0/
- [Tests] Demonstrate providing a `Geometry(point: NSValue(mkCoordinate: CLLocationCoordinate2D))` with `TileRegionLoadOptions.build` function.
- [Core] Increment minimum MapboxCommon version from 24.0.0 to 24.2.0.

**MapboxCoreSearch**: v2.0.0-alpha.16
**MapboxCommon**: v24.2.0

## 2.0.0-rc.3
Expand Down
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
binary "https://api.mapbox.com/downloads/v2/carthage/search-core-sdk/MapboxCoreSearch.xcframework.json" == 2.0.0-alpha.14
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" == 24.2.0
binary "https://api.mapbox.com/downloads/v2/carthage/search-core-sdk/MapboxCoreSearch.xcframework.json" == 2.0.0-alpha.16
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" == 24.2.0
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" "24.2.0"
binary "https://api.mapbox.com/downloads/v2/carthage/search-core-sdk/MapboxCoreSearch.xcframework.json" "2.0.0-alpha.14"
binary "https://api.mapbox.com/downloads/v2/carthage/search-core-sdk/MapboxCoreSearch.xcframework.json" "2.0.0-alpha.16"
16 changes: 2 additions & 14 deletions MapboxSearch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
0405809D2BA8E67D00A54CB9 /* OwningObjectDeallocatedErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0405809C2BA8E67D00A54CB9 /* OwningObjectDeallocatedErrorTests.swift */; };
041DAFD92BCDA45B0071F9EB /* DiscoverViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14B92D5D298BFD19006003C1 /* DiscoverViewController.swift */; };
042477C32B7290F900D870D5 /* SearchEngineGeocodingIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 042477C12B7290E700D870D5 /* SearchEngineGeocodingIntegrationTests.swift */; };
042477C52B72CCB000D870D5 /* geocoding-reverse-geocoding.json in Resources */ = {isa = PBXBuildFile; fileRef = 042477C42B72CCB000D870D5 /* geocoding-reverse-geocoding.json */; };
042477C62B72CCB000D870D5 /* geocoding-reverse-geocoding.json in Resources */ = {isa = PBXBuildFile; fileRef = 042477C42B72CCB000D870D5 /* geocoding-reverse-geocoding.json */; };
Expand All @@ -32,7 +33,6 @@
0477904E2B890F4E00A99528 /* search-box-retrieve-minsk.json in Resources */ = {isa = PBXBuildFile; fileRef = 0477904C2B890F4E00A99528 /* search-box-retrieve-minsk.json */; };
0477904F2B890F4E00A99528 /* search-box-retrieve-minsk.json in Resources */ = {isa = PBXBuildFile; fileRef = 0477904C2B890F4E00A99528 /* search-box-retrieve-minsk.json */; };
0484BCDF2BC4865C003CF408 /* OfflineIndexObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0484BCDE2BC4865C003CF408 /* OfflineIndexObserver.swift */; };
0484BCE22BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0484BCE12BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift */; };
048823482B6B0A9D00C770AA /* category-hotel-search-along-route-jp.json in Resources */ = {isa = PBXBuildFile; fileRef = 04AB0B7C2B6B043C00FDE7D5 /* category-hotel-search-along-route-jp.json */; };
048823492B6B0A9D00C770AA /* category-hotel-search-along-route-jp.json in Resources */ = {isa = PBXBuildFile; fileRef = 04AB0B7C2B6B043C00FDE7D5 /* category-hotel-search-along-route-jp.json */; };
0488234A2B6B0A9E00C770AA /* category-hotel-search-along-route-jp.json in Resources */ = {isa = PBXBuildFile; fileRef = 04AB0B7C2B6B043C00FDE7D5 /* category-hotel-search-along-route-jp.json */; };
Expand Down Expand Up @@ -104,7 +104,6 @@
149948EF290A8DD500E7E619 /* Swifter in Frameworks */ = {isa = PBXBuildFile; productRef = 149948EE290A8DD500E7E619 /* Swifter */; };
149948F1290A8DF900E7E619 /* Swifter in Frameworks */ = {isa = PBXBuildFile; productRef = 149948F0290A8DF900E7E619 /* Swifter */; settings = {ATTRIBUTES = (Required, ); }; };
14A0B83D2A5FF20B00D281F1 /* PlaceAutocomplet.Result+Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14A0B83B2A5FF1B300D281F1 /* PlaceAutocomplet.Result+Tests.swift */; };
14B92D5E298BFD19006003C1 /* DiscoverViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14B92D5D298BFD19006003C1 /* DiscoverViewController.swift */; };
14F71865299FD4BD00D5BC2E /* PlaceAutocomplete+PlaceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14F71864299FD4BD00D5BC2E /* PlaceAutocomplete+PlaceType.swift */; };
14F7186B29A1361700D5BC2E /* PlaceAutocompleteMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14F7186929A1341A00D5BC2E /* PlaceAutocompleteMainViewController.swift */; };
14F7186D29A139BF00D5BC2E /* PlaceAutocompleteDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14F7186C29A139BF00D5BC2E /* PlaceAutocompleteDetailsViewController.swift */; };
Expand Down Expand Up @@ -543,7 +542,6 @@
047790482B890A8500A99528 /* search-box-recursion.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "search-box-recursion.json"; sourceTree = "<group>"; };
0477904C2B890F4E00A99528 /* search-box-retrieve-minsk.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "search-box-retrieve-minsk.json"; sourceTree = "<group>"; };
0484BCDE2BC4865C003CF408 /* OfflineIndexObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineIndexObserver.swift; sourceTree = "<group>"; };
0484BCE12BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreOfflineIndexChangeEventType.swift; sourceTree = "<group>"; };
04970F8C2B7A97C900213763 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
04AB0B4A2B6AADB700FDE7D5 /* mapbox.places.san.francisco.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = mapbox.places.san.francisco.json; sourceTree = "<group>"; };
04AB0B792B6AF37800FDE7D5 /* DiscoverIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoverIntegrationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1056,14 +1054,6 @@
path = sbs;
sourceTree = "<group>";
};
0484BCE02BC49A18003CF408 /* Offline */ = {
isa = PBXGroup;
children = (
0484BCE12BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift */,
);
path = Offline;
sourceTree = "<group>";
};
04970F8B2B7A97C900213763 /* Resources */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1744,7 +1734,6 @@
FEEDD2C12508DFE400DC0A98 /* InternalAPI */ = {
isa = PBXGroup;
children = (
0484BCE02BC49A18003CF408 /* Offline */,
04C127562B62FFD000884325 /* Engine */,
148DE66E285777050085684D /* Common */,
F98BECBB2577B9150081D3BC /* Telemetry */,
Expand Down Expand Up @@ -2597,7 +2586,6 @@
14173C302878437D00B20E1C /* Country+ISO3166-1.swift in Sources */,
FEEDD3162508DFE400DC0A98 /* SearchCategorySuggestion.swift in Sources */,
FEEDD31D2508DFE400DC0A98 /* HighlightsCalculator.swift in Sources */,
14B92D5E298BFD19006003C1 /* DiscoverViewController.swift in Sources */,
14FA657C2953497600056E5B /* PlaceAutocomplete+Options.swift in Sources */,
F9A0B8402562B10E00CAD907 /* SearchResultMetadata.swift in Sources */,
FE097B7D264EAA1A001EAC2F /* CustomNSError.swift in Sources */,
Expand Down Expand Up @@ -2678,7 +2666,6 @@
F9E8146225418E7D00F6378E /* EventsManager.swift in Sources */,
FEEDD3002508DFE400DC0A98 /* CLLocationCoordinate2DCodable.swift in Sources */,
FEEDD3042508DFE400DC0A98 /* SearchResultType.swift in Sources */,
0484BCE22BC49A23003CF408 /* CoreOfflineIndexChangeEventType.swift in Sources */,
F91FD66C258CCB41008CB8E1 /* CoreResultType+Extensions.swift in Sources */,
FEEDD3152508DFE400DC0A98 /* ServerSearchResult.swift in Sources */,
140E47A2298BC90E00677E30 /* Discover.swift in Sources */,
Expand Down Expand Up @@ -2869,6 +2856,7 @@
files = (
1440BF4F290019AD009B3679 /* AddressAutofillResultViewController.swift in Sources */,
1440BF4D28FD75A9009B3679 /* AddressAutofillMainViewController.swift in Sources */,
041DAFD92BCDA45B0071F9EB /* DiscoverViewController.swift in Sources */,
FEEDD3C32508E3CD00DC0A98 /* AppDelegate.swift in Sources */,
14F7186D29A139BF00D5BC2E /* PlaceAutocompleteDetailsViewController.swift in Sources */,
FEEDD3BF2508E3CD00DC0A98 /* MapRootController.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription
import Foundation

let (coreSearchVersion, coreSearchVersionHash) = ("2.0.0-alpha.14", "c3e61341f2beb1b8043f3c71caccdd9bea12a23f221cb90eb452e2abe299c3e0")
let (coreSearchVersion, coreSearchVersionHash) = ("2.0.0-alpha.16", "315d5f6ed1446f5ca5d62cc6e4124ae01fa271ad9d675268e886c38149db8532")

let commonMinVersion = Version("24.2.0")
let commonMaxVersion = Version("25.0.0")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Demo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
<!--Discover-->
<scene sceneID="cow-iZ-A5n">
<objects>
<viewController title="Discover" id="ggU-4h-Z4i" customClass="DiscoverViewController" customModule="MapboxSearch" sceneMemberID="viewController">
<viewController title="Discover" id="ggU-4h-Z4i" customClass="DiscoverViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="H51-Up-D8x">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
1 change: 1 addition & 0 deletions Sources/Demo/DiscoverViewController.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import MapboxSearch
import MapKit
import UIKit

Expand Down
6 changes: 6 additions & 0 deletions Sources/Demo/PlaceAutocompleteDetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ extension PlaceAutocomplete.Result {
)
}

if let mapboxId {
components.append(
(name: "Mapbox ID", value: mapboxId)
)
}

return components
}
}
10 changes: 4 additions & 6 deletions Sources/MapboxSearch/InternalAPI/CoreAliases.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
@_implementationOnly import MapboxCommon_Private
import MapboxCommon_Private
import MapboxCoreSearch
import MapboxCoreSearch_Private

/// https://forums.swift.org/t/update-on-implementation-only-imports/26996
@_implementationOnly import MapboxCoreSearch
@_implementationOnly import MapboxCoreSearch_Private

// Note: This file included in MapboxSearch and MapboxSearchTests targets
// Note: This file is included in MapboxSearch and MapboxSearchTests targets

typealias CoreSearchEngine = MapboxCoreSearch.SearchEngine
typealias CoreSearchResponse = MapboxCoreSearch_Private.SearchResponse
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions Sources/MapboxSearch/PublicAPI/FavoriteRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable
/// Displayable name of the record.
public var name: String

/// A unique identifier for the geographic feature
public var mapboxId: String?

/**
The feature name, as matched by the search algorithm.

Expand Down Expand Up @@ -79,6 +82,7 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable
/// - resultType: Favorite result type
public init(
id: String? = nil,
mapboxId: String? = nil,
name: String,
matchingName: String?,
coordinate: CLLocationCoordinate2D,
Expand All @@ -93,6 +97,7 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable
metadata: SearchResultMetadata? = nil
) {
self.id = id ?? UUID().uuidString
self.mapboxId = mapboxId
self.name = name
self.matchingName = matchingName
self.coordinateCodable = .init(coordinate)
Expand All @@ -118,6 +123,7 @@ public struct FavoriteRecord: IndexableRecord, SearchResult, Codable, Equatable
) {
self.init(
id: id,
mapboxId: searchResult.mapboxId,
name: name,
matchingName: searchResult.matchingName,
coordinate: searchResult.coordinate,
Expand Down
5 changes: 5 additions & 0 deletions Sources/MapboxSearch/PublicAPI/HistoryRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable {
/// Unique identifier
public private(set) var id: String

public private(set) var mapboxId: String?

/// Record's name
public private(set) var name: String

Expand Down Expand Up @@ -97,6 +99,7 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable {
/// - routablePoints: Coordinates of building entries
public init(
id: String = UUID().uuidString,
mapboxId: String?,
name: String,
matchingName: String?,
serverIndex: Int?,
Expand All @@ -112,6 +115,7 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable {
routablePoints: [RoutablePoint]? = nil
) {
self.id = id
self.mapboxId = mapboxId
self.name = name
self.matchingName = matchingName
self.serverIndex = serverIndex
Expand All @@ -138,6 +142,7 @@ public struct HistoryRecord: IndexableRecord, SearchResult, Codable, Hashable {
timestamp: Date = Date()
) {
self.id = searchResult.id
self.mapboxId = searchResult.mapboxId
self.name = searchResult.name
self.matchingName = searchResult.matchingName
self.serverIndex = searchResult.serverIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import CoreLocation
import Foundation

class ExternalRecordPlaceholder: SearchResultSuggestion, CoreResponseProvider {
var mapboxId: String?

var originalResponse: CoreSearchResultResponse

var dataLayerIdentifier: String

var id: String

var mapboxId: String?

var name: String

var address: Address?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import CoreLocation
import Foundation

class SearchCategorySuggestionImpl: SearchCategorySuggestion, CoreResponseProvider {
var mapboxId: String?

var originalResponse: CoreSearchResultResponse

var id: String

var mapboxId: String?

var name: String

var address: Address?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public protocol SearchResult {
/// Result name.
var name: String { get }

/// A unique identifier for the geographic feature
var mapboxId: String? { get }

/// Icon name according to [Mapbox Maki icon set](https://github.com/mapbox/maki/)
var iconName: String? { get }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import CoreLocation
import Foundation

class SearchResultSuggestionImpl: SearchResultSuggestion, CoreResponseProvider {
var mapboxId: String?

var originalResponse: CoreSearchResultResponse

let dataLayerIdentifier = SearchEngine.providerIdentifier

var id: String

var mapboxId: String?

var name: String

var address: Address?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public protocol SearchSuggestion {
/// - Attention: Mapbox backend may change the identifier of the object in the future.
var id: String { get }

/// A unique identifier for the geographic feature
var mapboxId: String? { get }

/// Suggestion name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import CoreLocation
import Foundation

class ServerSearchResult: SearchResult, SearchResultSuggestion, CoreResponseProvider {
var mapboxId: String?

var distance: CLLocationDistance?

var originalResponse: CoreSearchResultResponse
Expand Down Expand Up @@ -37,6 +35,8 @@ class ServerSearchResult: SearchResult, SearchResultSuggestion, CoreResponseProv

var id: String

var mapboxId: String?

var name: String

var matchingName: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ extension AddressAutofill {
}
let result = AddressAutofill.Result(
name: suggestion.name,
mapboxId: suggestion.mapboxId,
formattedAddress: suggestion.formattedAddress,
coordinate: coordinate,
addressComponents: suggestion.addressComponents
Expand Down Expand Up @@ -248,6 +249,7 @@ extension AddressAutofill {

return Suggestion(
name: name,
mapboxId: result.mapboxId,
formattedAddress: fullAddress,
coordinate: result.center?.value,
addressComponents: resultAddress,
Expand Down Expand Up @@ -287,6 +289,7 @@ extension AddressAutofill {

let autofillResult = AddressAutofill.Result(
name: result.name,
mapboxId: result.mapboxId,
formattedAddress: formattedAddress,
coordinate: result.coordinate,
addressComponents: addressComponents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ extension AddressAutofill {
/// Result name.
public let name: String

/// A unique identifier for the geographic feature
public let mapboxId: String?

/// Textual representation of the address.
public let formattedAddress: String

Expand All @@ -16,11 +19,13 @@ extension AddressAutofill {

init(
name: String,
mapboxId: String?,
formattedAddress: String,
coordinate: CLLocationCoordinate2D,
addressComponents: NonEmptyArray<AddressComponent>
) {
self.name = name
self.mapboxId = mapboxId
self.formattedAddress = formattedAddress
self.coordinate = coordinate
self.addressComponents = addressComponents
Expand Down
Loading

0 comments on commit 4a3f2b6

Please sign in to comment.