Skip to content

Commit d907b44

Browse files
committed
fixed buld failure for tv and watch os
1 parent 934918d commit d907b44

File tree

10 files changed

+48
-99
lines changed

10 files changed

+48
-99
lines changed

.swiftpm/xcode/xcshareddata/xcschemes/RichEditorSwiftUI.xcscheme

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3030
shouldUseLaunchSchemeArgsEnv = "YES"
3131
shouldAutocreateTestPlan = "YES">
32+
<Testables>
33+
<TestableReference
34+
skipped = "NO">
35+
<BuildableReference
36+
BuildableIdentifier = "primary"
37+
BlueprintIdentifier = "RichEditorSwiftUITests"
38+
BuildableName = "RichEditorSwiftUITests"
39+
BlueprintName = "RichEditorSwiftUITests"
40+
ReferencedContainer = "container:">
41+
</BuildableReference>
42+
</TestableReference>
43+
</Testables>
3244
</TestAction>
3345
<LaunchAction
3446
buildConfiguration = "Debug"

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ The editor offers the following <b>options</b>:
7070
## mac Editor video
7171

7272
<div align="center">
73-
<video src="https://github.com/user-attachments/assets/844d8843-41e9-44c2-8a0c-afedaa55c5cb" />
73+
<video src="https://github.com/user-attachments/assets/844d8843-41e9-44c2-8a0c-afedaa55c5cb" width="90%"/>
7474
</div>
7575

7676
## Editor video
7777
<div align="center">
78-
<video src="https://github.com/user-attachments/assets/f99804fb-8612-4e46-b172-66567d1acf91" />
78+
<video src="https://github.com/user-attachments/assets/f99804fb-8612-4e46-b172-66567d1acf91" width="90%"/>
7979
</div>
8080

8181
## Installation
@@ -88,7 +88,7 @@ Once you have your Swift package set up, adding RichEditorSwiftUI as a dependenc
8888

8989
```swift
9090
dependencies: [
91-
.package(url: "https://github.com/canopas/rich-editor-swiftui.git", .upToNextMajor(from: "1.0.0"))
91+
.package(url: "https://github.com/canopas/rich-editor-swiftui.git", .upToNextMajor(from: "1.1.0"))
9292
]
9393
```
9494

@@ -97,7 +97,7 @@ dependencies: [
9797
[CocoaPods][] is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate RichEditorSwiftUI into your Xcode project using CocoaPods, specify it in your Podfile:
9898

9999
target 'YourAppName' do
100-
pod 'RichEditorSwiftUI', '~> 1.0.0'
100+
pod 'RichEditorSwiftUI', '~> 1.1.0'
101101
end
102102

103103
[CocoaPods]: https://cocoapods.org

RichEditorDemo/RichEditorDemo/ContentView.swift

+8
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,22 @@ struct ContentView: View {
5858
)
5959
#endif
6060
}
61+
#if iOS || macOS
6162
.inspector(isPresented: $isInspectorPresented) {
6263
RichTextFormat.Sidebar(context: state)
6364
#if os(macOS)
6465
.inspectorColumnWidth(min: 200, ideal: 200, max: 315)
6566
#endif
6667
}
68+
#endif
6769
.padding(10)
70+
#if iOS || os(macOS)
6871
.toolbar {
6972
ToolbarItemGroup(placement: .automatic) {
7073
toolBarGroup
7174
}
7275
}
76+
#endif
7377
.background(colorScheme == .dark ? .black : .gray.opacity(0.07))
7478
.navigationTitle("Rich Editor")
7579
.alert("Enter file name", isPresented: getBindingAlert()) {
@@ -80,6 +84,7 @@ struct ContentView: View {
8084
}
8185
.focusedValue(\.richEditorState, state)
8286
.toolbarRole(.automatic)
87+
#if iOS || macOS || os(visionOS)
8388
.richTextFormatSheetConfig(.init(colorPickers: colorPickers))
8489
.richTextFormatSidebarConfig(
8590
.init(
@@ -88,9 +93,11 @@ struct ContentView: View {
8893
)
8994
)
9095
.richTextFormatToolbarConfig(.init(colorPickers: []))
96+
#endif
9197
}
9298
}
9399

