Skip to content

Commit

Permalink
Initial visionOS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
b3ll committed Feb 3, 2024
1 parent c676667 commit 533e148
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ on:
jobs:
create_release:
name: Create Release
runs-on: macos-12
runs-on: macos-14
steps:
- uses: actions/checkout@v2

- name: Setup Swift 5.7
- name: Setup Swift 5.9
uses: swift-actions/setup-swift@v1
with:
swift-version: '5.7'
swift-version: '5.9'

- name: Create xcframework
uses: unsignedapps/swift-create-xcframework@v2.3.0
uses: bsneed/swift-create-xcframework@bsneed/xcode15_fix
# uses: unsignedapps/swift-create-xcframework@v2.3.0

- name: Create Release
id: create_release
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docc-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ on: [push]

jobs:
deploy_docs:
runs-on: macos-12
runs-on: macos-14
steps:
- uses: actions/checkout@v2

- name: Setup Swift 5.7
- name: Setup Swift 5.9
uses: swift-actions/setup-swift@v1
with:
swift-version: '5.7'
swift-version: '5.9'

- name: Build Docs
uses: sersoft-gmbh/swifty-docs-action@v2.0.3
uses: sersoft-gmbh/swifty-docs-action@v3.0.0
with:
output: docs
targets: Motion
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: macos-12
runs-on: macos-14

steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 10 additions & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
"revision" : "26ac5758409154cc448d7ab82389c520fa8a8247",
"version" : "1.3.0"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
},
Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -9,6 +9,7 @@ let package = Package(
.iOS(.v13),
.tvOS(.v13),
.macOS(.v10_14),
.visionOS(.v1)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand Down
13 changes: 13 additions & 0 deletions Sources/Motion/Utilities/AnimationDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ protocol AnimationDriverObserver: AnyObject {
func tick(frame: AnimationFrame)
}

#if os(visionOS)
fileprivate let MaxFPSVisionOS = 90 // TODO: Hardcoded until I find a better API to query.
#endif

#if canImport(UIKit)
import UIKit

Expand All @@ -39,7 +43,12 @@ final class CoreAnimationDriver: AnimationDriver {
// Find the first connected scene that's a UIWindowScene and is active, then find the highest supported refresh rate.
let connectedScenes = UIApplication.shared.connectedScenes
let windowScene = connectedScenes.first { ($0 as? UIWindowScene)?.activationState == .foregroundActive } as? UIWindowScene

#if os(visionOS)
let maxFPS = Float(MaxFPSVisionOS) // TODO: Hardcoded until I find a better API to query.
#else
let maxFPS = Float(windowScene?.windows.map { $0.screen.maximumFramesPerSecond }.max() ?? 60)
#endif

/**
If we've got a high refresh display, we can use 80 as a minimum.
Expand Down Expand Up @@ -80,7 +89,11 @@ final class CoreAnimationDriver: AnimationDriver {
var preferredFramesPerSecond: Int {
let fps = displayLink.preferredFramesPerSecond
if fps == 0 {
#if os(visionOS)
return MaxFPSVisionOS
#else
return UIScreen.main.maximumFramesPerSecond
#endif
} else {
return fps
}
Expand Down

0 comments on commit 533e148

Please sign in to comment.