Add iOS support and set default text colors#8
Conversation
|
Warning Review limit reached
More reviews will be available in 46 minutes and 21 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR restructures TextDiff into separate core/UI-common/macOS/iOS modules, adds iOS 18 support, introduces platform-agnostic UI primitives, implements an iOS Changes Cross-platform modularization
🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
Package.swift (1)
43-72:TESTINGflag scope makes#if !TESTING assert(...)blocks effectively dead.
TESTINGis defined for every debug build, not just test runs. Sinceassertis a no-op in release, the guarded assertions inDiffSegmentIndexer(and any similar guards) never execute in any configuration. If the intent is to suppress assertions only while running tests, consider moving theTESTINGdefine to the test target via an-Dunsafe flag / test plan, or use#if DEBUG && !TESTINGwith the flag set only in a dedicated configuration.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Package.swift` around lines 43 - 72, The TESTING build define is applied to all debug targets making any guards like `#if !TESTING` in DiffSegmentIndexer effectively dead; update the build settings so TESTING is only defined for actual test runs (e.g., remove `.define("TESTING", .when(configuration: .debug))` from the targets and instead add the flag only to the test target via an unsafe `-DTESTING` test-only flag or a dedicated test configuration), or adjust the conditionals to `#if DEBUG && !TESTING` and ensure TESTING is set only in the test configuration so assertions in DiffSegmentIndexer behave as intended.Sources/TextDiffCore/TextDiff.swift (1)
1-1: Consider deleting this placeholder file.A file containing only a comment adds noise without carrying anything the compiler or reader uses. If
TextDiffCoreneeds at least one source file to compile, keep it; otherwise drop it. If kept, a brief note pointing to the actual entry points (e.g.DiffSegmentIndexer.swift,TextDiffEngine.swift) would be more useful than the current one-liner.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Sources/TextDiffCore/TextDiff.swift` at line 1, This file is a no-op placeholder; either remove TextDiff.swift to eliminate noise (if TextDiffCore builds without it) or replace the comment with a concise guide pointing to the real entry points (e.g., reference DiffSegmentIndexer.swift and TextDiffEngine.swift) so readers know where the public API lives; update the repository accordingly and ensure the module still compiles after deleting or editing TextDiff.swift.Sources/TextDiff/TextDiffView.swift (1)
363-401: Add iOS previews for the new SwiftUI path.The macOS branch has previews, but the new iOS representable path has none. Add a couple of iOS
#Previews, for example default rendering and precomputed-result rendering.As per coding guidelines, SwiftUI views should always include
#Previewwith a few state configurations.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Sources/TextDiff/TextDiffView.swift` around lines 363 - 401, Add SwiftUI previews for the iOS representable by creating one or more `#Preview` blocks that instantiate TextDiffIOSRepresentable with (1) live inputs using original/updated/mode/style to show default rendering and (2) a precomputed TextDiffResult passed to the result parameter to show the precomputed-result rendering; reference TextDiffIOSRepresentable (the makeUIView/updateUIView paths) and ensure the previews compile under `#if` os(iOS) and exercise both branches (result != nil and result == nil).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Sources/TextDiffIOSUI/UITextDiffView.swift`:
- Around line 6-57: Add three public properties to
UITextDiffView—isRevertActionsEnabled: Bool, showsInvisibleCharacters: Bool, and
onRevertAction: ((DiffSegment) -> Void)?—with sensible defaults and didSet
observers that mirror NSTextDiffView semantics: when changed, set any relevant
internal state and call the same update/invalidation flow used elsewhere (e.g.
set contentSource = .text and call updateSegmentsIfNeeded() or call
invalidateCachedLayout()/mark pendingStyleInvalidation as appropriate). Ensure
the onRevertAction is stored and invoked by whatever revert-action UI/path the
view exposes, and reference existing helpers like updateSegmentsIfNeeded(),
invalidateCachedLayout(), contentSource, pendingStyleInvalidation, and segments
to locate where to hook the new behavior.
In `@Sources/TextDiffUICommon/TextDiffChangeStyleDefaults.swift`:
- Around line 9-14: The defaultRemoval TextDiffChangeStyle currently sets
strikethrough to false causing deletions to render without a strike; update the
defaultRemoval initializer (TextDiffChangeStyle defaultRemoval) to set
strikethrough: true so deleted text uses the strikethrough style by default,
leaving other properties (fillColor, strokeColor, textColorOverride) unchanged.
In `@Sources/TextDiffUICommon/TextDiffViewModel.swift`:
- Around line 3-4: Remove the duplicate import by deleting one of the repeated
"import TextDiffCore" statements in TextDiffViewModel.swift so the module is
only imported once; keep a single "import TextDiffCore" line and remove the
redundant one.
---
Nitpick comments:
In `@Package.swift`:
- Around line 43-72: The TESTING build define is applied to all debug targets
making any guards like `#if !TESTING` in DiffSegmentIndexer effectively dead;
update the build settings so TESTING is only defined for actual test runs (e.g.,
remove `.define("TESTING", .when(configuration: .debug))` from the targets and
instead add the flag only to the test target via an unsafe `-DTESTING` test-only
flag or a dedicated test configuration), or adjust the conditionals to `#if
DEBUG && !TESTING` and ensure TESTING is set only in the test configuration so
assertions in DiffSegmentIndexer behave as intended.
In `@Sources/TextDiff/TextDiffView.swift`:
- Around line 363-401: Add SwiftUI previews for the iOS representable by
creating one or more `#Preview` blocks that instantiate TextDiffIOSRepresentable
with (1) live inputs using original/updated/mode/style to show default rendering
and (2) a precomputed TextDiffResult passed to the result parameter to show the
precomputed-result rendering; reference TextDiffIOSRepresentable (the
makeUIView/updateUIView paths) and ensure the previews compile under `#if` os(iOS)
and exercise both branches (result != nil and result == nil).
In `@Sources/TextDiffCore/TextDiff.swift`:
- Line 1: This file is a no-op placeholder; either remove TextDiff.swift to
eliminate noise (if TextDiffCore builds without it) or replace the comment with
a concise guide pointing to the real entry points (e.g., reference
DiffSegmentIndexer.swift and TextDiffEngine.swift) so readers know where the
public API lives; update the repository accordingly and ensure the module still
compiles after deleting or editing TextDiff.swift.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9add5936-e6ca-4644-b093-7beb1377b8f9
⛔ Files ignored due to path filters (18)
Tests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/character_mode_no_affordance.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/character_suffix_refinement.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/custom_style_spacing_strikethrough.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/hover_pair_affordance.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/hover_single_addition_affordance.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/hover_single_deletion_affordance.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/invisible_characters_debug_overlay.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/multiline_insertion_wrap.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/narrow_width_wrapping.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/punctuation_replacement.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/token_basic_replacement.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/character_suffix_refinement.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/custom_style_spacing_strikethrough.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/multiline_insertion_wrap.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/precomputed_result_rendering.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/punctuation_replacement.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/token_basic_replacement.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/whitespace_only_layout_change.1.pngis excluded by!**/*.png
📒 Files selected for processing (34)
Package.swiftSources/TextDiff/TextDiff.swiftSources/TextDiff/TextDiffChangeStyleDefaults.swiftSources/TextDiff/TextDiffView.swiftSources/TextDiffCore/DiffSegmentIndexer.swiftSources/TextDiffCore/DiffTypes.swiftSources/TextDiffCore/MyersDiff.swiftSources/TextDiffCore/TextDiff.swiftSources/TextDiffCore/TextDiffEngine.swiftSources/TextDiffCore/TextDiffResult.swiftSources/TextDiffCore/Tokenizer.swiftSources/TextDiffIOSUI/UITextDiffView.swiftSources/TextDiffMacOSUI/AppKit/DiffRevertActionResolver.swiftSources/TextDiffMacOSUI/AppKit/DiffTextViewRepresentable.swiftSources/TextDiffMacOSUI/AppKit/NSTextDiffContentSource.swiftSources/TextDiffMacOSUI/AppKit/NSTextDiffView.swiftSources/TextDiffUICommon/DiffTextLayoutMetrics.swiftSources/TextDiffUICommon/DiffTokenLayouter.swiftSources/TextDiffUICommon/TextDiffChangeStyle.swiftSources/TextDiffUICommon/TextDiffChangeStyleDefaults.swiftSources/TextDiffUICommon/TextDiffGroupStrokeStyle.swiftSources/TextDiffUICommon/TextDiffPlatformTypes.swiftSources/TextDiffUICommon/TextDiffStyle.swiftSources/TextDiffUICommon/TextDiffStyling.swiftSources/TextDiffUICommon/TextDiffViewModel.swiftTests/TextDiffCoreTests/TextDiffEngineTests.swiftTests/TextDiffMacOSUITests/DiffLayouterPerformanceTests.swiftTests/TextDiffMacOSUITests/DiffRevertActionResolverTests.swiftTests/TextDiffMacOSUITests/NSTextDiffSnapshotTests.swiftTests/TextDiffMacOSUITests/NSTextDiffViewTests.swiftTests/TextDiffMacOSUITests/SnapshotTestSupport.swiftTests/TextDiffMacOSUITests/TextDiffSnapshotTests.swiftTests/TextDiffMacOSUITests/TextDiffStyleAndLayouterTests.swiftTests/TextDiffMacOSUITests/TextDiffViewModelTests.swift
💤 Files with no reviewable changes (1)
- Sources/TextDiff/TextDiffChangeStyleDefaults.swift
|
@coderabbitai review the code |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check the new iOS UI file
cat Sources/TextDiffIOSUI/UITextDiffView.swift
# Check platform types
cat Sources/TextDiffUICommon/TextDiffPlatformTypes.swift
# Check TextDiff.swift re-exports
cat Sources/TextDiff/TextDiff.swift
# Check Package.swift
cat Package.swift
# Check TextDiffView.swift
cat Sources/TextDiff/TextDiffView.swift
# Check TextDiffChangeStyleDefaults in UICommon
cat Sources/TextDiffUICommon/TextDiffChangeStyleDefaults.swift
# Check TextDiffStyle
cat Sources/TextDiffUICommon/TextDiffStyle.swift
# Check if there are any TODO/FIXME comments
rg -n "TODO|FIXME|HACK|XXX" --type swiftLength of output: 32741
SummaryThe modular split is solid and the cross-platform approach is clean. A few things worth fixing: 🔴 High Priority1.
2. In typealias DiffProvider = (String, String, TextDiffComparisonMode) -> [DiffSegment]This is 3. In .define("TESTING", .when(configuration: .debug))This means the test-only 4. No test coverage for There's a 🟡 Medium Priority5. It's only used in 6. Redundant dependencies in dependencies: [
"TextDiff", // re-exports TextDiffCore, TextDiffUICommon, TextDiffMacOSUI
"TextDiffCore", // redundant
"TextDiffUICommon",// redundant
"TextDiffMacOSUI", // redundant
...
]Since 7. Dead code in public func setContent(result: TextDiffResult, style: TextDiffStyle) {
isBatchUpdating = true
defer {
isBatchUpdating = false
pendingStyleInvalidation = false // ← reset, but never read
}
self.style = style // sets pendingStyleInvalidation = true
apply(result: result) // always calls invalidateCachedLayout()
}
🟢 Low Priority8. iOS 18 minimum is very restrictive .iOS(.v18)iOS 16 or 17 would cover significantly more devices. Unless you're using iOS 18-only APIs (not obvious from the diff), consider lowering this. 9.
10. Misleading iOS preview `#Preview`("iOS Representable Precomputed Result") {
TextDiffIOSRepresentable(
result: TextDiffEngine.result(...),
original: "", // ← ignored but confusing
updated: "",
...
)
}The |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Sources/TextDiff/TextDiffView.swift (1)
490-491: 💤 Low valueEmpty strings are confusing when result contains actual values.
The
resultalready has the original and updated strings baked in. Passing empty strings here is misleading to anyone reading the preview. Use the actual strings for clarity.Suggested fix
- original: "", - updated: "", + original: "Track old values in storage.", + updated: "Track new values in storage.",🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Sources/TextDiff/TextDiffView.swift` around lines 490 - 491, The preview is passing empty strings for the original/updated text which is confusing; update the call in TextDiffView (where original: "" and updated: "") to pass the actual strings from the diff result (e.g., use result.original and result.updated or the appropriate properties on the `result` object) so the preview shows real content; locate the initializer/call that supplies original/updated in TextDiffView.swift and replace the empty literals with the corresponding `result` properties.Sources/TextDiffIOSUI/UITextDiffView.swift (1)
7-7: 💤 Low value
DiffProvidertypealias is internal but exposed viaTESTINGinit.The
DiffProvidertypealias has default internal access, but the#if TESTINGinitializer accepts it as a parameter. If tests in a separate module need this initializer,DiffProviderneeds to bepublic. If tests are only within this module, it's fine as-is.Also note: PR objectives mention that
TESTINGis set for all debug builds (.when(configuration: .debug)), so this init leaks into any consumer's debug build, not just test targets.Also applies to: 119-139
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Sources/TextDiffIOSUI/UITextDiffView.swift` at line 7, The DiffProvider typealias is currently internal but is exposed as a parameter on the UITextDiffView initializer that’s compiled under `#if` TESTING; make the access levels consistent by marking the typealias public (change "typealias DiffProvider = ..." to "public typealias DiffProvider = ...") so it can be used from test modules, or alternatively restrict the TESTING-only initializer (the UITextDiffView init under the TESTING block) to internal/private or narrow the compile flag so it doesn’t leak into consumer debug builds—update the DiffProvider declaration or the TESTING init accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Sources/TextDiff/TextDiffView.swift`:
- Around line 490-491: The preview is passing empty strings for the
original/updated text which is confusing; update the call in TextDiffView (where
original: "" and updated: "") to pass the actual strings from the diff result
(e.g., use result.original and result.updated or the appropriate properties on
the `result` object) so the preview shows real content; locate the
initializer/call that supplies original/updated in TextDiffView.swift and
replace the empty literals with the corresponding `result` properties.
In `@Sources/TextDiffIOSUI/UITextDiffView.swift`:
- Line 7: The DiffProvider typealias is currently internal but is exposed as a
parameter on the UITextDiffView initializer that’s compiled under `#if` TESTING;
make the access levels consistent by marking the typealias public (change
"typealias DiffProvider = ..." to "public typealias DiffProvider = ...") so it
can be used from test modules, or alternatively restrict the TESTING-only
initializer (the UITextDiffView init under the TESTING block) to
internal/private or narrow the compile flag so it doesn’t leak into consumer
debug builds—update the DiffProvider declaration or the TESTING init
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 00b917c8-8146-4486-b554-a616cbc26b7b
⛔ Files ignored due to path filters (4)
Tests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/custom_style_spacing_strikethrough.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/hover_pair_affordance.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/NSTextDiffSnapshotTests/narrow_width_wrapping.1.pngis excluded by!**/*.pngTests/TextDiffMacOSUITests/__Snapshots__/TextDiffSnapshotTests/custom_style_spacing_strikethrough.1.pngis excluded by!**/*.png
📒 Files selected for processing (10)
Package.swiftREADME.mdSources/TextDiff/TextDiffView.swiftSources/TextDiffIOSUI/UITextDiffView.swiftSources/TextDiffMacOSUI/AppKit/NSTextDiffView.swiftSources/TextDiffUICommon/DiffRevertActionResolver.swiftSources/TextDiffUICommon/DiffRevertHitResolver.swiftSources/TextDiffUICommon/TextDiffViewModel.swiftTests/TextDiffUICommonTests/DiffRevertActionResolverTests.swiftTests/TextDiffUICommonTests/DiffRevertHitResolverTests.swift
💤 Files with no reviewable changes (1)
- Sources/TextDiffUICommon/TextDiffViewModel.swift
✅ Files skipped from review due to trivial changes (1)
- README.md
🚧 Files skipped from review as they are similar to previous changes (1)
- Package.swift
- Keep indexed segment cursors aligned with source text when equal display segments are synthetic - Refresh UITextDiffView content immediately after revert actions - Reject stale revert candidates whose updated fragment no longer matches - Add regression coverage for shifted ranges
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Sources/TextDiffCore/DiffSegmentIndexer.swift (1)
35-50:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReplace the ineffective
assertchecks with a release-active diagnosticIn
Sources/TextDiffCore/DiffSegmentIndexer.swift(lines 35-50), theassert(...)calls are inside#if !TESTING, andTESTINGis defined for theTextDiffCoreandTextDiffUICommontargets only for.debug, so those assertions don’t compile in Debug. In Release (-O), Swiftassert()is compiled out/no-op, so mismatches produce no signal in any build.
- Drop the dead asserts, or replace them with a check that stays active in Release (e.g.,
precondition/preconditionFailureor a lightweight logging/error path).♻️ Remove the ineffective asserts
let originalMatches = textMatches(segment.text, source: originalNSString, at: originalCursor) let updatedMatches = textMatches(segment.text, source: updatedNSString, at: updatedCursor) - `#if` !TESTING - assert( - originalMatches, - "Equal segment text mismatch in original at \(originalCursor) for segment \(index): \(segment.text)" - ) - assert( - updatedMatches, - "Equal segment text mismatch in updated at \(updatedCursor) for segment \(index): \(segment.text)" - ) - `#endif` if originalMatches { originalCursor += textLength } if updatedMatches { updatedCursor += textLength }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Sources/TextDiffCore/DiffSegmentIndexer.swift` around lines 35 - 50, The assert(...) checks in DiffSegmentIndexer.swift around originalMatches/updatedMatches are ineffective in some builds; replace them with release-active diagnostics: change the assert calls that reference originalMatches, updatedMatches, originalCursor, updatedCursor, segment.text and textLength to use precondition or call preconditionFailure with the same descriptive messages (so mismatches raise in Release), or alternatively log and throw a fatal error if that fits your error model; ensure the checks occur before advancing originalCursor/updatedCursor in the same function (e.g., in the scope where those asserts currently live).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@Sources/TextDiffCore/DiffSegmentIndexer.swift`:
- Around line 35-50: The assert(...) checks in DiffSegmentIndexer.swift around
originalMatches/updatedMatches are ineffective in some builds; replace them with
release-active diagnostics: change the assert calls that reference
originalMatches, updatedMatches, originalCursor, updatedCursor, segment.text and
textLength to use precondition or call preconditionFailure with the same
descriptive messages (so mismatches raise in Release), or alternatively log and
throw a fatal error if that fits your error model; ensure the checks occur
before advancing originalCursor/updatedCursor in the same function (e.g., in the
scope where those asserts currently live).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3017b79e-7ea9-42a4-8acc-8771d51c22b2
📒 Files selected for processing (4)
Sources/TextDiffCore/DiffSegmentIndexer.swiftSources/TextDiffIOSUI/UITextDiffView.swiftSources/TextDiffUICommon/DiffRevertActionResolver.swiftTests/TextDiffUICommonTests/DiffRevertActionResolverTests.swift
🚧 Files skipped from review as they are similar to previous changes (1)
- Sources/TextDiffIOSUI/UITextDiffView.swift
This pull request restructures the
TextDiffpackage to support both macOS and iOS platforms, modularizes the codebase into platform-specific and shared components, and updates the SwiftUI interface to be cross-platform. The most significant changes include the introduction of new library and target modules, refactoring of the main SwiftUI view to support both platforms, and moving core logic into a newTextDiffCoretarget.Cross-platform and modularization updates:
Package.swift) now supports both macOS and iOS, and defines new library products and targets:TextDiffCore,TextDiffUICommon,TextDiffMacOSUI, andTextDiffIOSUI, along with platform-conditional dependencies and test targets. [1] [2]TextDifftarget now re-exports the core and UI modules, and conditionally includes the macOS or iOS UI module depending on the platform. (Sources/TextDiff/TextDiff.swift)SwiftUI view refactorings:
TextDiffViewinSources/TextDiff/TextDiffView.swiftis refactored to use platform-conditional logic, delegating to either a macOS (TextDiffMacOSRepresentable) or iOS (TextDiffIOSRepresentable) implementation. This enables the same SwiftUI interface to work seamlessly across platforms. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]PlatformFontandTextDiffEdgeInsetsare now used in place of AppKit-only types, making the style configuration cross-platform. [1] [2] [3] [4]Core logic reorganization:
DiffSegmentIndexerand related types) has been moved fromSources/TextDiffto a newSources/TextDiffCoretarget, and access levels have been updated to use Swift's newpackagevisibility.Sources/TextDiffCore/TextDiff.swiftfor clarity.Cleanup and removals:
TextDiffChangeStyleDefaults.swift, further decoupling platform-specific code.These changes lay the foundation for a clean, modular, and cross-platform Swift package architecture for text diffing.
Summary by CodeRabbit
New Features
Breaking Changes
Refactor
Documentation