Gravity Digits is a native watchOS prototype that displays the current time as a particle-based digital clock on Apple Watch.
- Xcode 27.0 or newer with the Swift 6.4 compiler
- watchOS 26.5 or newer simulator or a paired Apple Watch
- Swift 6 language mode / SwiftUI / SpriteKit / Core Motion
No private APIs, network services, data collection, or background execution assumptions are used.
Open GravityDigits.xcodeproj in Xcode, select the GravityDigits scheme, then choose a watchOS simulator or paired Apple Watch destination.
The app and test targets use Swift 6 language mode (SWIFT_VERSION = 6.0), including complete concurrency checking. The verified toolchain is Xcode 27.0 (27A266a) with Apple Swift 6.4 and the watchOS 27.0 SDK. The minimum supported OS remains watchOS 26.5; the compiler version and language mode are separate settings.
From Terminal:
xcodebuild -project GravityDigits.xcodeproj -scheme GravityDigits -destination 'generic/platform=watchOS Simulator' -derivedDataPath /tmp/gravitydigits-dd buildThe explicit /tmp DerivedData path avoids code-signing failures caused by File Provider extended attributes when this repository lives in a synced Documents folder.
Run the unit tests on an available watchOS simulator:
xcodebuild test -project GravityDigits.xcodeproj -scheme GravityDigits \
-destination 'platform=watchOS Simulator,name=Apple Watch SE 3 (40mm)' \
-derivedDataPath /tmp/gravitydigits-tests-ddThe tests cover rounded display geometry, mask bounds and row orientation, particle speed and containment invariants, trapped-particle ejection, safe spawning, and the SpriteKit-only update loop. Concurrency regressions cover out-of-order mask completion, resize and minute-change rejection, pause/resume handoff, and a synchronous frame callback outside the main actor.
For physical-device signing, keep local signing values out of git:
cp Signing.example.xcconfig Signing.local.xcconfig
$EDITOR Signing.local.xcconfig
xcodebuild -project GravityDigits.xcodeproj -scheme GravityDigits -destination 'generic/platform=watchOS' -xcconfig Signing.local.xcconfig buildThe project and example configuration default to organization team W4KKT72RUX. Signing.local.xcconfig remains ignored for optional local overrides; credentials, certificates, and provisioning profiles must stay out of git. See Apple Developer account.
The simulator does not provide live Apple Watch accelerometer input. In simulator builds, MotionManager uses an animated fallback gravity vector so particles keep moving and settling around the digits.
- Open the project in Xcode.
- Select your own Apple Developer team in Signing & Capabilities.
- Replace the placeholder bundle identifier with an identifier registered to your Apple Developer account.
- Select a paired Apple Watch destination.
- Build and run.
On device, CMMotionManager reads accelerometer updates while the app is active. Tilting the watch changes the screen-space gravity vector. When the watch lies flat, its in-plane gravity approaches zero and particles coast to rest under damping rather than receiving an artificial downward force. The app stops accelerometer updates and pauses the simulation when inactive, then resumes when watchOS activates it again.
watchOS can dim or turn off the display after a short period of inactivity, for example when the wrist is lowered. This is system behavior for battery life and burn-in protection. Gravity Digits does not use an extended runtime session or other workaround to keep the display awake indefinitely.
- Displays the current time in 24-hour
HH:mmformat. - Exposes the same minute-updated
HH:mmvalue to VoiceOver. - Renders the time into an offscreen bitmap mask on a background queue once per minute or when layout changes.
- Uses that same rendered texture as the visible foreground time.
- Simulates particles from SpriteKit's render update using a fixed timestep.
- Caps particle speed so collision substeps cannot skip thin glyph strokes.
- Treats white mask pixels as solid glyph obstacles.
- Moves particles out of newly rendered digits and never deliberately spawns them inside a glyph.
- Treats the visible watch display as a rounded solid boundary with a small inset.
- Starts with 400 active particles, reduces the count when frame work or render cadence is too slow, and recovers in small, softly faded batches only after sustained headroom.
- Allocates only the 400-particle recovery target instead of retaining a larger hidden SpriteKit node pool.
- Limits fixed-step catch-up work to one simulation step per rendered frame so a delayed frame cannot cause a burst of physics work and a large visual jump.
- Drops simulation and rendering from 30 Hz to 2 Hz after gravity stays stable and particles settle, then restores 30 Hz when motion resumes.
- The simulator gravity source is synthetic.
- Physical accelerometer behavior has been validated on real Apple Watch hardware.
- Display sleep is controlled by watchOS.
.persistentSystemOverlays(.hidden)hides system overlays but does not prevent display sleep. - The app icon uses the approved Sumi-e source in
GravityDigits/GravityDigits.icon; Xcode generates the platform renditions. - WidgetKit complication support is intentionally not included yet; a complication could launch the app and show a static preview, but it should not run the live SpriteKit simulation.