Skip to content

Commit d0ef352

Browse files
committed
add ios support
1 parent 1de02e4 commit d0ef352

8 files changed

Lines changed: 27 additions & 3 deletions

File tree

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "SwiftUIHidden",
8-
platforms: [.macOS(.v12)],
8+
platforms: [.macOS(.v12), .iOS(.v15)],
99
products: [
1010
.library(
1111
name: "SwiftUIHidden",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## SwiftUI-HiddenAPI
22

33
This package allows you to use various hidden SwiftUI features.
4+
Compatible with macOS 12.0+, iOS 15.0+
45

56
### Why is it an xcframework?
67
This exposes functions in SwiftUI for the hidden features that are not in the swiftinterface files.

Sources/SwiftUIHidden/App+open.swift

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

1010
public enum AppActions {
11+
#if os(macOS)
1112
/// Open SwiftUI Settings.
1213
public static func openSettings() {
1314
if #available(macOS 14.0, *) {
@@ -18,6 +19,7 @@ public enum AppActions {
1819
NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
1920
}
2021
}
22+
#endif
2123

2224
/// Open a SwiftUI Window.
2325
@available(macOS 13.0, *)
@@ -39,6 +41,7 @@ public enum AppActions {
3941

4042
/// Open a SwiftUI Document.
4143
@available(macOS 13.0, *)
44+
@available(iOS, unavailable)
4245
public static func openDocument(at url: URL) async throws {
4346
try await EnvironmentValues().openDocument(at: url)
4447
}

Sources/SwiftUIHidden/Environment+extensions.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ public extension EnvironmentValues {
1313
}
1414
}
1515

16+
@available(iOS, unavailable)
1617
public struct WithCurrentWindowAction {
1718
let action: SwiftUI.WithCurrentWindowAction
1819

19-
public func callAsFunction(_ window: (NSWindow?) -> Void) {
20+
#if os(macOS)
21+
public func callAsFunction(_ window: (UIWindow?) -> Void) {
2022
action(window)
2123
}
24+
#endif
2225
}
2326

2427
public struct HiddenEnvironmentValues {
2528
let environment: EnvironmentValues
2629

30+
#if os(macOS)
2731
/// Open SwiftUI Settings.
2832
public var openSettings: () -> Void {
2933
if #available(macOS 14.0, *) {
@@ -38,8 +42,10 @@ public struct HiddenEnvironmentValues {
3842
}
3943
}
4044
}
45+
#endif
4146

4247
/// Access the current window.
48+
@available(iOS, unavailable)
4349
public var withCurrentWindow: WithCurrentWindowAction {
4450
.init(action: environment.withCurrentWindow)
4551
}

Sources/SwiftUIHidden/Form+init.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SwiftUI
1010
public extension Form {
1111
/// Add a footer to a form.
1212
@available(macOS 13.0, *)
13+
@available(iOS, unavailable)
1314
static func withFooter<C: View, F: View>(@ViewBuilder content: () -> C, @ViewBuilder footer: () -> F) -> some View {
1415
Form<FormFooterContent<C, F>>(content: content, footer: footer)
1516
}

Sources/SwiftUIHidden/Scene+extensions.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@ public struct HiddenSceneModifier<S: Scene> {
1717
let content: S
1818

1919
/// Customize the window background. Use `.clear` for a transparent window, use `.*Material` for a blurred background
20+
@available(iOS, unavailable)
2021
public func windowBackground(_ shape: some ShapeStyle) -> some Scene {
2122
content.windowBackground(shape)
2223
}
2324

2425
/// Disable automatic window opening behavior..
2526
/// For example, when set to `.hidden`, launching the app or clicking the app icon won't create a new window of that scene.
2627
/// Note that previously created windows may reappear.
28+
@available(iOS, unavailable)
2729
public func defaultVisibility(_ visibility: Visibility) -> some Scene {
2830
content.defaultVisibility(visibility)
2931
}
3032

3133
/// Determine if a window should be closed when the user tries to close the window.
3234
/// Returning `true` will close the window, `false` will keep the window open.
35+
@available(iOS, unavailable)
3336
public func windowShouldClose(_ perform: @escaping () -> Bool) -> some Scene {
3437
content.windowShouldClose(perform)
3538
}

Sources/SwiftUIHidden/View+extensions.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public struct HiddenViewModifier<Content: View> {
4848

4949
/// Change the toolbar behavior when the window is fullscreen.
5050
/// `.showsWithWindow` is the default behavior. `.showsWithMenuBar` will hide the toolbar when fullscreen.
51+
@available(iOS, unavailable)
5152
public func fullScreenToolbarBehavior(_ behavior: FullScreenToolbarBehavior) -> some View {
5253
content.fullScreenToolbarBehavior(behavior.toOriginal)
5354
}
@@ -78,6 +79,7 @@ public struct HiddenViewModifier<Content: View> {
7879

7980
/// Set the indentation level of a Form row.
8081
@available(macOS 13.0, *)
82+
@available(iOS, unavailable)
8183
public func formRowIndentationLevel(_ level: Int?) -> some View {
8284
content.formRowIndentationLevel(level)
8385
}
@@ -103,37 +105,43 @@ public struct HiddenViewModifier<Content: View> {
103105
/// Add a trailing info icon to a Form row.
104106
/// As an example, see system bluetooth settings.
105107
@available(macOS 13.0, *)
108+
@available(iOS, unavailable)
106109
public func formInfoAction(action: @escaping () -> Void) -> some View {
107110
content.formInfoAction(action: action)
108111
}
109112

110113
/// Change the visibility of the trailing info icon in a Form row.
111114
@available(macOS 13.0, *)
115+
@available(iOS, unavailable)
112116
public func formRowInfoVisibility(_ visibility: Visibility) -> some View {
113117
content.formRowInfoVisibility(visibility)
114118
}
115119

116120
/// Add a trailing Form row view, which becomes visible when hovered over the row.
117121
/// As an example, see system wifi settings.
118122
@available(macOS 13.0, *)
123+
@available(iOS, unavailable)
119124
public func formAccessory(@ViewBuilder accessories: () -> some View) -> some View {
120125
content.formAccessory(accessories: accessories)
121126
}
122127

123128
/// Change the visibility of the trailing Form row view.
124129
@available(macOS 13.0, *)
130+
@available(iOS, unavailable)
125131
public func formAccessoryVisibility(_ visibility: Visibility) -> some View {
126132
content.formAccessoryVisibility(visibility)
127133
}
128134

129-
/// Add a bottom row to a Form.
135+
/// Add a bottom row to a Table.
130136
@available(macOS 13.0, *)
137+
@available(iOS, unavailable)
131138
public func bottomBar(@ViewBuilder content: () -> some View) -> some View {
132139
self.content.bottomBar(content: content)
133140
}
134141

135142
/// Add a sticky footer to List or Table. The List or Table needs to be wrapped in a Form with style `grouped`.
136143
@available(macOS 13.0, *)
144+
@available(iOS, unavailable)
137145
public func accessoryBar(@ViewBuilder content: () -> some View) -> some View {
138146
self.content.accessoryBar(content: content)
139147
}

Sources/SwiftUIHidden/WindowStyle+hidden.swift

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

88
import SwiftUI
99

10+
@available(iOS, unavailable)
1011
public struct HiddenWindowStyle: WindowStyle {
1112
public typealias _Body = Never
1213

@@ -15,6 +16,7 @@ public struct HiddenWindowStyle: WindowStyle {
1516
}
1617
}
1718

19+
@available(iOS, unavailable)
1820
public extension WindowStyle where Self == HiddenWindowStyle {
1921
static var hidden: HiddenWindowStyle {
2022
.init()

0 commit comments

Comments
 (0)