Skip to content

fix(svg): build on iOS without @nativescript/canvas - #180

Merged
triniwiz merged 1 commit into
masterfrom
fix/canvas-svg-standalone-ios
Oct 9, 2026
Merged

triniwiz merged 1 commit into
masterfrom
fix/canvas-svg-standalone-ios

Conversation

@triniwiz

@triniwiz triniwiz commented Oct 9, 2026

Copy link
Copy Markdown
Member

Problem

@nativescript/canvas-svg doesn't build on iOS unless @nativescript/canvas is also installed:

canvas-svg/platforms/ios/src/cpp/SVGCommon.h:6:10: fatal error: 'include/v8.h' file not found

The SVG sources compile against the V8 headers, but only canvas (and audio-context) ship them, as the NativeScriptV8 SwiftPM shim. Android isn't affected: its native libraries only link against the NativeScript runtime.

Fix

  • SwiftPM shim: ship the same NativeScriptV8 shim (Package.swift, Headers, Sources) from nativescript-v8/ as canvas and audio-context do. A plugin nativescript.config.ts declares it, and the CLI dedupes the same-named CanvasNative package across plugins.
  • build.xcconfig: add Headers/include to the search path, as canvas's build.xcconfig does, and build as C++20 for V8 14.9. The shim alone gets include/v8.h to resolve, but the V8 headers then include each other by bare name (cppgc/common.h → "v8config.h"). The flags use their own variable names, so the CLI's xcconfig merge appends them next to canvas's instead of dropping one.

Testing

nx build wasn't available in my checkout, so I assembled the package by hand (published 3.0.0-beta.3 plus this change's assets) and ran it in a NativeScript Vue app on the iPhone 17 Pro simulator, iOS 26.4:

Setup Result
Before: canvas-svg 3.0.0-beta.3 only ❌ 'include/v8.h' file not found
SwiftPM shim only, no xcconfig flags ❌ 'v8config.h' file not found
This PR, canvas-svg only ✅ builds, SVGs render
This PR + @nativescript/canvas 3.0.0-beta.3 ✅ builds, one CanvasNative package, both plugins' header flags merged, no xcconfig conflicts

Android with canvas-svg only builds as before.

Note

audio-context ships the shim but its build.xcconfig has neither the Headers/include flag nor C++20, so it probably hits the same v8config.h error when it's installed without canvas. I haven't tested that.

canvas-svg's iOS sources include "include/v8.h", but the package shipped no
V8 headers, so an app with only canvas-svg failed to build ('include/v8.h'
file not found). It only worked when @nativescript/canvas was installed too.

Ship the same NativeScriptV8 SwiftPM shim audio-context and canvas ship, with
a plugin nativescript.config.ts declaring it (the CLI dedupes the package
across plugins). As in canvas's build.xcconfig, also add Headers/include
itself to the search path, since the V8 headers include each other by bare
name (cppgc/common.h -> "v8config.h"), and build as C++20 for V8 14.9.
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e4833062-656c-4a3e-9f93-cd571e6d4f85

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@triniwiz
triniwiz merged commit 87479e1 into master Oct 9, 2026
14 of 21 checks passed
@triniwiz
triniwiz deleted the fix/canvas-svg-standalone-ios branch October 9, 2026 18:41
triniwiz added a commit that referenced this pull request Oct 9, 2026
AudioModule.mm includes the runtime's Runtime.h, whose headers include V8
by bare name ("v8.h"), so an app with only audio-context failed to build
('v8.h' file not found). It only worked when @nativescript/canvas was
installed too, since canvas's build.xcconfig puts Headers/include on the
search path.

audio-context already ships the NativeScriptV8 SwiftPM shim; as in #180 for
canvas-svg, add the shim's Headers/include to the search path and build as
C++20 for V8 14.9.
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