Skip to content

Commit 2390cbe

Browse files
authored
Add visionOS support (#499)
1 parent 0af53c9 commit 2390cbe

File tree

79 files changed

+312
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+312
-263
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@
106106
);
107107
/Localized/Main.storyboard = (
108108
ios,
109+
xros,
109110
);
110111
SceneDelegate.swift = (
111112
ios,
113+
xros,
112114
);
113115
};
114116
target = 27D49DF72BA604FB00F6E2E2 /* HostingExample */;
@@ -530,9 +532,10 @@
530532
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
531533
PRODUCT_NAME = "$(TARGET_NAME)";
532534
SDKROOT = auto;
533-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
535+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
536+
SUPPORTS_MACCATALYST = NO;
534537
SWIFT_EMIT_LOC_STRINGS = YES;
535-
TARGETED_DEVICE_FAMILY = "1,2";
538+
TARGETED_DEVICE_FAMILY = "1,2,7";
536539
};
537540
name = OpenSwiftUIDebug;
538541
};
@@ -559,12 +562,13 @@
559562
PRODUCT_NAME = "$(TARGET_NAME)";
560563
REGISTER_APP_GROUPS = NO;
561564
SDKROOT = auto;
562-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
565+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
563566
SUPPORTS_MACCATALYST = NO;
564567
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
565568
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
566569
SWIFT_EMIT_LOC_STRINGS = YES;
567-
TARGETED_DEVICE_FAMILY = "1,2";
570+
TARGETED_DEVICE_FAMILY = "1,2,7";
571+
XROS_DEPLOYMENT_TARGET = 2.0;
568572
};
569573
name = OpenSwiftUIDebug;
570574
};
@@ -633,10 +637,10 @@
633637
PRODUCT_NAME = "$(TARGET_NAME)";
634638
REGISTER_APP_GROUPS = YES;
635639
SDKROOT = auto;
636-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
640+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
637641
SUPPORTS_MACCATALYST = NO;
638642
SWIFT_EMIT_LOC_STRINGS = YES;
639-
TARGETED_DEVICE_FAMILY = "1,2";
643+
TARGETED_DEVICE_FAMILY = "1,2,7";
640644
};
641645
name = SwiftUIDebug;
642646
};
@@ -702,11 +706,11 @@
702706
PRODUCT_NAME = "$(TARGET_NAME)";
703707
REGISTER_APP_GROUPS = YES;
704708
SDKROOT = auto;
705-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
709+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
706710
SUPPORTS_MACCATALYST = NO;
707711
SWIFT_COMPILATION_MODE = wholemodule;
708712
SWIFT_EMIT_LOC_STRINGS = YES;
709-
TARGETED_DEVICE_FAMILY = "1,2";
713+
TARGETED_DEVICE_FAMILY = "1,2,7";
710714
};
711715
name = SwiftUIRelease;
712716
};
@@ -772,11 +776,11 @@
772776
PRODUCT_NAME = "$(TARGET_NAME)";
773777
REGISTER_APP_GROUPS = YES;
774778
SDKROOT = auto;
775-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
779+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
776780
SUPPORTS_MACCATALYST = NO;
777781
SWIFT_COMPILATION_MODE = wholemodule;
778782
SWIFT_EMIT_LOC_STRINGS = YES;
779-
TARGETED_DEVICE_FAMILY = "1,2";
783+
TARGETED_DEVICE_FAMILY = "1,2,7";
780784
};
781785
name = OpenSwiftUIDebug;
782786
};
@@ -842,11 +846,11 @@
842846
PRODUCT_NAME = "$(TARGET_NAME)";
843847
REGISTER_APP_GROUPS = YES;
844848
SDKROOT = auto;
845-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
849+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
846850
SUPPORTS_MACCATALYST = NO;
847851
SWIFT_COMPILATION_MODE = wholemodule;
848852
SWIFT_EMIT_LOC_STRINGS = YES;
849-
TARGETED_DEVICE_FAMILY = "1,2";
853+
TARGETED_DEVICE_FAMILY = "1,2,7";
850854
};
851855
name = OpenSwiftUIRelease;
852856
};
@@ -935,9 +939,10 @@
935939
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
936940
PRODUCT_NAME = "$(TARGET_NAME)";
937941
SDKROOT = auto;
938-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
942+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
943+
SUPPORTS_MACCATALYST = NO;
939944
SWIFT_EMIT_LOC_STRINGS = YES;
940-
TARGETED_DEVICE_FAMILY = "1,2";
945+
TARGETED_DEVICE_FAMILY = "1,2,7";
941946
};
942947
name = SwiftUIRelease;
943948
};
@@ -964,12 +969,13 @@
964969
PRODUCT_NAME = "$(TARGET_NAME)";
965970
REGISTER_APP_GROUPS = NO;
966971
SDKROOT = auto;
967-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
972+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
968973
SUPPORTS_MACCATALYST = NO;
969974
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
970975
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
971976
SWIFT_EMIT_LOC_STRINGS = YES;
972-
TARGETED_DEVICE_FAMILY = "1,2";
977+
TARGETED_DEVICE_FAMILY = "1,2,7";
978+
XROS_DEPLOYMENT_TARGET = 2.0;
973979
};
974980
name = SwiftUIRelease;
975981
};
@@ -1058,9 +1064,10 @@
10581064
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
10591065
PRODUCT_NAME = "$(TARGET_NAME)";
10601066
SDKROOT = auto;
1061-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1067+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
1068+
SUPPORTS_MACCATALYST = NO;
10621069
SWIFT_EMIT_LOC_STRINGS = YES;
1063-
TARGETED_DEVICE_FAMILY = "1,2";
1070+
TARGETED_DEVICE_FAMILY = "1,2,7";
10641071
};
10651072
name = OpenSwiftUIRelease;
10661073
};
@@ -1087,12 +1094,13 @@
10871094
PRODUCT_NAME = "$(TARGET_NAME)";
10881095
REGISTER_APP_GROUPS = NO;
10891096
SDKROOT = auto;
1090-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1097+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
10911098
SUPPORTS_MACCATALYST = NO;
10921099
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
10931100
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
10941101
SWIFT_EMIT_LOC_STRINGS = YES;
1095-
TARGETED_DEVICE_FAMILY = "1,2";
1102+
TARGETED_DEVICE_FAMILY = "1,2,7";
1103+
XROS_DEPLOYMENT_TARGET = 2.0;
10961104
};
10971105
name = OpenSwiftUIRelease;
10981106
};
@@ -1112,10 +1120,10 @@
11121120
PRODUCT_BUNDLE_IDENTIFIER = org.OpenSwiftUI.OpenSwiftUIUITests;
11131121
PRODUCT_NAME = "$(TARGET_NAME)";
11141122
SDKROOT = auto;
1115-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1123+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
11161124
SUPPORTS_MACCATALYST = NO;
11171125
SWIFT_EMIT_LOC_STRINGS = NO;
1118-
TARGETED_DEVICE_FAMILY = "1,2";
1126+
TARGETED_DEVICE_FAMILY = "1,2,7";
11191127
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
11201128
};
11211129
name = SwiftUIDebug;
@@ -1134,10 +1142,10 @@
11341142
PRODUCT_BUNDLE_IDENTIFIER = org.OpenSwiftUI.OpenSwiftUIUITests;
11351143
PRODUCT_NAME = "$(TARGET_NAME)";
11361144
SDKROOT = auto;
1137-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1145+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
11381146
SUPPORTS_MACCATALYST = NO;
11391147
SWIFT_EMIT_LOC_STRINGS = NO;
1140-
TARGETED_DEVICE_FAMILY = "1,2";
1148+
TARGETED_DEVICE_FAMILY = "1,2,7";
11411149
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
11421150
};
11431151
name = SwiftUIRelease;
@@ -1156,10 +1164,10 @@
11561164
PRODUCT_BUNDLE_IDENTIFIER = org.OpenSwiftUI.OpenSwiftUIUITests;
11571165
PRODUCT_NAME = "$(TARGET_NAME)";
11581166
SDKROOT = auto;
1159-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1167+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
11601168
SUPPORTS_MACCATALYST = NO;
11611169
SWIFT_EMIT_LOC_STRINGS = NO;
1162-
TARGETED_DEVICE_FAMILY = "1,2";
1170+
TARGETED_DEVICE_FAMILY = "1,2,7";
11631171
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
11641172
};
11651173
name = OpenSwiftUIDebug;
@@ -1178,10 +1186,10 @@
11781186
PRODUCT_BUNDLE_IDENTIFIER = org.OpenSwiftUI.OpenSwiftUIUITests;
11791187
PRODUCT_NAME = "$(TARGET_NAME)";
11801188
SDKROOT = auto;
1181-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1189+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
11821190
SUPPORTS_MACCATALYST = NO;
11831191
SWIFT_EMIT_LOC_STRINGS = NO;
1184-
TARGETED_DEVICE_FAMILY = "1,2";
1192+
TARGETED_DEVICE_FAMILY = "1,2,7";
11851193
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestingHost.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/TestingHost";
11861194
};
11871195
name = OpenSwiftUIRelease;
@@ -1271,9 +1279,10 @@
12711279
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
12721280
PRODUCT_NAME = "$(TARGET_NAME)";
12731281
SDKROOT = auto;
1274-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1282+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
1283+
SUPPORTS_MACCATALYST = NO;
12751284
SWIFT_EMIT_LOC_STRINGS = YES;
1276-
TARGETED_DEVICE_FAMILY = "1,2";
1285+
TARGETED_DEVICE_FAMILY = "1,2,7";
12771286
};
12781287
name = SwiftUIDebug;
12791288
};
@@ -1300,12 +1309,13 @@
13001309
PRODUCT_NAME = "$(TARGET_NAME)";
13011310
REGISTER_APP_GROUPS = NO;
13021311
SDKROOT = auto;
1303-
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1312+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
13041313
SUPPORTS_MACCATALYST = NO;
13051314
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
13061315
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
13071316
SWIFT_EMIT_LOC_STRINGS = YES;
1308-
TARGETED_DEVICE_FAMILY = "1,2";
1317+
TARGETED_DEVICE_FAMILY = "1,2,7";
1318+
XROS_DEPLOYMENT_TARGET = 2.0;
13091319
};
13101320
name = SwiftUIDebug;
13111321
};

