Răsfoiți Sursa

Compile for visionOS (#777)

Alex Türk 2 ani în urmă
părinte
comite
4d52cc3768
40 a modificat fișierele cu 69 adăugiri și 63 ștergeri
  1. 1 1
      Example-iOS/AppDelegate.swift
  2. 9 3
      Example-iOS/Example-iOS.xcodeproj/project.pbxproj
  3. 3 3
      Sources/Constraint.swift
  4. 2 2
      Sources/ConstraintAttributes.swift
  5. 1 1
      Sources/ConstraintConfig.swift
  6. 5 5
      Sources/ConstraintConstantTarget.swift
  7. 1 1
      Sources/ConstraintDSL.swift
  8. 1 1
      Sources/ConstraintDescription.swift
  9. 2 2
      Sources/ConstraintDirectionalInsetTarget.swift
  10. 2 2
      Sources/ConstraintDirectionalInsets.swift
  11. 1 1
      Sources/ConstraintInsetTarget.swift
  12. 2 2
      Sources/ConstraintInsets.swift
  13. 1 1
      Sources/ConstraintItem.swift
  14. 1 1
      Sources/ConstraintLayoutGuide+Extensions.swift
  15. 2 2
      Sources/ConstraintLayoutGuide.swift
  16. 1 1
      Sources/ConstraintLayoutGuideDSL.swift
  17. 2 2
      Sources/ConstraintLayoutSupport.swift
  18. 1 1
      Sources/ConstraintLayoutSupportDSL.swift
  19. 1 1
      Sources/ConstraintMaker.swift
  20. 2 2
      Sources/ConstraintMakerEditable.swift
  21. 1 1
      Sources/ConstraintMakerExtendable.swift
  22. 1 1
      Sources/ConstraintMakerFinalizable.swift
  23. 1 1
      Sources/ConstraintMakerPrioritizable.swift
  24. 1 1
      Sources/ConstraintMakerRelatable+Extensions.swift
  25. 1 1
      Sources/ConstraintMakerRelatable.swift
  26. 1 1
      Sources/ConstraintMultiplierTarget.swift
  27. 1 1
      Sources/ConstraintOffsetTarget.swift
  28. 1 1
      Sources/ConstraintPriority.swift
  29. 2 2
      Sources/ConstraintPriorityTarget.swift
  30. 2 2
      Sources/ConstraintRelatableTarget.swift
  31. 1 1
      Sources/ConstraintRelation.swift
  32. 1 1
      Sources/ConstraintView+Extensions.swift
  33. 2 2
      Sources/ConstraintView.swift
  34. 1 1
      Sources/ConstraintViewDSL.swift
  35. 2 2
      Sources/Debugging.swift
  36. 1 1
      Sources/LayoutConstraint.swift
  37. 1 1
      Sources/LayoutConstraintItem.swift
  38. 1 1
      Sources/Typealiases.swift
  39. 1 1
      Sources/UILayoutSupport+Extensions.swift
  40. 5 5
      Tests/SnapKitTests/Tests.swift

+ 1 - 1
Example-iOS/AppDelegate.swift

@@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 
-        self.window = UIWindow(frame: UIScreen.main.bounds)
+        self.window = UIWindow()
 
         let listViewController:ListViewController = ListViewController()
         let navigationController:UINavigationController = UINavigationController(rootViewController: listViewController);

+ 9 - 3
Example-iOS/Example-iOS.xcodeproj/project.pbxproj

@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 52;
+	objectVersion = 54;
 	objects = {
 
 /* Begin PBXBuildFile section */
@@ -310,8 +310,11 @@
 				);
 				PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
+				SUPPORTS_MACCATALYST = NO;
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = "1,2";
+				TARGETED_DEVICE_FAMILY = "1,2,7";
 			};
 			name = Debug;
 		};
@@ -333,8 +336,11 @@
 				);
 				PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
+				SUPPORTS_MACCATALYST = NO;
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = "1,2";
+				TARGETED_DEVICE_FAMILY = "1,2,7";
 			};
 			name = Release;
 		};

