Skip to content

Commit 1750358

Browse files
committed
chore: upgrade minimum iOS version from 15.0 to 18.0
- Update all @available annotations from iOS 15.0/16.0 to iOS 18.0 - Remove iOS 15/16 compatibility checks and fallback code in RichView.swift - Simplify MarkdownRenderer usage by removing version checks - Update phase-4 integration tracking documentation - Update technical plan with new iOS 18.0 requirement This change eliminates the need for iOS 15 compatibility workarounds, enabling full use of modern Swift APIs (Regex, etc.) throughout RichView. Progress: Phase 4, Task 8/11 (iOS version update complete) Refs: .plan/phases/phase-4-integration.md Tracking: #70
1 parent c5d3ae9 commit 1750358

File tree

11 files changed

+61
-73
lines changed

11 files changed

+61
-73
lines changed

.plan/phases/phase-4-integration.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -182,39 +182,35 @@ Replace existing implementations with RichView:
182182

183183
## 📝 Notes
184184

185-
### iOS 15 Compatibility Status
186-
187-
**Current Implementation (08b9230)**:
188-
- Basic RichView integration complete
189-
- Using simplified AttributedString rendering (no markdown formatting)
190-
- iOS 16+ features temporarily disabled:
191-
- MarkdownRenderer.swift (#if false - requires Regex API)
192-
- RenderActor.swift (removed from build)
193-
- RichContentView.swift (removed from build - depends on ContentElement)
194-
- RichContentView+Preview.swift (removed from build)
195-
196-
**What Works**:
197-
- HTML to Markdown conversion (HTMLToMarkdownConverter)
198-
- Basic text rendering with font and color styling
199-
- Link tap handling
200-
- Dark mode support
201-
- Height calculation via onRenderCompleted
202-
- Cache system (markdown and attributedString tiers)
203-
204-
**What's Missing (iOS 15 compatible implementation needed)**:
205-
- **Bold**, *italic*, `code` inline formatting
206-
- Code block rendering with syntax highlighting
207-
- @mention highlighting and tap handling
208-
- Image rendering
209-
- Heading styles (H1-H6)
210-
- Blockquote styling
211-
- List rendering (bullets and numbers)
185+
### iOS 18.0 Minimum Version
186+
187+
**Status**: ✅ Minimum iOS version upgraded to 18.0
188+
189+
**Changes Made**:
190+
- Updated all `@available(iOS 15.0, *)``@available(iOS 18.0, *)`
191+
- Updated all `@available(iOS 16.0, *)``@available(iOS 18.0, *)`
192+
- Removed iOS 15/16 compatibility checks and fallback code
193+
- All RichView features now available without version checks
194+
195+
**Fully Enabled Features**:
196+
- ✅ HTML to Markdown conversion (HTMLToMarkdownConverter)
197+
-**Bold**, *italic*, `code` inline formatting
198+
- ✅ Code block rendering with syntax highlighting (Highlightr)
199+
-@mention highlighting and tap handling
200+
- ✅ Image rendering (AsyncImageAttachment)
201+
- ✅ Heading styles (H1-H6)
202+
- ✅ Blockquote styling
203+
- ✅ List rendering (bullets and numbers)
204+
- ✅ Link tap handling
205+
- ✅ Dark mode support
206+
- ✅ Height calculation via onRenderCompleted
207+
- ✅ Cache system (markdown and attributedString tiers)
212208

213209
**Next Steps**:
214-
1. Implement iOS 15-compatible MarkdownRenderer using NSRegularExpression
215-
2. Re-enable RenderActor with NSRegularExpression-based parsing
216-
3. Test with real V2EX content
217-
4. Compare rendering quality with HtmlView/RichText
210+
1. Manual testing with real V2EX content
211+
2. Performance comparison testing
212+
3. Integration testing
213+
4. Move to Phase 5 (rollout)
218214

219215
### Migration Strategy
220216
1. **Parallel Implementation**: Keep old code until RichView proven stable

.plan/richtext_plan.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,10 +1269,11 @@ struct DegradationAnalytics {
12691269
### 开放问题响应
12701270

12711271
**iOS 版本兼容性**
1272-
- ✅ 项目最低版本:**iOS 17.0**
1272+
- ✅ 项目最低版本:**iOS 18.0**(2025-10-19 updated)
12731273
- ✅ swift-markdown 要求:iOS 15.0+(满足)
12741274
- ✅ AttributedString 要求:iOS 15.0+(满足)
1275-
- ✅ 老设备(iOS 16 及以下)将通过应用内公告提示保持旧版 WebView 展示
1275+
- ✅ Regex API 要求:iOS 16.0+(满足)
1276+
- ✅ 所有功能全面启用,无需兼容性降级
12761277

12771278
### 修正任务清单
12781279

V2er/Sources/RichView/Cache/RichViewCache.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
import SwiftUI
1010

1111
/// Three-tier caching system for RichView rendering
12-
@available(iOS 15.0, *)
12+
@available(iOS 18.0, *)
1313
public class RichViewCache {
1414

1515
// MARK: - Singleton
@@ -239,7 +239,7 @@ public struct CacheStatistics {
239239

240240
// MARK: - Cached Values
241241

242-
@available(iOS 15.0, *)
242+
@available(iOS 18.0, *)
243243
private class CachedAttributedString {
244244
let attributedString: AttributedString
245245
let timestamp: Date

V2er/Sources/RichView/Models/AsyncImageAttachment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SwiftUI
99
import Kingfisher
1010

1111
/// AsyncImage view for RichView with Kingfisher integration
12-
@available(iOS 15.0, *)
12+
@available(iOS 18.0, *)
1313
public struct AsyncImageAttachment: View {
1414

1515
// MARK: - Properties
@@ -216,7 +216,7 @@ public class ImageCacheManager {
216216

217217
// MARK: - Preview
218218

219-
@available(iOS 15.0, *)
219+
@available(iOS 18.0, *)
220220
struct AsyncImageAttachment_Previews: PreviewProvider {
221221
static var previews: some View {
222222
VStack(spacing: 20) {

V2er/Sources/RichView/Models/CodeBlockAttachment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import SwiftUI
99

1010
/// Code block view with optional syntax highlighting
11-
@available(iOS 15.0, *)
11+
@available(iOS 18.0, *)
1212
public struct CodeBlockAttachment: View {
1313

1414
// MARK: - Properties
@@ -229,7 +229,7 @@ extension EdgeInsets {
229229

230230
// MARK: - Preview
231231

232-
@available(iOS 15.0, *)
232+
@available(iOS 18.0, *)
233233
struct CodeBlockAttachment_Previews: PreviewProvider {
234234
static let swiftCode = """
235235
func fibonacci(_ n: Int) -> Int {

V2er/Sources/RichView/Renderers/MarkdownRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
import SwiftUI
1010

1111
/// Renders Markdown content to AttributedString with styling
12-
@available(iOS 16.0, *)
12+
@available(iOS 18.0, *)
1313
public class MarkdownRenderer {
1414

1515
private let stylesheet: RenderStylesheet

V2er/Sources/RichView/Renderers/RenderActor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
import SwiftUI
1010

1111
/// Actor for thread-safe background rendering
12-
@available(iOS 16.0, *)
12+
@available(iOS 18.0, *)
1313
public actor RenderActor {
1414

1515
// MARK: - Properties
@@ -207,7 +207,7 @@ public actor RenderActor {
207207

208208
// MARK: - Render Result
209209

210-
@available(iOS 15.0, *)
210+
@available(iOS 18.0, *)
211211
public struct RenderResult {
212212
public let elements: [ContentElement]
213213
public let metadata: RenderMetadata

V2er/Sources/RichView/Views/RichContentView+Preview.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
@available(iOS 15.0, *)
10+
@available(iOS 18.0, *)
1111
struct RichContentView_Previews: PreviewProvider {
1212

1313
static var previews: some View {
@@ -138,7 +138,7 @@ struct RichContentView_Previews: PreviewProvider {
138138

139139
// MARK: - Interactive Preview
140140

141-
@available(iOS 15.0, *)
141+
@available(iOS 18.0, *)
142142
struct RichContentViewInteractive: View {
143143
@State private var htmlInput = RichContentView_Previews.complexExample
144144
@State private var selectedStyle: StylePreset = .default
@@ -199,7 +199,7 @@ struct RichContentViewInteractive: View {
199199
}
200200
}
201201

202-
@available(iOS 15.0, *)
202+
@available(iOS 18.0, *)
203203
struct RichContentViewPlayground: View {
204204
var body: some View {
205205
NavigationView {
@@ -208,7 +208,7 @@ struct RichContentViewPlayground: View {
208208
}
209209
}
210210

211-
@available(iOS 15.0, *)
211+
@available(iOS 18.0, *)
212212
struct RichContentViewPlayground_Previews: PreviewProvider {
213213
static var previews: some View {
214214
RichContentViewPlayground()

V2er/Sources/RichView/Views/RichContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import SwiftUI
99

1010
/// Enhanced RichView that properly renders images, code blocks, and complex content
11-
@available(iOS 16.0, *)
11+
@available(iOS 18.0, *)
1212
public struct RichContentView: View {
1313

1414
// MARK: - Properties
@@ -182,7 +182,7 @@ public struct ContentElement: Identifiable {
182182

183183
// MARK: - Configuration
184184

185-
@available(iOS 15.0, *)
185+
@available(iOS 18.0, *)
186186
extension RichContentView {
187187

188188
public func configuration(_ config: RenderConfiguration) -> Self {

V2er/Sources/RichView/Views/RichView+Preview.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
@available(iOS 15.0, *)
10+
@available(iOS 18.0, *)
1111
struct RichView_Previews: PreviewProvider {
1212

1313
static var previews: some View {
@@ -120,7 +120,7 @@ struct RichView_Previews: PreviewProvider {
120120

121121
// MARK: - Interactive Preview
122122

123-
@available(iOS 15.0, *)
123+
@available(iOS 18.0, *)
124124
struct RichViewInteractivePreview: View {
125125
@State private var htmlInput = """
126126
<h2>Interactive RichView Preview</h2>
@@ -191,7 +191,7 @@ struct RichViewInteractivePreview: View {
191191
}
192192
}
193193

194-
@available(iOS 15.0, *)
194+
@available(iOS 18.0, *)
195195
struct RichViewPlayground: View {
196196
var body: some View {
197197
NavigationView {
@@ -200,7 +200,7 @@ struct RichViewPlayground: View {
200200
}
201201
}
202202

203-
@available(iOS 15.0, *)
203+
@available(iOS 18.0, *)
204204
struct RichViewPlayground_Previews: PreviewProvider {
205205
static var previews: some View {
206206
RichViewPlayground()

0 commit comments

Comments
 (0)