Example/Example/BenchmarkApp.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import OpenSwiftUI
1212
import SwiftUI
1313
#endif
1414

15-
#if os(iOS)
15+
#if os(iOS) || os(visionOS)
1616
import UIKit
1717
#endif
1818

@@ -24,7 +24,7 @@ struct BenchmarkApp {
2424
])
2525
}
2626
}
27-
#if os(iOS)
27+
#if os(iOS) || os(visionOS)
2828
extension UIHostingController: _Test where Content == AnyView {}
2929
extension UIHostingController: _ViewTest where Content == AnyView {
3030
public func initRootView() -> AnyView {
@@ -46,7 +46,7 @@ struct PerformanceTest: _PerformanceTest {
4646
}
4747

4848
func runTest(host: _BenchmarkHost, options: [AnyHashable : Any]) {
49-
#if os(iOS)
49+
#if os(iOS) || os(visionOS)
5050
let test = _makeUIHostingController(view) as! UIHostingController<AnyView>
5151
test.setUpTest()
5252
test.render()

Example/HostingExample/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Kyle on 2024/3/17.
66
//
77

8-
#if os(iOS)
8+
#if os(iOS) || os(visionOS)
99

1010
import UIKit
1111

Example/HostingExample/SceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Kyle on 2024/3/17.
66
//
77

8-
#if os(iOS)
8+
#if os(iOS) || os(visionOS)
99

1010
import UIKit
1111

Example/HostingExample/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import OpenSwiftUI
1111
import SwiftUI
1212
#endif
1313

14-
#if os(iOS)
14+
#if os(iOS) || os(visionOS)
1515
import UIKit
1616
#elseif os(macOS)
1717
import AppKit
1818
#endif
1919

20-
#if os(iOS)
20+
#if os(iOS) || os(visionOS)
2121
class ViewController: UINavigationController {
2222
override func viewDidAppear(_ animated: Bool) {
2323
pushViewController(EntryViewController(), animated: false)

Example/OpenSwiftUIUITests/Integration/Representable/PlatformViewControllerRepresentableUITests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Testing
66
import SnapshotTesting
77

8-
#if os(iOS)
8+
#if os(iOS) || os(visionOS)
99
import UIKit
1010
typealias PlatformViewControllerRepresentable = UIViewControllerRepresentable
1111
#elseif os(macOS)
@@ -19,7 +19,7 @@ struct PlatformViewControllerRepresentableUITests {
1919
@Test
2020
func plainColorView() {
2121
struct PlainColorView: PlatformViewControllerRepresentable {
22-
#if os(iOS)
22+
#if os(iOS) || os(visionOS)
2323
func makeUIViewController(context: Context) -> some UIViewController {
2424
let vc = UIViewController()
2525
vc.view.backgroundColor = .red

Example/OpenSwiftUIUITests/Integration/Representable/PlatformViewRepresentableUITests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Testing
66
import SnapshotTesting
77

8-
#if os(iOS)
8+
#if os(iOS) || os(visionOS)
99
import UIKit
1010
typealias PlatformViewRepresentable = UIViewRepresentable
1111
#elseif os(macOS)
@@ -19,7 +19,7 @@ struct PlatformViewRepresentableUITests {
1919
@Test
2020
func plainColorView() {
2121
struct PlainColorView: PlatformViewRepresentable {
22-
#if os(iOS)
22+
#if os(iOS) || os(visionOS)
2323
func makeUIView(context: Context) -> some UIView {
2424
let v = UIView()
2525
v.backgroundColor = .red

Example/SharedExample/Extension/Color+Platform.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import OpenSwiftUI
1111
import SwiftUI
1212
#endif
1313

14-
#if os(iOS)
14+
#if os(iOS) || os(visionOS)
1515
import UIKit
1616
typealias PlatformColor = UIColor
1717
#elseif os(macOS)
@@ -21,7 +21,7 @@ typealias PlatformColor = NSColor
2121

2222
extension Color {
2323
init(platformColor: PlatformColor) {
24-
#if os(iOS)
24+
#if os(iOS) || os(visionOS)
2525
self.init(uiColor: platformColor)
2626
#elseif os(macOS)
2727
self.init(nsColor: platformColor)

Example/SharedExample/Integration/Representable/ColorRepresentableExample.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import OpenSwiftUI
88
import SwiftUI
99
#endif
1010

11-
#if os(iOS)
11+
#if os(iOS) || os(visionOS)
1212
import UIKit
1313
typealias PlatformViewRepresentable = UIViewRepresentable
1414
typealias PlatformViewControllerRepresentable = UIViewControllerRepresentable
@@ -19,7 +19,7 @@ typealias PlatformViewControllerRepresentable = NSViewControllerRepresentable
1919
#endif
2020

2121
struct ColorViewRepresentableExample: PlatformViewRepresentable {
22-
#if os(iOS)
22+
#if os(iOS) || os(visionOS)
2323
func makeUIView(context: Context) -> some UIView {
2424
let v = UIView()
2525
v.backgroundColor = .red
@@ -40,7 +40,7 @@ struct ColorViewRepresentableExample: PlatformViewRepresentable {
4040
}
4141

4242
struct ColorViewControllerRepresentableExample: PlatformViewControllerRepresentable {
43-
#if os(iOS)
43+
#if os(iOS) || os(visionOS)
4444
func makeUIViewController(context: Context) -> some UIViewController {
4545
let vc = UIViewController()
4646
vc.view.backgroundColor = .red

0 commit comments

Comments
 (0)