Skip to content

fix(visionOS): make the package actually build for visionOS - #80

Open
gabhelstudios-dev wants to merge 4 commits into
colinc86:mainfrom
gabhelstudios:fix/visionos-cocoa-import
Open

fix(visionOS): make the package actually build for visionOS#80
gabhelstudios-dev wants to merge 4 commits into
colinc86:mainfrom
gabhelstudios:fix/visionos-cocoa-import

Conversation

@gabhelstudios-dev

@gabhelstudios-dev gabhelstudios-dev commented May 10, 2026

Copy link
Copy Markdown

Summary

Two small fixes that were keeping LaTeXSwiftUI from building on visionOS, even though the package declares .visionOS(.v1) in Package.swift.

1. Previews/LaTeX_Previews+Fonts.swift — missing os(visionOS) in the iOS guard

Every other #if os(...) guard in the package already includes visionOS (Aliases.swift, Renderer.swift, Font+Extensions.swift, Image+Extensions.swift, LaTeX.swift, SVGGeometry.swift). This preview file was missed, so visionOS fell through to import Cocoa and the build failed with:

Unable to resolve module dependency: 'Cocoa'

2. Package.swift — bump visionOS minimum to 2.0

EquationMarker (and its call site in Component.swift) conform to / use TextAttribute and customAttribute(_:), both of which are iOS 18 / macOS 15 / visionOS 2.0+. The existing @available(iOS 18.0, macOS 15.0, *) lets * expand to the package's visionOS deployment target, which was .v1. Result:

'EquationMarker' is only available in visionOS 2.0 or newer

visionOS 1 has been superseded by visionOS 2 for over a year, and the package already uses visionOS 2 era APIs (TextAttribute), so bumping the floor to .visionOS(.v2) matches the real API surface.

Alternative: add visionOS 2.0 explicitly to the two @available annotations and keep .visionOS(.v1) in Package.swift. Happy to switch to that form if you'd rather preserve visionOS 1 support.

Test plan

  • Built downstream visionOS app target (deployment 26.0) — both errors gone, package compiles cleanly.
  • No source changes affect iOS/macOS/etc. behavior.

The other Apple-platform guards across the package already use
`#if os(iOS) || os(visionOS)` so visionOS picks up `UIKit` instead of
falling through to `Cocoa`. This preview file was missed when
visionOS support was added, so building any visionOS target that
links LaTeXSwiftUI fails with `Unable to resolve module dependency: 'Cocoa'`.
`EquationMarker` and the `customAttribute(_:)` call site in `Component.swift`
require `TextAttribute`, which is iOS 18 / macOS 15 / visionOS 2.0+. Their
`@available(iOS 18.0, macOS 15.0, *)` annotations let `*` expand to the
package's visionOS deployment target, which was `.v1` (1.0) — so the
package fails to build for visionOS with:

  'EquationMarker' is only available in visionOS 2.0 or newer

visionOS 1 has been deprecated for over a year and the rest of the package's
visionOS guards already assume modern visionOS. Bumping the minimum to 2.0
matches the actual API surface used.
@gabhelstudios-dev gabhelstudios-dev changed the title fix(visionOS): include visionOS in iOS guard for LaTeX_Previews+Fonts fix(visionOS): make the package actually build for visionOS May 10, 2026
gabhelstudios-dev and others added 2 commits July 22, 2026 20:43
MathJaxSwift 3.5.0 define `defaultDigits` perdiendo los escapes del regex
original de MathJax (`\{,\}` → `{,}`, `\.` → `.`). El `.` sin escapar casa
cualquier carácter, así que el tokenizador TeX se come el carácter que sigue
a un número: `x^{2}` pierde la llave de cierre y MathJax devuelve "Extra open
brace or missing close brace". Con `errorMode: .rendered` eso produce el SVG
de error de MathJax (52.9ex × 2.1ex), que rasterizado sale como una caja
opaca — en Markitown, una barra negra en lugar de la fórmula.

Fijamos el regex correcto en el init de conveniencia, que es el que usan
tanto la vista `LaTeX` como `renderToImages`.

Ref: colinc86/MathJaxSwift#45

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Renderer.rasterizeSVG already returns an NSImage whose size is the
logical (point) size — NSImage(cgImage:size:) is handed the pre-scale
size while the bitmap holds size * scale pixels. Image(image:scale:)
then divided that point size by displayScale again on macOS, so every
formula laid out at half its intended size on Retina (scale 2.0)
screens. The cached path (Image(image:)) never divided, so the two
paths disagreed.

Drop the division and the now-dead scale parameter and
NSImage.resized(to:) helper. UIImage already carries its scale, so
iOS/visionOS behavior is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants