Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bridge text blocks and tables to the native UIKit classes on iOS 27#1320

Merged
odrobnik merged 2 commits into
developfrom
claude/heuristic-yalow-2d02b3
Jun 12, 2026
Merged

Bridge text blocks and tables to the native UIKit classes on iOS 27#1320
odrobnik merged 2 commits into
developfrom
claude/heuristic-yalow-2d02b3

Conversation

@odrobnik

Copy link
Copy Markdown
Collaborator

What

Completes the last open item of #1317: TextBlockConverter now bridges the DT text block model to the native NSTextBlock/NSTextTable/NSTextTableBlock classes that UIKit publishes with the iOS 27 SDK — and the handoff is verified end to end on the iOS 27 simulator.

  • Converter on UIKit platforms. The same identity-preserving conversion that existed for AppKit now compiles for iOS/tvOS/visionOS/Mac Catalyst behind compiler(>=6.4) (Xcode 27), gated @available(iOS 27.0, …) at runtime. Per-edge accessor shims paper over the API difference (NSRectEdge on AppKit, the new CGRectEdge-based rectEdge: methods on UIKit).
  • Attributed-string handoff. New addingNativeTextBlocks(to:) / addingTextBlocksAttribute(to:) convert whole strings between the DTTextBlocks attribute and native NSParagraphStyle.textBlocks with one converter per document, so shared NSTextTable identity is preserved across paragraphs. DTCoreText output can be handed straight to a TextKit view on iOS 27.
  • Xcode 27 compatibility for the existing macOS code. The 27 SDKs change the AppKit text block enums from NSUInteger to NSInteger raw types and soft-deprecate the NSRectEdge accessors; the converter and the AppKit parity tests now bridge raw values with numericCast so both Xcode 26 and 27 build (the old code did not compile with Xcode 27 at all).
  • New TextBlockUIKitParityTests mirror the AppKit parity suite against UIKit and verify the handoff empirically. (Swift Testing rejects @available on @Test/@Suite, so the tests guard with runtime #available instead.)
  • tvOS build fix (drive-by). tvOS was failing to build on develop independent of this change: the non-iOS branch in NSString+CSS.swift used NSValue(size:), which doesn't exist on tvOS. The branch condition is now canImport(UIKit); CI doesn't build tvOS, so this had gone unnoticed.

Verified on the iOS 27 simulator

  • TextKit 1 lays out the converted tables natively: cells of a row side by side on one baseline, colspan rows below, borders / <th> styling / cell backgrounds rendered correctly.
  • The system HTML writer emits <table> markup from the converted blocks (Cocoa HTML Writer with table.t1/td.td1 CSS), and the system HTML reader now produces NSTextTableBlocks on iOS with the same string shape as macOS.
  • Known difference, not a regression: native automatic table layout stretches columns across the container, while DTCoreText's simplified algorithm hugs content (documented limitation in the DocC article).

Test matrix

Configuration Result
macOS, Xcode 26 (swift test, as CI) 299/299 ✅
macOS, Xcode 27 beta 299/299 ✅
iOS 27.0 simulator, Xcode 27 beta 299/299 ✅
iOS simulator, Xcode 26 (CI invocation) 291/291 ✅ (UIKit suite compiled out by design)
tvOS simulator build, Xcode 27 beta

CI stays green: with Xcode 26 the new code is entirely compiled out.

Closes the remaining checkboxes of #1317.

🤖 Generated with Claude Code

UIKit publishes NSTextBlock/NSTextTable/NSTextTableBlock with the iOS 27 SDK
(Xcode 27, Swift 6.4), so TextBlockConverter now compiles there too: the same
identity-preserving conversion as on macOS, plus attributed-string level
methods that move the DTTextBlocks attribute onto native
NSParagraphStyle.textBlocks (and back), so DTCoreText output can be handed
straight to TextKit. Verified on the iOS 27 simulator: TextKit 1 lays out
and renders the converted tables natively, and the system HTML reader and
writer round-trip them.

The 27 SDKs also change the AppKit text block enums from NSUInteger to
NSInteger raw types; the converter and the AppKit parity tests now bridge
raw values with numericCast so they compile with both Xcode 26 and 27.

Also routes tvOS through the UIKit branch for CSS shadow offsets, fixing
the tvOS build.

Co-Authored-By: Claude Fable 5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 507eac45f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Tests/DTCoreTextTests/TextBlockUIKitParityTests.swift
The macos-latest image only ships simulator runtimes for its default Xcode;
after pinning Xcode 26.0 the test job found no iOS devices at all. Download
the platform when no iPhone simulator is available before testing.

Also clarify in the UIKit parity suite why the raw-value test needs no
availability guard (the text block enums are available since iOS 6 in the
27 SDK; only the converter and per-edge accessors are 27-only).

Co-Authored-By: Claude Fable 5 <[email protected]>
@odrobnik odrobnik merged commit a1023df into develop Jun 12, 2026
2 checks passed
@odrobnik odrobnik deleted the claude/heuristic-yalow-2d02b3 branch June 12, 2026 07:33
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