Compile for visionOS (#777)

This commit is contained in:
Alex Türk 2023-10-04 15:30:31 +02:00 committed by GitHub
parent 58320fe805
commit 4d52cc3768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 69 additions and 63 deletions

View File

@ -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);

View File

@ -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;
};

View File

@ -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 {

View File

@ -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)
}

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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 {
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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 {
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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>()