Fix visionOS build (Cocoa import + visionOS 2.0 availability) - #81
Open
LasCondes wants to merge 2 commits into
Open
Fix visionOS build (Cocoa import + visionOS 2.0 availability)#81LasCondes wants to merge 2 commits into
LasCondes wants to merge 2 commits into
Conversation
The platform import in Previews/LaTeX_Previews+Fonts.swift used `#if os(iOS)`
with a `#else import Cocoa` fallback. On visionOS `os(iOS)` is false, so the
file falls into the `#else` branch and tries to `import Cocoa`, which does not
exist on visionOS:
error: Unable to resolve module dependency: 'Cocoa'
This breaks any visionOS build that depends on LaTeXSwiftUI. Every other
UIKit/Cocoa guard in the package already uses `#if os(iOS) || os(visionOS)`
(e.g. Font+Extensions.swift, Models/Renderer.swift, Models/Aliases.swift,
Extensions/Image+Extensions.swift); this previews file was the lone exception.
Align it with the rest of the codebase so visionOS picks the UIKit branch
(UIFont is available on visionOS).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…OS 2.0
EquationMarker conforms to the SwiftUI TextAttribute protocol, which (together
with Text.customAttribute) is available on iOS 18 / macOS 15 / visionOS 2.0.
Five availability clauses spelled this generation as `(iOS 18.0, macOS 15.0, *)`,
omitting visionOS. Because the package's deployment floor is visionOS 1.0, the
`*` resolves to visionOS 1.0, so the compiler rejects EquationMarker on visionOS:
error: 'EquationMarker' is only available in visionOS 2.0 or newer
Add `visionOS 2.0` to all five clauses (the EquationMarker and LineSpacingNormalizer
@available attributes, and the three #available runtime checks). The existing
`else` branches still provide the fallback for visionOS 1.x, so the package keeps
its visionOS 1.0 floor.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LaTeXSwiftUI does not build for visionOS, which breaks any visionOS target that depends on it. There are two independent causes; this PR fixes both.
1. Unguarded
import Cocoain a previews fileSources/LaTeXSwiftUI/Previews/LaTeX_Previews+Fonts.swiftselected its font type with:On visionOS
os(iOS)is false, so it falls into#elseand triesimport Cocoa:Fix:
#if os(iOS) || os(visionOS). This was the only UIKit/Cocoa guard in the package missing|| os(visionOS)— every other site (Font+Extensions.swift,Models/Renderer.swift,Models/Aliases.swift,Extensions/Image+Extensions.swift,LaTeX.swift) already uses it.UIFontis available on visionOS, so the UIKit branch is correct.2. visionOS-2.0 text-attribute path not gated for visionOS
EquationMarkerconforms to SwiftUI'sTextAttribute, which — withText.customAttribute— is available on iOS 18 / macOS 15 / visionOS 2.0. Five availability clauses spelled that generation as(iOS 18.0, macOS 15.0, *), omitting visionOS. Since the package's deployment floor is.visionOS(.v1), the*resolves to visionOS 1.0 and the compiler rejects the symbol:Fix: add
visionOS 2.0to all five clauses:Models/EquationMarker.swift(@available)Views/LineSpacingNormalizer.swift(@available)Views/ComponentBlocksViews.swift(#available)Views/ComponentBlocksText.swift(#available)Models/Component.swift(#available)The existing
elsebranches still cover visionOS 1.x, so the package keeps its visionOS 1.0 floor (noPackage.swiftplatform bump needed).Scope / impact
main,develop, andv2.1at time of writing.🤖 Generated with Claude Code