Skip to content

Commit

Permalink
Vision OS support (#1988)
Browse files Browse the repository at this point in the history
  • Loading branch information
persidskiy committed Jan 30, 2024
1 parent 1a5fd6f commit 35a3bea
Show file tree
Hide file tree
Showing 67 changed files with 746 additions and 349 deletions.
1 change: 1 addition & 0 deletions .fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ platform :ios do
skip_detect_devices: true, # Required
build_for_testing: true, # Required
sdk: 'iphoneos', # Required
destination: "generic/platform=iOS", # Required
should_zip_build_products: true, # Must be true to set the correct format for Firebase Test Lab,
result_bundle: true,
output_directory: "output/",
Expand Down
8 changes: 4 additions & 4 deletions Apps/Apps.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-common-ios.git",
"state" : {
"revision" : "6ed3e33b51d3e3162843885f6914d7fb175609c6",
"version" : "24.1.0"
"revision" : "f7804e860a7d99fac4aafda0bd790eee76150e6c",
"version" : "24.2.0-beta.1"
}
},
{
"identity" : "turf-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/turf-swift.git",
"state" : {
"revision" : "f0afe204b4266337066a436becab62fdd2b32378",
"version" : "2.7.0"
"revision" : "213050191cfcb3d5aa76e1fa90c6ff1e182a42ca",
"version" : "2.8.0"
}
}
],
Expand Down
278 changes: 168 additions & 110 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
runPostActionsOnFailure = "NO">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -26,7 +27,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "NO">
shouldUseLaunchSchemeArgsEnv = "NO"
onlyGenerateCoverageForSpecifiedTargets = "NO">
<TestPlans>
<TestPlanReference
default = "YES"
reference = "container:../../Tests/TestPlans/Examples.xctestplan">
</TestPlanReference>
<TestPlanReference
reference = "container:../../Tests/TestPlans/Examples no unit tests.xctestplan">
</TestPlanReference>
</TestPlans>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -36,37 +47,6 @@
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "MTL_HUD_ENABLED"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "MTL_HUD_ALIGNMENT"
value = "20"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "MAPBOX_MAPS_SIGNPOSTS_ENABLED"
value = "1"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "MAPBOX_REOPEN_EXAMPLE"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<TestPlans>
<TestPlanReference
reference = "container:../../Tests/TestPlans/Examples.xctestplan"
default = "YES">
</TestPlanReference>
<TestPlanReference
reference = "container:../../Tests/TestPlans/Examples no unit tests.xctestplan">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -89,6 +69,30 @@
</BuildableReference>
</TestableReference>
</Testables>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MTL_HUD_ENABLED"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "MTL_HUD_ALIGNMENT"
value = "20"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "MAPBOX_MAPS_SIGNPOSTS_ENABLED"
value = "1"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "MAPBOX_REOPEN_EXAMPLE"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -110,6 +114,8 @@
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MTL_HUD_ENABLED"
Expand Down Expand Up @@ -149,6 +155,8 @@
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MTL_HUD_ENABLED"
Expand Down
24 changes: 19 additions & 5 deletions Apps/Examples/Examples/SwiftUI Examples/SwiftUIRoot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import UIKit

@available(iOS 14.0, *)
struct SwiftUIRoot: View {
@Environment(\.presentationMode) var presentationMode

var body: some View {
NavigationView {
List {
Expand Down Expand Up @@ -46,13 +44,13 @@ struct SwiftUIRoot: View {
.listStyle(.plain)
.navigationTitle(title)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
.modifier(ToolbarContentWhenPresented { dismiss in
ToolbarItem(placement: .navigationBarLeading) {
Button("Close") {
presentationMode.wrappedValue.dismiss()
dismiss()
}
}
}
})
}
}
}
Expand Down Expand Up @@ -81,6 +79,22 @@ struct ExampleLink<S, Destination>: View where S : StringProtocol, Destination:
}
}