+ 3 - 3
Sources/Constraint.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -101,7 +101,7 @@ public final class Constraint {
         for layoutFromAttribute in layoutFromAttributes {
             // get layout to attribute
             let layoutToAttribute: LayoutAttribute
-            #if os(iOS) || os(tvOS)
+            #if canImport(UIKit)
                 if layoutToAttributes.count > 0 {
                     if self.from.attributes == .edges && self.to.attributes == .margins {
                         switch layoutFromAttribute {
@@ -245,7 +245,7 @@ public final class Constraint {
         return self
     }
 
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
     @discardableResult
     @available(iOS 11.0, tvOS 11.0, *)
     public func update(inset: ConstraintDirectionalInsetTarget) -> Constraint {

+ 2 - 2
Sources/ConstraintAttributes.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -152,7 +152,7 @@ internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral {
             attrs.append(.lastBaseline)
         }
         
-        #if os(iOS) || os(tvOS)
+        #if canImport(UIKit)
             if (self.contains(ConstraintAttributes.firstBaseline)) {
                 attrs.append(.firstBaseline)
             }

+ 1 - 1
Sources/ConstraintConfig.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
     public typealias ConstraintInterfaceLayoutDirection = UIUserInterfaceLayoutDirection
 #else

+ 5 - 5
Sources/ConstraintConstantTarget.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -40,7 +40,7 @@ extension CGSize: ConstraintConstantTarget {
 extension ConstraintInsets: ConstraintConstantTarget {
 }
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
 @available(iOS 11.0, tvOS 11.0, *)
 extension ConstraintDirectionalInsets: ConstraintConstantTarget {
 }
@@ -80,7 +80,7 @@ extension ConstraintConstantTarget {
         }
         
         if let value = self as? CGPoint {
-            #if os(iOS) || os(tvOS)
+            #if canImport(UIKit)
                 switch layoutAttribute {
                 case .left, .right, .leading, .trailing, .centerX, .leftMargin, .rightMargin, .leadingMargin, .trailingMargin, .centerXWithinMargins:
                     return value.x
@@ -110,7 +110,7 @@ extension ConstraintConstantTarget {
         }
         
         if let value = self as? ConstraintInsets {
-            #if os(iOS) || os(tvOS)
+            #if canImport(UIKit)
                 switch layoutAttribute {
                 case .left, .leftMargin:
                     return value.left
@@ -171,7 +171,7 @@ extension ConstraintConstantTarget {
             #endif
         }
         
-        #if os(iOS) || os(tvOS)
+        #if canImport(UIKit)
             if #available(iOS 11.0, tvOS 11.0, *), let value = self as? ConstraintDirectionalInsets {
                 switch layoutAttribute {
                 case .left, .leftMargin:

+ 1 - 1
Sources/ConstraintDSL.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintDescription.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/ConstraintDirectionalInsetTarget.swift

@@ -21,13 +21,13 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
 import UIKit
 #else
 import AppKit
 #endif
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
 public protocol ConstraintDirectionalInsetTarget: ConstraintConstantTarget {
 }
 

+ 2 - 2
Sources/ConstraintDirectionalInsets.swift

@@ -21,14 +21,14 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
 #endif
 
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     @available(iOS 11.0, tvOS 11.0, *)
     public typealias ConstraintDirectionalInsets = NSDirectionalEdgeInsets
 #endif

+ 1 - 1
Sources/ConstraintInsetTarget.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/ConstraintInsets.swift

@@ -21,14 +21,14 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
 #endif
 
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     public typealias ConstraintInsets = UIEdgeInsets
 #else
     public typealias ConstraintInsets = NSEdgeInsets

+ 1 - 1
Sources/ConstraintItem.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintLayoutGuide+Extensions.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #endif
     

+ 2 - 2
Sources/ConstraintLayoutGuide.swift

@@ -21,14 +21,14 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
 #endif
 
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     @available(iOS 9.0, *)
     public typealias ConstraintLayoutGuide = UILayoutGuide
 #else

+ 1 - 1
Sources/ConstraintLayoutGuideDSL.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/ConstraintLayoutSupport.swift

@@ -21,14 +21,14 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
 #endif
 
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     @available(iOS 8.0, *)
     public typealias ConstraintLayoutSupport = UILayoutSupport
 #else

+ 1 - 1
Sources/ConstraintLayoutSupportDSL.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintMaker.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/ConstraintMakerEditable.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -53,7 +53,7 @@ public class ConstraintMakerEditable: ConstraintMakerPrioritizable {
         return self
     }
     
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
     @discardableResult
     @available(iOS 11.0, tvOS 11.0, *)
     public func inset(_ amount: ConstraintDirectionalInsetTarget) -> ConstraintMakerEditable {

+ 1 - 1
Sources/ConstraintMakerExtendable.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintMakerFinalizable.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintMakerPrioritizable.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintMakerRelatable+Extensions.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintMakerRelatable.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintMultiplierTarget.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintOffsetTarget.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintPriority.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/ConstraintPriorityTarget.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -74,7 +74,7 @@ extension CGFloat: ConstraintPriorityTarget {
     
 }
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
 extension UILayoutPriority: ConstraintPriorityTarget {
 
     public var constraintPriorityTargetValue: Float {

+ 2 - 2
Sources/ConstraintRelatableTarget.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -55,7 +55,7 @@ extension CGPoint: ConstraintRelatableTarget {
 extension ConstraintInsets: ConstraintRelatableTarget {
 }
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
 @available(iOS 11.0, tvOS 11.0, *)
 extension ConstraintDirectionalInsets: ConstraintRelatableTarget {
 }

+ 1 - 1
Sources/ConstraintRelation.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/ConstraintView+Extensions.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/ConstraintView.swift

@@ -21,14 +21,14 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
 #endif
 
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     public typealias ConstraintView = UIView
 #else
     public typealias ConstraintView = NSView

+ 1 - 1
Sources/ConstraintViewDSL.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 2 - 2
Sources/Debugging.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit
@@ -89,7 +89,7 @@ private func descriptionForRelation(_ relation: LayoutRelation) -> String {
 }
 
 private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String {
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
         switch attribute {
         case .notAnAttribute:       return "notAnAttribute"
         case .top:                  return "top"

+ 1 - 1
Sources/LayoutConstraint.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/LayoutConstraintItem.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #else
     import AppKit

+ 1 - 1
Sources/Typealiases.swift

@@ -23,7 +23,7 @@
 
 import Foundation
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #if swift(>=4.2)
     typealias LayoutRelation = NSLayoutConstraint.Relation

+ 1 - 1
Sources/UILayoutSupport+Extensions.swift

@@ -21,7 +21,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
     import UIKit
 #endif
 

+ 5 - 5
Tests/SnapKitTests/Tests.swift

@@ -1,4 +1,4 @@
-#if os(iOS) || os(tvOS)
+#if canImport(UIKit)
 import UIKit
 typealias View = UIView
 extension View {
@@ -453,7 +453,7 @@ class SnapKitTests: XCTestCase {
         XCTAssertEqual(constraints[3].constant, -25, "Should be -25")
     }
     
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
     @available(iOS 11.0, tvOS 11.0, *)
     func testConstraintDirectionalInsetsAsImpliedEqualToConstraints() {
         let view = View()
@@ -481,7 +481,7 @@ class SnapKitTests: XCTestCase {
     }
     #endif
 
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
     @available(iOS 11.0, tvOS 11.0, *)
     func testConstraintDirectionalInsetsAsConstraintsConstant() {
         let view = View()
@@ -509,7 +509,7 @@ class SnapKitTests: XCTestCase {
     }
     #endif
 
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
     @available(iOS 11.0, tvOS 11.0, *)
     func testConstraintDirectionalInsetsFallBackForNonDirectionalConstraints() {
         let view = View()
@@ -638,7 +638,7 @@ class SnapKitTests: XCTestCase {
         XCTAssert(toAttributes == [.top, .leading, .bottom, .trailing])
     }
     
-    #if os(iOS) || os(tvOS)
+    #if canImport(UIKit)
     func testEdgesToMargins() {
         var fromAttributes = Set<LayoutAttribute>()
         var toAttributes = Set<LayoutAttribute>()