Skip to content

fix(camera): compile the macOS nitro-image patch with Swift 6.2 - #521

Open
adelbeke wants to merge 1 commit into
LegendApp:mainfrom
adelbeke:ad/fix-nitro-image-macos-swift
Open

adelbeke wants to merge 1 commit into
LegendApp:mainfrom
adelbeke:ad/fix-nitro-image-macos-swift

Conversation

@adelbeke

Copy link
Copy Markdown
Contributor

Why

A new Spark app created from main fails to build its macOS dev build on Xcode 26.2 (Swift 6.2.3):

react-native-nitro-image/macos/MacImage.swift:55:16: error: type of expression is ambiguous without a type annotation
    return try render(abs(bounds.width), abs(bounds.height)) { context in

macos/MacImage.swift is not upstream code: Spark's patches/camera/react-native-nitro-image.patch creates it. In rotate(), the multi-statement closure passed to render() mixes CGFloat (the rotated CGRect bounds) and Double (the image size), and Swift 6.2's type checker gives up on inferring it. The Kitchen Sink does not link NitroImage, so its builds did not catch it.

What

  • Convert the rotated bounds to Double and capture the source size before the closure.
  • Annotate the closure parameter as CGContext.
  • Update the hunk header (+1,183 to +1,185).

Same rotation math, only explicit types.

Verification

  • The diff package (which native-patches.cjs uses to apply patches) applies the updated patch to an empty file, and the output matches the hand-fixed file byte for byte.
  • spark build --dev --platform macos of a fresh spark create --universal app (packed from main) fails without the fix and builds with it, on Xcode 26.2.

Not verified: an older Xcode such as CI's macos-latest. The change only adds explicit types, so it should still compile there, and CI covers it.

🤖 Generated with Claude Code

Xcode 26.2 (Swift 6.2.3) rejects MacImage.rotate() with "type of
expression is ambiguous without a type annotation": the multi-statement
closure passed to render() mixes CGFloat and Double. Any new app that
links react-native-nitro-image on macOS failed to build.

Convert the rotated bounds to Double and type the closure parameter so
the type checker no longer has to infer them.
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.

1 participant