@available(iOS 14.0, *)
private struct ToolbarContentWhenPresented<T: ToolbarContent>: ViewModifier {
@Environment(\.presentationMode) var presentationMode
var toolbarContent: (@escaping () -> Void) -> T
func body(content: Content) -> some View {
if presentationMode.wrappedValue.isPresented {
content.toolbar {
toolbarContent({ presentationMode.wrappedValue.dismiss() })
}
} else {
content
}
}
}



@available(iOS 14.0, *)
func createSwiftUIExamplesController() -> UIViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ struct MapStyleSelectorButton: View {
.frame(width: 40, height: 40)
.floating(Circle())
}
#if !swift(>=5.9) || !os(visionOS)
.fixedMenuOrder()
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extension View {
if #available(iOS 16.0, *) {
return self.menuOrder(.fixed)
} else {
return self
return AnyView(self)
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions Apps/Examples/Examples/VisionOSMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SwiftUI

@main
struct VisionOSMain: App {
var body: some Scene {
WindowGroup {
SwiftUIRoot()
}
}
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Mapbox welcomes participation and contributions from everyone.

## main

* Vision OS support.
* Add easing curve parameter to `CameraAnimationsManager.fly(to:duration:curve:completion)`, make `TimingCurve` public with few more options.
* Fix MapView flickering during resizing.
* Fix glitch in chained camera animations.
Expand All @@ -18,6 +19,8 @@ Use them to configure respective map options after creating a map view.
* Introduce `SymbolLayer.iconColorSaturation` API.
* Introduce experimental `RasterLayer.rasterElevation` API.
* Introduce experimental `MapboxMap.collectPerformanceStatistics` allowing to collect map rendering performance statistics, both for UIKit and SwiftUI.
* Bump Turf version to `2.8.0`.
* Bump minimum Xcode version to `14.3.1`.

## 11.1.0 - 17 January, 2024

Expand Down
6 changes: 3 additions & 3 deletions MapboxMaps.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Pod::Spec.new do |m|
m.source_files = 'Sources/MapboxMaps/**/*.{swift,h}'
m.resource_bundles = { 'MapboxMapsResources' => ['Sources/**/*.{xcassets,strings}', 'Sources/MapboxMaps/MapboxMaps.json', 'Sources/MapboxMaps/PrivacyInfo.xcprivacy'] }

m.dependency 'MapboxCoreMaps', '11.2.0-SNAPSHOT.0126T1736Z.c82057a'
m.dependency 'MapboxCommon', '24.1.0'
m.dependency 'Turf', '2.7.0'
m.dependency 'MapboxCoreMaps', '11.2.0-SNAPSHOT.0129T1135Z.89fb196'
m.dependency 'MapboxCommon', '24.2.0-beta.1'
m.dependency 'Turf', '2.8.0'

end
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-common-ios.git",
"state" : {
"revision" : "6ed3e33b51d3e3162843885f6914d7fb175609c6",
"version" : "24.1.0"
"revision" : "f7804e860a7d99fac4aafda0bd790eee76150e6c",
"version" : "24.2.0-beta.1"
}
},
{
"identity" : "turf-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/turf-swift.git",
"state" : {
"revision" : "f0afe204b4266337066a436becab62fdd2b32378",
"version" : "2.7.0"
"revision" : "213050191cfcb3d5aa76e1fa90c6ff1e182a42ca",
"version" : "2.8.0"
}
}
],
Expand Down
14 changes: 8 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@

import PackageDescription

let coreMaps = MapsDependency.coreMaps(version: "11.2.0-SNAPSHOT.0126T1736Z.c82057a", checksum: "d87bd0627f7364da0f5d746a912934b835c66ef21a444df77ef2c1730ff86b31")

let common = MapsDependency.common(version: "24.1.0")
let coreMaps = MapsDependency.coreMaps(
version: "11.2.0-SNAPSHOT.0129T1135Z.89fb196",
checksum: "79f384025c8593498b32a0f3ad72a80420758d651ecf0e1e1d151513a53896d1"
)
let common = MapsDependency.common(version: "24.2.0-beta.1")