100+
#if iOS || os(macOS)
94101
var toolBarGroup: some View {
95102
return Group {
96103
RichTextExportMenu.init(
@@ -125,6 +132,7 @@ struct ContentView: View {
125132
#endif
126133
}
127134
}
135+
#endif
128136

129137
func getBindingAlert() -> Binding<Bool> {
130138
.init(

RichEditorSwiftUI.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Pod::Spec.new do |s|
1111
s.license = { :type => "MIT", :file => "LICENSE.md" }
1212
s.author = { "Jimmy" => "[email protected]" }
1313
s.source = { :git => "https://github.com/canopas/rich-editor-swiftui.git", :tag => s.version.to_s }
14-
s.source_files = "Sources/**/*.swift"
15-
s.social_media_url = 'https://twitter.com/canopassoftware'
14+
s.source_files = "Sources/*.swift"
15+
s.social_media_url = 'https://x.com/canopas_eng'
1616

1717
s.module_name = 'RichEditorSwiftUI'
1818
s.requires_arc = true

Sources/RichEditorSwiftUI/Data/Models/RichAttributes+RichTextAttributes.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ extension RichAttributes {
1717
func toAttributes(font: FontRepresentable? = nil) -> RichTextAttributes {
1818
var attributes: RichTextAttributes = [:]
1919

20+
var defaultFont: FontRepresentable = .standardRichTextFont
21+
#if !os(watchOS)
22+
defaultFont = RichTextView.Theme.standard.font
23+
#endif
2024
// Set the font size and handle headers
21-
var font = font ?? RichTextView.Theme.standard.font
25+
var font = font ?? defaultFont
2226
if let headerType = self.header?.getTextSpanStyle() {
2327
font = font
2428
.updateFontSize(

Sources/RichEditorSwiftUI/UI/Context/RichEditorState.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ public class RichEditorState: ObservableObject {
157157
tempSpans.forEach { span in
158158
str.addAttributes(span.attributes?.toAttributes(font: .standardRichTextFont) ?? [:], range: span.spanRange)
159159
if span.attributes?.color == nil {
160-
str.addAttributes([.foregroundColor: RichTextView.Theme.standard.fontColor], range: span.spanRange)
160+
var color: ColorRepresentable = .clear
161+
#if os(watchOS)
162+
color = .black
163+
#else
164+
color = RichTextView.Theme.standard.fontColor
165+
#endif
166+
str.addAttributes([.foregroundColor: color], range: span.spanRange)
161167
}
162168
}
163169

Sources/RichEditorSwiftUI/UI/Editor/RichEditorState+UITextView.swift

-89
This file was deleted.

Sources/RichEditorSwiftUI/UI/Editor/RichTextSpanStyle.swift

+8
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,18 @@ public enum RichTextSpanStyle: Equatable, CaseIterable, Hashable {
125125
size: .standardRichTextFontSize
126126
) ?? font
127127
} else {
128+
#if os(watchOS)
129+
return CGFloat.standardRichTextFontSize
130+
#else
128131
return RichTextView.Theme.standard.font
132+
#endif
129133
}
130134
case .color:
135+
#if os(watchOS)
136+
return Color.primary
137+
#else
131138
return RichTextView.Theme.standard.fontColor
139+
#endif
132140
case .background:
133141
return ColorRepresentable.white
134142
case .align:

Sources/RichEditorSwiftUI/UI/Extensions/View+BackportSupportExtension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SwiftUI
1010
extension View {
1111
nonisolated public func onChangeBackPort<V>(of value: V, _ action: @escaping (_ newValue: V) -> Void) -> some View where V : Equatable {
1212
Group {
13-
if #available(iOS 17.0, macOS 14.0, *) {
13+
if #available(iOS 17.0, macOS 14.0, watchOS 10.0, *) {
1414
self
1515
//iOS17~
1616
.onChange(of: value) { oldValue, newValue in

Sources/RichEditorSwiftUI/UI/TextViewUI/RichTextView+Config_UIKit.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Divyesh Vekariya on 21/10/24.
66
//
77

8-
#if canImport(UIKit) || os(tvOS) || os(visionOS)
8+
#if iOS || os(tvOS) || os(visionOS)
99
import SwiftUI
1010

1111
public extension RichTextView {

0 commit comments

Comments
 (0)