feat: enable CoreGraphics polyfill on Android#85
Closed
pedrovgs wants to merge 95 commits into
Closed
Conversation
- Add conditional import statements across all SVG-related files - Use Foundation for WebAssembly System Interface (WASI) platform - Keep SwiftUI/Combine imports for other platforms - Enable cross-platform compatibility for WebAssembly environments
- Remove @published property wrappers when targeting WASI platform - Maintain identical public API surface with conditional compilation - Continue implementation of WASI platform support from previous commit
- Change approach from conditionally compiling model properties to conditionally compiling UI code - Wrap SwiftUI view implementations in #if !os(WASI) blocks instead of duplicating property declarations - Simplify code structure while maintaining full WASI platform compatibility - Improve maintainability by reducing conditional compilation complexity
- Upgrade Swift tools version from 5.3 to 5.9 - Increase minimum macOS version from 11 to 14 - Maintain existing requirements for iOS (14) and watchOS (7)
- Change `#if os(WASI)` to `#if os(WASI) || os(Linux)` throughout codebase - Replace `#if !os(WASI)` with `#if canImport(SwiftUI)` for better platform detection - Add conditional compilation for published properties on Linux platform - Ensure proper handling of SwiftUI dependencies across all platforms
- Implement CGPath, CGAffineTransform and related types for non-Apple platforms - Create MBezierPath implementation compatible with Linux/WASI - Add mathematical function wrappers needed for graphics operations - Use conditional compilation to maintain native CoreGraphics on Apple platforms
- Improves code organization by separating core SVG functionality from SwiftUI integrations - Reduces platform-specific dependencies in base class definitions - Makes the codebase more maintainable by isolating UI framework bindings - Consistent with modern Swift architectural practices of protocol conformance via extensions
- Wrap SwiftUI-dependent methods in SVGNode, SVGColor, SVGFont and SVGStroke with #if canImport(SwiftUI) - Move gesture handling code inside conditional compilation blocks - Ensure SVG components work on platforms where SwiftUI is unavailable - Continues the cross-platform compatibility work for Linux and WASI platforms
- Organize imports into clearer platform-specific sections - Add explicit UIKit import for iOS/tvOS/watchOS platforms - Remove unnecessary SwiftUI import - Move Foundation import to Linux/WASI specific section
- Replace SwiftUI's HorizontalAlignment with custom SVGText.Anchor enum - Add conversion between Anchor and HorizontalAlignment for SwiftUI compatibility - Update serialization to work with the new enum - Continue ongoing efforts to reduce platform-specific dependencies
- Add conditional compilation directives to make bezierPath variables mutable on Linux/WASI - Follows pattern of other platform-specific fixes for cross-platform compatibility
- Remove unnecessary CGFloat, CGSize, and CGPoint typealiases - Add missing Foundation imports to SVG parser files - Continue improving cross-platform compatibility
These math function declarations (sqrt, copysign, acos, cos, sin) are no longer needed in the Linux/WASI environment as they're likely available from standard libraries or other imports.
- Change implementation from struct to class to better match CoreGraphics behavior - Remove mutating keywords from methods as they're no longer needed - Update parameter types in addArcTo method to match class-based approach
- Tests CGAffineTransform operations (identity, translation, scaling, rotation) - Verifies CGPath functionality (basic operations, bounding box calculation) - Covers MBezierPath operations (initialization, path building, transformations) - Includes tests for PathElement enum and extensions - Handles edge cases and platform-specific behavior
- Set up GitHub Actions workflow to run tests on Linux - Add CoreGraphicsPolyfillTests test target to Package.swift - Remove unnecessary exclude entry for Info.plist
- Test on macOS-latest to validate against native CoreGraphics implementation - Mirror existing Linux test job structure with caching and test discovery
Make SVGView XP compliant
Expose MBezierPath helper methods as public API
- Add public applyWithBlock method to CGPath extension for WASI/Linux - Convert internal PathElement types to CGPathElement for API compatibility - Enable block-based iteration over path elements using unsafe pointers - Support all path element types including curves and subpath operations
- Remove Exyte branding and company-specific content - Add attribution to original exyte/SVGView repository - Document Goodnotes-specific customizations and requirements - Add development section with Makefile usage instructions - Simplify project overview and remove platform badges
- Fix YAML formatting and indentation consistency - Filter Linux tests to CoreGraphicsPolyfillTests only - Remove trailing whitespace and normalize spacing
- Add fallback CLI implementation for non-macOS platforms - Display clear error message when attempting to run on unsupported systems - Maintain existing functionality on macOS while preventing execution elsewhere
Improve DX ergonomic
[FFA-502] Parse width and height
…rt_html [FFA-593] Parse RGBA string
Make PathReader class and initializer public
Fix matrix concat order in polyfill
Adds os(Android) alongside os(WASI) and os(Linux) to every gate that selects the pure-Swift CoreGraphics polyfill. The polyfill is Foundation only, so it works on Android without further changes; this just opts the platform in so downstream packages (GoodNotes' SVGToNotesItems, CommonNLI) can build for Android the same way they already build for WASI/Linux. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
|
Wrong target — should go to the GoodNotes fork (GoodNotes#15). |
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
Extends every
#if os(WASI) || os(Linux)gate inSource/andTests/to also includeos(Android)so the pure-Swift CoreGraphics polyfill is selected on Android. The polyfill is Foundation-only — no platform-specific code — so the same path that's been working for WASI/Linux works on Android with no further changes.Why: downstream packages (
GoodNotes/CanvasKit'sSVGToNotesItems,CommonNLI's SVG conversion) need this to build on Android. Until now, anywhere that importsSVGToNotesItemseither had to#if canImport(SVGToNotesItems)guard the call site or exclude itself from the Android build graph.Tagged as
0.2.0-goodnotes.Test plan
swift buildon Apple unchanged (CoreGraphics path still used).swift buildon WASI/Linux unchanged (polyfill path still used).CanvasKit/CanvasKitAndroidDemo now succeeds withSVGToNotesItemslinked.🤖 Generated with Claude Code