let mapboxMapsPath: String? = nil

let package = Package(
name: "MapboxMaps",
defaultLocalization: "en",
// Maps SDK doesn't support macOS but declared the minimum macOS requirement with downstrem deps to enable `swift run` cli tools
platforms: [.iOS(.v12), .macOS(.v10_15)],
// Maps SDK doesn't support macOS but declared the minimum macOS requirement with downstream deps to enable `swift run` cli tools
platforms: [.iOS(.v12), .macOS(.v10_15), .custom("visionOS", versionString: "1.0")],
products: [
.library(
name: "MapboxMaps",
targets: ["MapboxMaps"]),
],
dependencies: [
.package(url: "https://github.com/mapbox/turf-swift.git", exact: "2.7.0"),
.package(url: "https://github.com/mapbox/turf-swift.git", exact: "2.8.0"),
] + coreMaps.packageDependencies + common.packageDependencies,
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CoreMaps - Internal

Maps rendering SDK also known as GL-Native. These are for internal use only.
Maps rendering SDK also known as GL-Native. These are for internal use only.

## Topics

Expand Down
6 changes: 5 additions & 1 deletion Sources/MapboxMaps/Foundation/Events/EventsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ internal final class EventsManager: EventsManagerProtocol {
}

private func getOrientation() -> String {
#if swift(>=5.9) && os(visionOS)
let orientation = UIDeviceOrientation.unknown
#else
let orientation = UIDevice.current.orientation
#endif

let defaultOrientation = "Default - Unknown"
let orientationToString: [UIDeviceOrientation: String] = [
Expand Down Expand Up @@ -108,7 +112,7 @@ internal final class EventsManager: EventsManagerProtocol {
let userId = UIDevice.current.identifierForVendor?.uuidString ?? ""
let model = lookupDeviceModel()
let operatingSystem = String(format: "%@ %@", UIDevice.current.systemName, UIDevice.current.systemVersion)
let resolution = UIScreen.main.nativeScale
let resolution = ScreenShim.nativeScale
let accessibilityFontScale = self.getContentScale(for: traits.preferredContentSizeCategory)
let orientation = self.getOrientation()
let wifi = ReachabilityFactory.reachability(forHostname: nil).currentNetworkStatus() == .reachableViaWiFi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension MapOptions {
crossSourceCollisions: Bool = true,
optimizeForTerrain: Bool = true,
size: CGSize? = nil,
pixelRatio: CGFloat = UIScreen.main.nativeScale,
pixelRatio: CGFloat? = nil,
glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions(fontFamilies: [])) {
fatalError()
}
Expand All @@ -46,7 +46,7 @@ extension MapOptions {
orientation: NorthOrientation = .upwards,
crossSourceCollisions: Bool = true,
size: CGSize? = nil,
pixelRatio: CGFloat = UIScreen.main.nativeScale,
pixelRatio: CGFloat? = nil,
glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions(fontFamilies: [])) {

let mbmSize: Size?
Expand All @@ -63,7 +63,7 @@ extension MapOptions {
orientation: orientation.NSNumber,
crossSourceCollisions: crossSourceCollisions.NSNumber,
size: mbmSize,
pixelRatio: Float(pixelRatio),
pixelRatio: Float(pixelRatio ?? ScreenShim.nativeScale),
glyphsRasterizationOptions: glyphsRasterizationOptions)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxMaps/Foundation/Extensions/UIImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension UIImage {
/// - Parameters:
/// - mbmImage: The internal `Image` type to use for the `UIImage`.
/// - scale: The scale of the new `UIImage`.
internal convenience init?(mbmImage: CoreMapsImage, scale: CGFloat = UIScreen.main.scale) {
internal convenience init?(mbmImage: CoreMapsImage, scale: CGFloat = ScreenShim.scale) {
guard let dataProvider = CGDataProvider(data: mbmImage.data.data as CFData) else {
return nil
}
Expand Down
Loading

0 comments on commit 35a3bea

Please sign in to comment.