From 4c69024887cf17df99fa8ed628f32fa1c5ced234 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 12:19:47 +0100 Subject: [PATCH 01/17] add compiler directives for visionOS support --- Sources/Nimble/Adapters/NimbleXCTestHandler.swift | 4 ++-- Sources/Nimble/Matchers/BeginWith.swift | 2 +- Sources/Nimble/Matchers/EndWith.swift | 2 +- Sources/Nimble/Matchers/ThrowAssertion.swift | 2 +- Sources/Nimble/Nimble.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Nimble/Adapters/NimbleXCTestHandler.swift b/Sources/Nimble/Adapters/NimbleXCTestHandler.swift index 697dc8d80..286ae7ea6 100644 --- a/Sources/Nimble/Adapters/NimbleXCTestHandler.swift +++ b/Sources/Nimble/Adapters/NimbleXCTestHandler.swift @@ -45,7 +45,7 @@ class NimbleXCTestUnavailableHandler: AssertionHandler { private var stashed_swift_reportFatalErrorsToDebugger: Bool = false @objc public func testCaseWillStart(_ testCase: XCTestCase) { - #if (os(macOS) || os(iOS)) && !SWIFT_PACKAGE + #if (os(macOS) || os(iOS) || os(visionOS)) && !SWIFT_PACKAGE stashed_swift_reportFatalErrorsToDebugger = _swift_reportFatalErrorsToDebugger _swift_reportFatalErrorsToDebugger = false #endif @@ -56,7 +56,7 @@ class NimbleXCTestUnavailableHandler: AssertionHandler { @objc public func testCaseDidFinish(_ testCase: XCTestCase) { currentTestCase = nil - #if (os(macOS) || os(iOS)) && !SWIFT_PACKAGE + #if (os(macOS) || os(iOS) || os(visionOS)) && !SWIFT_PACKAGE _swift_reportFatalErrorsToDebugger = stashed_swift_reportFatalErrorsToDebugger #endif } diff --git a/Sources/Nimble/Matchers/BeginWith.swift b/Sources/Nimble/Matchers/BeginWith.swift index cc4a58dac..05e1b8231 100644 --- a/Sources/Nimble/Matchers/BeginWith.swift +++ b/Sources/Nimble/Matchers/BeginWith.swift @@ -17,7 +17,7 @@ public func beginWith(_ startingElement: Any) -> Matcher { return Matcher.simple("begin with <\(startingElement)>") { actualExpression in guard let collection = try actualExpression.evaluate() else { return .fail } guard collection.count > 0 else { return .doesNotMatch } - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) let collectionValue = collection.object(at: 0) as AnyObject #else guard let collectionValue = collection.object(at: 0) as? NSObject else { diff --git a/Sources/Nimble/Matchers/EndWith.swift b/Sources/Nimble/Matchers/EndWith.swift index d1fffc42e..0b61da991 100644 --- a/Sources/Nimble/Matchers/EndWith.swift +++ b/Sources/Nimble/Matchers/EndWith.swift @@ -25,7 +25,7 @@ public func endWith(_ endingElement: Any) -> Matcher { guard let collection = try actualExpression.evaluate() else { return .fail } guard collection.count > 0 else { return MatcherStatus(bool: false) } - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) let collectionValue = collection.object(at: collection.count - 1) as AnyObject #else guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else { diff --git a/Sources/Nimble/Matchers/ThrowAssertion.swift b/Sources/Nimble/Matchers/ThrowAssertion.swift index b64a06211..db240e4ee 100644 --- a/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -1,5 +1,5 @@ // swiftlint:disable all -#if canImport(CwlPreconditionTesting) && (os(macOS) || os(iOS)) +#if canImport(CwlPreconditionTesting) && (os(macOS) || os(iOS) || os(visionOS)) import CwlPreconditionTesting #elseif canImport(CwlPosixPreconditionTesting) import CwlPosixPreconditionTesting diff --git a/Sources/Nimble/Nimble.h b/Sources/Nimble/Nimble.h index dc68ded76..1072c2641 100644 --- a/Sources/Nimble/Nimble.h +++ b/Sources/Nimble/Nimble.h @@ -3,7 +3,7 @@ #import #import -#if TARGET_OS_OSX || TARGET_OS_IOS +#if TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_VISION #import #import #endif From 0f901d9dc81a7368f2a854a195b20f60e2edfd97 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 12:20:06 +0100 Subject: [PATCH 02/17] add SPM visionOS support --- Package.resolved | 42 ++++++++++++++++++++---------------------- Package.swift | 9 +++++---- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Package.resolved b/Package.resolved index b429a9226..04a917823 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,25 +1,23 @@ { - "object": { - "pins": [ - { - "package": "CwlCatchException", - "repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", - "state": { - "branch": null, - "revision": "f809deb30dc5c9d9b78c872e553261a61177721a", - "version": "2.0.0" - } - }, - { - "package": "CwlPreconditionTesting", - "repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", - "state": { - "branch": null, - "revision": "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688", - "version": "2.1.0" - } + "pins" : [ + { + "identity" : "cwlcatchexception", + "kind" : "remoteSourceControl", + "location" : "https://github.com/mattgallagher/CwlCatchException.git", + "state" : { + "revision" : "3b123999de19bf04905bc1dfdb76f817b0f2cc00", + "version" : "2.1.2" } - ] - }, - "version": 1 + }, + { + "identity" : "cwlpreconditiontesting", + "kind" : "remoteSourceControl", + "location" : "https://github.com/bitmovin-engineering/CwlPreconditionTesting.git", + "state" : { + "branch" : "bitmovin/feature/visionos-support", + "revision" : "204426ebff46789adc32d4fc49b35cdb7da6f218" + } + } + ], + "version" : 2 } diff --git a/Package.swift b/Package.swift index de40d97b5..0a2eebdd4 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,10 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.9 import PackageDescription let package = Package( name: "Nimble", platforms: [ - .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6) + .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1) ], products: [ .library( @@ -19,7 +19,8 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .upToNextMajor(from: "2.1.0")), + // TODO: use official repo once merged + .package(url: "https://github.com/bitmovin-engineering/CwlPreconditionTesting.git", branch: "bitmovin/feature/visionos-support"), ], targets: { var testHelperDependencies: [PackageDescription.Target.Dependency] = ["Nimble"] @@ -31,7 +32,7 @@ let package = Package( name: "Nimble", dependencies: [ .product(name: "CwlPreconditionTesting", package: "CwlPreconditionTesting", - condition: .when(platforms: [.macOS, .iOS, .macCatalyst])), + condition: .when(platforms: [.macOS, .iOS, .macCatalyst, .visionOS])), .product(name: "CwlPosixPreconditionTesting", package: "CwlPreconditionTesting", condition: .when(platforms: [.tvOS, .watchOS])) ], From d3eebfd0d98865ab25beb618ecf93c906bf7b609 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 12:20:15 +0100 Subject: [PATCH 03/17] add CocoaPods visionOS support --- Nimble.podspec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Nimble.podspec b/Nimble.podspec index 3bc2a4972..8e8f8c920 100644 --- a/Nimble.podspec +++ b/Nimble.podspec @@ -12,6 +12,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = "10.15" s.tvos.deployment_target = "13.0" s.watchos.deployment_target = "7.0" + s.visionos.deployment_target = "1.0" s.source = { :git => "https://github.com/Quick/Nimble.git", :tag => "v#{s.version}" } @@ -29,6 +30,9 @@ Pod::Spec.new do |s| s.ios.exclude_files = [ "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift", ] + s.visionos.exclude_files = [ + "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift", + ] s.tvos.exclude_files = [ "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h", "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift", From 8663e7286053a03f8e09614d8dd2450673c2cff2 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 13:21:10 +0100 Subject: [PATCH 04/17] update Carthage dependencies --- Cartfile.private | 2 +- Cartfile.resolved | 4 +- .../Checkouts/CwlCatchException/Package.swift | 2 +- .../Checkouts/CwlCatchException/README.md | 19 ++++++- .../CwlCatchException/CwlCatchException.swift | 43 ++++++++++++-- .../CwlCatchException.m | 4 +- .../include/CwlCatchException.h | 2 +- .../CwlPreconditionTesting/Package.swift | 6 +- .../CwlMachBadInstructionHandler.m | 2 +- .../include/CwlMachBadInstructionHandler.h | 2 +- .../mach_excServer.c | 2 +- .../mach_excServer.h | 2 +- .../CwlBadInstructionException.swift | 4 +- .../CwlCatchBadInstruction.swift | 57 +++---------------- .../CwlDarwinDefinitions.swift | 2 +- 15 files changed, 81 insertions(+), 72 deletions(-) diff --git a/Cartfile.private b/Cartfile.private index f1d58e1d4..a9f3a0a80 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ github "mattgallagher/CwlCatchException" ~> 2.0 -github "mattgallagher/CwlPreconditionTesting" ~> 2.1 +github "bitmovin-engineering/CwlPreconditionTesting" "bitmovin/main" diff --git a/Cartfile.resolved b/Cartfile.resolved index 098e53fc3..da40ae26d 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "mattgallagher/CwlCatchException" "2.0.0" -github "mattgallagher/CwlPreconditionTesting" "2.1.0" +github "bitmovin-engineering/CwlPreconditionTesting" "1a3d129278e6e1b0622fdc965fe4d0f9b6cea3e3" +github "mattgallagher/CwlCatchException" "2.1.2" diff --git a/Carthage/Checkouts/CwlCatchException/Package.swift b/Carthage/Checkouts/CwlCatchException/Package.swift index acee3952a..c6767a5de 100644 --- a/Carthage/Checkouts/CwlCatchException/Package.swift +++ b/Carthage/Checkouts/CwlCatchException/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.5 import PackageDescription let package = Package( diff --git a/Carthage/Checkouts/CwlCatchException/README.md b/Carthage/Checkouts/CwlCatchException/README.md index 1e8a6ec56..ef38cabff 100644 --- a/Carthage/Checkouts/CwlCatchException/README.md +++ b/Carthage/Checkouts/CwlCatchException/README.md @@ -1,18 +1,31 @@ # CwlCatchException + A simple Swift wrapper around an Objective-C `@try`/`@catch` statement that selectively catches Objective-C exceptions by `NSException` subtype, rethrowing if any caught exception is not the expected subtype. Look at [CwlCatchExceptionTests.swift](https://github.com/mattgallagher/CwlCatchException/blob/master/Tests/CwlCatchExceptionTests/CwlCatchExceptionTests.swift) for syntax. ## Requirements -From version 2.0.0-beta.1, building CwlCatchException requires Swift 5 or newer and the Swift Package Manager. +From version 2.0.0-beta.1, building CwlCatchException requires Swift 5 or newer, Swift Package Manager or CocoaPods. For use with older versions of Swift or other package managers, [use version 1.2.0 or older](https://github.com/mattgallagher/CwlCatchException/tree/1.2.0). ## Adding to your project +### Swift Package Manager + Add the following to the `dependencies` array in your "Package.swift" file: - .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: Version("2.0.0-beta.1")) + .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: Version("2.0.0")) + +Or by adding `https://github.com/mattgallagher/CwlCatchException.git`, version 2.0.0 or later, to the list of Swift packages for any project in Xcode. + +### CocoaPods + +CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CwlCatchException into your Xcode project using CocoaPods, specify it in your Podfile: + +pod 'CwlCatchException', '~> 2.0' + +## Thanks -Or by adding `https://github.com/mattgallagher/CwlCatchException.git`, version 2.0.0-beta.1 or later, to the list of Swift packages for any project in Xcode. +Includes contributions from @alexbaev, @dnkoutso and @ejensen. \ No newline at end of file diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift index 2cb9b2918..d6dbe4a0a 100644 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift +++ b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift @@ -20,16 +20,51 @@ import Foundation -#if SWIFT_PACKAGE +#if SWIFT_PACKAGE || COCOAPODS import CwlCatchExceptionSupport #endif -private func catchReturnTypeConverter(_ type: T.Type, block: @escaping () -> Void) -> T? { - return catchExceptionOfKind(type, block) as? T +private func catchReturnTypeConverter(_ type: Exception.Type, block: () -> Void) -> Exception? { + return catchExceptionOfKind(type, block) as? Exception } extension NSException { - public static func catchException(in block: @escaping () -> Void) -> Self? { + public static func catchException(in block: () -> Void) -> Self? { return catchReturnTypeConverter(self, block: block) } } + +public func catchExceptionAsError(in block: (() throws -> Output)) throws -> Output { + var result: Result? + + let exception = NSException.catchException { + result = Result(catching: block) + } + + if let exception = exception { + throw ExceptionError(exception) + } + + return try result!.get() +} + +// Adding conformance so that ExceptionError is fully Sendable as part of CustomNSError +extension NSException: @unchecked Sendable { } + +public struct ExceptionError: CustomNSError { + public let exception: NSException + public let domain = "com.cocoawithlove.catch-exception" + public let errorUserInfo: [String: Any] + + public init(_ exception: NSException) { + self.exception = exception + + if let userInfo = exception.userInfo { + self.errorUserInfo = [String: Any](uniqueKeysWithValues: userInfo.map { pair in + (pair.key.description, pair.value) + }) + } else { + self.errorUserInfo = [:] + } + } +} diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m index ff35465d8..4530e923b 100644 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m +++ b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m @@ -18,9 +18,9 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "CwlCatchException.h" +#import -NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void)) { +NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ NS_NOESCAPE __nonnull inBlock)(void)) { @try { inBlock(); } @catch (NSException *exception) { diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h index eb42378f5..b93dcd26f 100644 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h +++ b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h @@ -20,4 +20,4 @@ #import -NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void)); +NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ NS_NOESCAPE __nonnull inBlock)(void)); diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Package.swift b/Carthage/Checkouts/CwlPreconditionTesting/Package.swift index d6d183dbf..99133d0f5 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Package.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.5 import PackageDescription let package = Package( @@ -8,14 +8,14 @@ let package = Package( .library(name: "CwlPosixPreconditionTesting", targets: ["CwlPosixPreconditionTesting"]) ], dependencies: [ - .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: "2.0.0") + .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: "2.1.2") ], targets: [ .target( name: "CwlPreconditionTesting", dependencies: [ .target(name: "CwlMachBadInstructionHandler"), - .product(name: "CwlCatchException") + .product(name: "CwlCatchException", package: "CwlCatchException") ] ), .target( diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m index 168fa5b70..0af0e8e51 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m @@ -20,7 +20,7 @@ #ifdef __APPLE__ #import "TargetConditionals.h" -#if TARGET_OS_OSX || TARGET_OS_IOS +#if TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_VISION #import "mach_excServer.h" #import "CwlMachBadInstructionHandler.h" diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h index 6feabe5ad..ade03df71 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h @@ -20,7 +20,7 @@ #import -#if TARGET_OS_OSX || TARGET_OS_IOS +#if TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_VISION #import diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c index ccd8f84b8..c6f414176 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c @@ -10,7 +10,7 @@ #define __MIG_check__Request__mach_exc_subsystem__ 1 #import "mach_excServer.h" -#if TARGET_OS_OSX || TARGET_OS_IOS +#if TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_VISION #ifndef mig_internal #define mig_internal static __inline__ diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h index 1f03d66c6..941b227cd 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h @@ -1,6 +1,6 @@ #ifdef __APPLE__ #import "TargetConditionals.h" -#if TARGET_OS_OSX || TARGET_OS_IOS +#if TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_VISION #ifndef _mach_exc_server_ #define _mach_exc_server_ diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift index 9ec85da8a..002219dc9 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift @@ -18,11 +18,11 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if (os(macOS) || os(iOS)) && (arch(x86_64) || arch(arm64)) +#if (os(macOS) || os(iOS) || os(visionOS)) && (arch(x86_64) || arch(arm64)) import Foundation -#if SWIFT_PACKAGE +#if SWIFT_PACKAGE || COCOAPODS import CwlMachBadInstructionHandler #endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift index 7232c24dd..833abc15d 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -18,12 +18,13 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if (os(macOS) || os(iOS)) && (arch(x86_64) || arch(arm64)) +#if (os(macOS) || os(iOS) || os(visionOS)) && (arch(x86_64) || arch(arm64)) import Foundation import Swift -#if SWIFT_PACKAGE +#if SWIFT_PACKAGE || COCOAPODS + import CwlCatchException import CwlMachBadInstructionHandler #endif @@ -90,51 +91,8 @@ private struct MachContext { /// A function for receiving mach messages and parsing the first with mach_exc_server (and if any others are received, throwing them away). private func machMessageHandler(_ arg: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { let context = arg.assumingMemoryBound(to: MachContext.self).pointee - var request = request_mach_exception_raise_t() - var reply = reply_mach_exception_raise_state_t() - - var handledfirstException = false - repeat { do { - // Request the next mach message from the port - request.Head.msgh_local_port = context.currentExceptionPort - request.Head.msgh_size = UInt32(MemoryLayout.size) - let requestSize = request.Head.msgh_size - try kernCheck { request.withMsgHeaderPointer { requestPtr in - mach_msg(requestPtr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0, requestSize, context.currentExceptionPort, 0, UInt32(MACH_PORT_NULL)) - } } - - // Prepare the reply structure - reply.Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request.Head.msgh_bits), 0) - reply.Head.msgh_local_port = UInt32(MACH_PORT_NULL) - reply.Head.msgh_remote_port = request.Head.msgh_remote_port - reply.Head.msgh_size = UInt32(MemoryLayout.size) - reply.NDR = mach_ndr_record() - - if !handledfirstException { - // Use the MiG generated server to invoke our handler for the request and fill in the rest of the reply structure - guard request.withMsgHeaderPointer(in: { requestPtr in reply.withMsgHeaderPointer { replyPtr in - mach_exc_server(requestPtr, replyPtr) - } }) != 0 else { throw MachExcServer.code(reply.RetCode) } - - handledfirstException = true - } else { - // If multiple fatal errors occur, don't handle subsquent errors (let the program crash) - reply.RetCode = KERN_FAILURE - } - - // Send the reply - let replySize = reply.Head.msgh_size - try kernCheck { reply.withMsgHeaderPointer { replyPtr in - mach_msg(replyPtr, MACH_SEND_MSG, replySize, 0, UInt32(MACH_PORT_NULL), 0, UInt32(MACH_PORT_NULL)) - } } - } catch let error as NSError where (error.domain == NSMachErrorDomain && (error.code == Int(MACH_RCV_PORT_CHANGED) || error.code == Int(MACH_RCV_INVALID_NAME))) { - // Port was already closed before we started or closed while we were listening. - // This means the controlling thread shut down. - return nil - } catch { - // Should never be reached but this is testing code, don't try to recover, just abort - fatalError("Mach message error: \(error)") - } } while true + mach_msg_server(unsafeBitCast(mach_exc_server as (@convention(c) (UnsafeMutablePointer, UnsafeMutablePointer) -> boolean_t), to: (@convention(c) (UnsafeMutablePointer?, UnsafeMutablePointer?) -> boolean_t).self), 4096, context.currentExceptionPort, MACH_MSG_OPTION_NONE) + return nil } /// Run the provided block. If a mach "BAD_INSTRUCTION" exception is raised, catch it and return a BadInstructionException (which captures stack information about the throw site, if desired). Otherwise return nil. @@ -170,7 +128,10 @@ public func catchBadInstruction(in block: @escaping () -> Void) -> BadInstructio } defer { // 7. Cleanup the mach port - mach_port_destroy(mach_task_self_, context.currentExceptionPort) + // When the reference count for the right goes down to 0, it triggers the right to be deallocated + mach_port_mod_refs(mach_task_self_, context.currentExceptionPort, MACH_PORT_RIGHT_RECEIVE, -1) + // All rights deallocated, can deallocate the name/port + mach_port_deallocate(mach_task_self_, context.currentExceptionPort) } try kernCheck { diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift index ccce5c59d..ad01ccfe4 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift @@ -18,7 +18,7 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if (os(macOS) || os(iOS)) && (arch(x86_64) || arch(arm64)) +#if (os(macOS) || os(iOS) || os(visionOS)) && (arch(x86_64) || arch(arm64)) import Darwin From a594e61c30daf1e738636670258c642cf8733381 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 13:24:46 +0100 Subject: [PATCH 05/17] add visionOS support when using the Xcode project --- Nimble.xcodeproj/project.pbxproj | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index 9c387bc9d..eee4eb33a 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 53; + objectVersion = 55; objects = { /* Begin PBXAggregateTarget section */ @@ -165,15 +165,15 @@ CDC157912511957100EAA480 /* DSLTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC157902511957100EAA480 /* DSLTest.swift */; }; CDD80B831F2030790002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; CDF5C57B2647B89B0036532C /* Equal+Tuple.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF5C57A2647B89B0036532C /* Equal+Tuple.swift */; }; - CDFB6A231F7E07C700AD8CC7 /* CwlCatchException.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A1E1F7E07C600AD8CC7 /* CwlCatchException.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A251F7E07C700AD8CC7 /* CwlCatchException.m in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A201F7E07C600AD8CC7 /* CwlCatchException.m */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A221F7E07C600AD8CC7 /* CwlCatchException.h */; platformFilters = (driverkit, ios, maccatalyst, macos, ); settings = {ATTRIBUTES = (Public, ); }; }; - CDFB6A391F7E082500AD8CC7 /* CwlBadInstructionException.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2A1F7E082400AD8CC7 /* CwlBadInstructionException.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A3B1F7E082500AD8CC7 /* CwlCatchBadInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2B1F7E082400AD8CC7 /* CwlCatchBadInstruction.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A3F1F7E082500AD8CC7 /* CwlDarwinDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2D1F7E082400AD8CC7 /* CwlDarwinDefinitions.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; + CDFB6A231F7E07C700AD8CC7 /* CwlCatchException.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A1E1F7E07C600AD8CC7 /* CwlCatchException.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); }; + CDFB6A251F7E07C700AD8CC7 /* CwlCatchException.m in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A201F7E07C600AD8CC7 /* CwlCatchException.m */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); }; + CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A221F7E07C600AD8CC7 /* CwlCatchException.h */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); settings = {ATTRIBUTES = (Public, ); }; }; + CDFB6A391F7E082500AD8CC7 /* CwlBadInstructionException.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2A1F7E082400AD8CC7 /* CwlBadInstructionException.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); }; + CDFB6A3B1F7E082500AD8CC7 /* CwlCatchBadInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2B1F7E082400AD8CC7 /* CwlCatchBadInstruction.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); }; + CDFB6A3F1F7E082500AD8CC7 /* CwlDarwinDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2D1F7E082400AD8CC7 /* CwlDarwinDefinitions.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); }; CDFB6A471F7E082500AD8CC7 /* CwlMachBadInstructionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A341F7E082400AD8CC7 /* CwlMachBadInstructionHandler.m */; }; - CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A361F7E082400AD8CC7 /* CwlMachBadInstructionHandler.h */; platformFilters = (driverkit, ios, maccatalyst, macos, ); settings = {ATTRIBUTES = (Public, ); }; }; - CDFB6A4B1F7E082500AD8CC7 /* mach_excServer.c in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A371F7E082400AD8CC7 /* mach_excServer.c */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; + CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A361F7E082400AD8CC7 /* CwlMachBadInstructionHandler.h */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); settings = {ATTRIBUTES = (Public, ); }; }; + CDFB6A4B1F7E082500AD8CC7 /* mach_excServer.c in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A371F7E082400AD8CC7 /* mach_excServer.c */; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); }; DA9E8C831A414BB9002633C2 /* DSL+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */; }; DD72EC651A93874A002F7651 /* AllPassTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD72EC631A93874A002F7651 /* AllPassTest.swift */; }; DD9A9A9019CF43AD00706F49 /* BeIdenticalToObjectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD9A9A8D19CF413800706F49 /* BeIdenticalToObjectTest.swift */; }; @@ -1254,10 +1254,10 @@ PRODUCT_NAME = Nimble; SDKROOT = macosx; SKIP_INSTALL = YES; - SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator"; + SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator"; SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; - TARGETED_DEVICE_FAMILY = "1,2,3,4"; + TARGETED_DEVICE_FAMILY = "1,2,3,4,7"; }; name = Debug; }; @@ -1297,12 +1297,12 @@ PRODUCT_NAME = Nimble; SDKROOT = macosx; SKIP_INSTALL = YES; - SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator"; + SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator"; SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - TARGETED_DEVICE_FAMILY = "1,2,3,4"; + TARGETED_DEVICE_FAMILY = "1,2,3,4,7"; }; name = Release; }; From f0fb4c47a445b6b000c43f3f0c7e48ff1b2ba99d Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 13:25:42 +0100 Subject: [PATCH 06/17] extend test script to include visionOS --- test | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test b/test index 1a40ebe4e..787224e4d 100755 --- a/test +++ b/test @@ -13,6 +13,8 @@ if which xcodebuild > /dev/null; then LATEST_WATCHOS_SDK_VERSION=`xcodebuild -showsdks | grep -e '-sdk watchos' | cut -d ' ' -f 2 | ruby -e 'puts STDIN.read.chomp.split("\n").last'` LATEST_WATCHOS_VERSION=`xcrun simctl list | grep ^watchOS | ruby -e 'puts /\(([0-9.]+).*\)/.match(STDIN.read.chomp.split("\n").last).to_a[1]'` LATEST_MACOS_SDK_VERSION=`xcodebuild -showsdks | grep -e '-sdk macosx' | cut -d ' ' -f 2 | ruby -e 'puts STDIN.read.chomp.split("\n").last'` + LATEST_VISIONOS_SDK_VERSION=`xcodebuild -showsdks | grep -e '-sdk xros' | cut -d ' ' -f 2 | ruby -e 'puts STDIN.read.chomp.split("\n").last'` + LATEST_VISIONOS_VERSION=`xcrun simctl list | grep ^visionOS | ruby -e 'puts /\(([0-9.]+).*\)/.match(STDIN.read.chomp.split("\n").last).to_a[1]'` BUILD_IOS_SDK_VERSION=${NIMBLE_BUILD_IOS_SDK_VERSION:-$LATEST_IOS_SDK_VERSION} RUNTIME_IOS_VERSION=${NIMBLE_RUNTIME_IOS_VERSION:-$LATEST_IOS_VERSION} BUILD_TVOS_SDK_VERSION=${NIMBLE_BUILD_TVOS_SDK_VERSION:-$LATEST_TVOS_SDK_VERSION} @@ -20,6 +22,8 @@ if which xcodebuild > /dev/null; then BUILD_WATCHOS_SDK_VERSION=${NIMBLE_BUILD_WATCHOS_SDK_VERSION:-$LATEST_WATCHOS_SDK_VERSION} RUNTIME_WATCHOS_VERSION=${NIMBLE_RUNTIME_WATCHOS_VERSION:-$LATEST_WATCHOS_VERSION} BUILD_MACOS_SDK_VERSION=${NIMBLE_BUILD_MACOS_SDK_VERSION:-$LATEST_MACOS_SDK_VERSION} + BUILD_VISIONOS_SDK_VERSION=${NIMBLE_BUILD_VISIONOS_SDK_VERSION:-$LATEST_VISIONOS_SDK_VERSION} + RUNTIME_VISIONOS_VERSION=${NIMBLE_RUNTIME_VISIONOS_VERSION:-$LATEST_VISIONOS_VERSION} fi set -e @@ -51,6 +55,11 @@ function print_env { echo " Building with watchOS SDK: `color_if_overridden $BUILD_WATCHOS_SDK_VERSION $NIMBLE_BUILD_WATCHOS_SDK_VERSION`" echo " Running with watchOS: `color_if_overridden $RUNTIME_WATCHOS_VERSION $NIMBLE_RUNTIME_WATCHOS_VERSION`" echo + echo " visionOS:" + echo " Latest visionOS SDK: $LATEST_VISIONOS_SDK_VERSION" + echo " Building with visionOS SDK: `color_if_overridden $BUILD_VISIONOS_SDK_VERSION $NIMBLE_BUILD_VISIONOS_SDK_VERSION`" + echo " Running with visionOS: `color_if_overridden $RUNTIME_VISIONOS_VERSION $NIMBLE_RUNTIME_VISIONOS_VERSION`" + echo echo " macOS:" echo " Latest macOS SDK: $LATEST_MACOS_SDK_VERSION" echo " Building with macOS SDK: `color_if_overridden $BUILD_MACOS_SDK_VERSION $NIMBLE_BUILD_MACOS_SDK_VERSION`" @@ -85,6 +94,13 @@ function test_watchos { run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble" -configuration "Debug" -sdk "watchsimulator$BUILD_WATCHOS_SDK_VERSION" -destination "name=Apple Watch Series 6 (40mm),OS=$RUNTIME_WATCHOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty } +function test_visionos { + run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble" -configuration "Debug" -destination "generic/platform=visionOS" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build | xcpretty + + run osascript -e 'tell app "Simulator" to quit' + run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble" -configuration "Debug" -sdk "xrsimulator$BUILD_VISIONOS_SDK_VERSION" -destination "name=Apple Vision Pro),OS=$RUNTIME_VISIONOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty +} + function test_macos { run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble" -configuration "Debug" -sdk "macosx$BUILD_MACOS_SDK_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty } @@ -116,6 +132,13 @@ function test_xcode_spm_watchos { run set -o pipefail && xcodebuild -scheme "Nimble" -configuration "Debug" -sdk "watchsimulator$BUILD_WATCHOS_SDK_VERSION" -destination "name=Apple Watch Series 6 (40mm),OS=$RUNTIME_WATCHOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty } +function test_xcode_spm_visionos { + run osascript -e 'tell app "Simulator" to quit' + mv Nimble.xcodeproj Nimble.xcodeproj.bak + trap 'mv Nimble.xcodeproj.bak Nimble.xcodeproj' EXIT + run set -o pipefail && xcodebuild -scheme "Nimble" -configuration "Debug" -sdk "xrsimulator$BUILD_WATCHOS_SDK_VERSION" -destination "name=Apple Vision Pro,OS=$RUNTIME_WATCHOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty +} + function test_podspec { echo "Gathering CocoaPods installation information..." run bundle exec pod --version @@ -141,12 +164,14 @@ function test() { test_ios test_tvos test_watchos + test_visionos if xcodebuild --help 2>&1 | grep xcframework > /dev/null; then test_xcode_spm_macos test_xcode_spm_ios test_xcode_spm_tvos test_xcode_spm_watchos + test_xcode_spm_visionos else echo "Not testing with Swift Package Manager version of Xcode because it requires at least Xcode 11" fi @@ -183,6 +208,8 @@ function help { echo " tvos_xcodespm - Runs the tests as an tvOS device using the Swift Package Manager version of Xcode" echo " watchos - Runs the tests as an watchOS device" echo " watchos_xcodespm - Runs the tests as an watchOS device using the Swift Package Manager version of Xcode" + echo " visionos - Runs the tests as an visionOS device" + echo " visionos_xcodespm - Runs the tests as an visionOS device using the Swift Package Manager version of Xcode" echo " podspec - Runs pod lib lint against the podspec to detect breaking changes" echo " swiftpm - Runs the tests built by the Swift Package Manager" echo " swiftpm_docker - Runs the tests built by the Swift Package Manager in a docker linux container" @@ -202,6 +229,8 @@ function main { tvos_xcodespm) test_xcode_spm_tvos ;; watchos) test_watchos ;; watchos_xcodespm) test_xcode_spm_watchos ;; + visionos) test_visionos ;; + visionos_xcodespm) test_xcode_spm_visionos ;; macos) test_macos ;; macos_xcodespm) test_xcode_spm_macos ;; podspec) test_podspec ;; From 37206178331180bc11e261b433f55c7095c6c7a1 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 2 Nov 2023 14:36:36 +0100 Subject: [PATCH 07/17] fix cocoapods support by modifying dependencies directly --- .../Sources/CwlCatchException/CwlCatchException.swift | 2 +- .../CwlPreconditionTesting/CwlBadInstructionException.swift | 2 +- .../Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift index d6dbe4a0a..8232fcb46 100644 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift +++ b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift @@ -20,7 +20,7 @@ import Foundation -#if SWIFT_PACKAGE || COCOAPODS +#if SWIFT_PACKAGE import CwlCatchExceptionSupport #endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift index 002219dc9..e6e70cfe3 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift @@ -22,7 +22,7 @@ import Foundation -#if SWIFT_PACKAGE || COCOAPODS +#if SWIFT_PACKAGE import CwlMachBadInstructionHandler #endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift index 833abc15d..35b8eb711 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -23,7 +23,7 @@ import Foundation import Swift -#if SWIFT_PACKAGE || COCOAPODS +#if SWIFT_PACKAGE import CwlCatchException import CwlMachBadInstructionHandler #endif From 78b4e7649c32d38582e9084b72965f318a933060 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Fri, 3 Nov 2023 10:30:51 +0100 Subject: [PATCH 08/17] do not break older Swift version support by creating a swift 5.9 explicit Package.swift file --- Package.swift | 9 +++--- Package@swift-5.9.swift | 66 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 Package@swift-5.9.swift diff --git a/Package.swift b/Package.swift index 0a2eebdd4..de40d97b5 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,10 @@ -// swift-tools-version:5.9 +// swift-tools-version:5.7 import PackageDescription let package = Package( name: "Nimble", platforms: [ - .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1) + .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6) ], products: [ .library( @@ -19,8 +19,7 @@ let package = Package( ), ], dependencies: [ - // TODO: use official repo once merged - .package(url: "https://github.com/bitmovin-engineering/CwlPreconditionTesting.git", branch: "bitmovin/feature/visionos-support"), + .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .upToNextMajor(from: "2.1.0")), ], targets: { var testHelperDependencies: [PackageDescription.Target.Dependency] = ["Nimble"] @@ -32,7 +31,7 @@ let package = Package( name: "Nimble", dependencies: [ .product(name: "CwlPreconditionTesting", package: "CwlPreconditionTesting", - condition: .when(platforms: [.macOS, .iOS, .macCatalyst, .visionOS])), + condition: .when(platforms: [.macOS, .iOS, .macCatalyst])), .product(name: "CwlPosixPreconditionTesting", package: "CwlPreconditionTesting", condition: .when(platforms: [.tvOS, .watchOS])) ], diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift new file mode 100644 index 000000000..0a2eebdd4 --- /dev/null +++ b/Package@swift-5.9.swift @@ -0,0 +1,66 @@ +// swift-tools-version:5.9 +import PackageDescription + +let package = Package( + name: "Nimble", + platforms: [ + .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1) + ], + products: [ + .library( + name: "Nimble", + targets: { + var targets: [String] = ["Nimble"] + #if os(macOS) + targets.append("NimbleObjectiveC") + #endif + return targets + }() + ), + ], + dependencies: [ + // TODO: use official repo once merged + .package(url: "https://github.com/bitmovin-engineering/CwlPreconditionTesting.git", branch: "bitmovin/feature/visionos-support"), + ], + targets: { + var testHelperDependencies: [PackageDescription.Target.Dependency] = ["Nimble"] + #if os(macOS) + testHelperDependencies.append("NimbleObjectiveC") + #endif + var targets: [Target] = [ + .target( + name: "Nimble", + dependencies: [ + .product(name: "CwlPreconditionTesting", package: "CwlPreconditionTesting", + condition: .when(platforms: [.macOS, .iOS, .macCatalyst, .visionOS])), + .product(name: "CwlPosixPreconditionTesting", package: "CwlPreconditionTesting", + condition: .when(platforms: [.tvOS, .watchOS])) + ], + exclude: ["Info.plist"] + ), + .target( + name: "NimbleSharedTestHelpers", + dependencies: testHelperDependencies + ), + .testTarget( + name: "NimbleTests", + dependencies: ["Nimble", "NimbleSharedTestHelpers"], + exclude: ["Info.plist"] + ), + ] +#if os(macOS) + targets.append(contentsOf: [ + .target( + name: "NimbleObjectiveC", + dependencies: ["Nimble"] + ), + .testTarget( + name: "NimbleObjectiveCTests", + dependencies: ["NimbleObjectiveC", "Nimble", "NimbleSharedTestHelpers"] + ) + ]) + #endif + return targets + }(), + swiftLanguageVersions: [.v5] +) From b86604f0bc06d55c495d980e5aa1d55217cdd5db Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Sat, 4 Nov 2023 11:47:46 +0100 Subject: [PATCH 09/17] skip tests on visionOS if it's not present --- test | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test b/test index 787224e4d..eca4c488b 100755 --- a/test +++ b/test @@ -95,6 +95,11 @@ function test_watchos { } function test_visionos { + if [[ -z $LATEST_VISIONOS_SDK_VERSION ]]; then + echo "visionOS is not supported on this machine" + return + fi + run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble" -configuration "Debug" -destination "generic/platform=visionOS" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build | xcpretty run osascript -e 'tell app "Simulator" to quit' @@ -133,6 +138,11 @@ function test_xcode_spm_watchos { } function test_xcode_spm_visionos { + if [[ -z $LATEST_VISIONOS_SDK_VERSION ]]; then + echo "visionOS is not supported on this machine" + return + fi + run osascript -e 'tell app "Simulator" to quit' mv Nimble.xcodeproj Nimble.xcodeproj.bak trap 'mv Nimble.xcodeproj.bak Nimble.xcodeproj' EXIT From a8d72dd17dfbcc09e18b06a9606e802b24b2fc99 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Fri, 10 Nov 2023 08:50:11 +0100 Subject: [PATCH 10/17] fix build issues below Xcode 15 --- Nimble.xcodeproj/project.pbxproj | 6 ++++++ Sources/Nimble/NimblePrefixHeader.pch | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Sources/Nimble/NimblePrefixHeader.pch diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index eee4eb33a..ea9f65e71 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -108,6 +108,7 @@ 1FE661571E6574E30035F243 /* ExpectationMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FE661561E6574E20035F243 /* ExpectationMessage.swift */; }; 29EA59641B551ED2002D767E /* ThrowErrorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EA59621B551ED2002D767E /* ThrowErrorTest.swift */; }; 29EA59671B551EE6002D767E /* ThrowError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EA59651B551EE6002D767E /* ThrowError.swift */; }; + 37B050BA2AFE172B00B26672 /* NimblePrefixHeader.pch in Headers */ = {isa = PBXBuildFile; fileRef = 37B050B92AFE172B00B26672 /* NimblePrefixHeader.pch */; }; 472FD1391B9E0A9700C7B8DA /* HaveCount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472FD1341B9E085700C7B8DA /* HaveCount.swift */; }; 472FD13A1B9E0A9F00C7B8DA /* HaveCountTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472FD1361B9E094B00C7B8DA /* HaveCountTest.swift */; }; 4793854E1BA0BB2500296F85 /* ObjCHaveCountTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4793854C1BA0BB2500296F85 /* ObjCHaveCountTest.m */; }; @@ -293,6 +294,7 @@ 1FE661561E6574E20035F243 /* ExpectationMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpectationMessage.swift; sourceTree = ""; }; 29EA59621B551ED2002D767E /* ThrowErrorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThrowErrorTest.swift; sourceTree = ""; }; 29EA59651B551EE6002D767E /* ThrowError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThrowError.swift; sourceTree = ""; }; + 37B050B92AFE172B00B26672 /* NimblePrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NimblePrefixHeader.pch; sourceTree = ""; }; 472FD1341B9E085700C7B8DA /* HaveCount.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HaveCount.swift; sourceTree = ""; }; 472FD1361B9E094B00C7B8DA /* HaveCountTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HaveCountTest.swift; sourceTree = ""; }; 4793854C1BA0BB2500296F85 /* ObjCHaveCountTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCHaveCountTest.m; sourceTree = ""; }; @@ -458,6 +460,7 @@ 1F1A742D1940169200FFFC47 /* Info.plist */, 1FD8CD0C1968AB07008ED995 /* Matchers */, 1F1A742E1940169200FFFC47 /* Nimble.h */, + 37B050B92AFE172B00B26672 /* NimblePrefixHeader.pch */, 1FD8CD241968AB07008ED995 /* Utils */, ); name = Nimble; @@ -770,6 +773,7 @@ files = ( CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */, CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */, + 37B050BA2AFE172B00B26672 /* NimblePrefixHeader.pch in Headers */, 1F1871DF1CA89EF500A34BF2 /* NMBStringify.h in Headers */, 1F1871DD1CA89EF500A34BF2 /* DSL.h in Headers */, 1F1871DE1CA89EF500A34BF2 /* NMBExceptionCapture.h in Headers */, @@ -1117,6 +1121,7 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Sources/$(PROJECT_NAME)/NimblePrefixHeader.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -1189,6 +1194,7 @@ ENABLE_TESTING_SEARCH_PATHS = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Sources/$(PROJECT_NAME)/NimblePrefixHeader.pch"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; diff --git a/Sources/Nimble/NimblePrefixHeader.pch b/Sources/Nimble/NimblePrefixHeader.pch new file mode 100644 index 000000000..c362d0984 --- /dev/null +++ b/Sources/Nimble/NimblePrefixHeader.pch @@ -0,0 +1,10 @@ +#ifndef NimblePrefixHeader_pch +#define NimblePrefixHeader_pch + +// When running below Xcode 15, TARGET_OS_VISION is not defined. Since the project has TREAT_WARNINGS_AS_ERROS enabled +// we need to workaround this warning. +#ifndef TARGET_OS_VISION + #define TARGET_OS_VISION 0 +#endif /* TARGET_OS_VISION */ + +#endif /* NimblePrefixHeader_pch */ From 00d60033ddd04c9979beb3ed22e7efb18e5d718c Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Fri, 10 Nov 2023 09:06:10 +0100 Subject: [PATCH 11/17] skip visionOS cocoapod validation if visionOS is not present --- test | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test b/test index eca4c488b..117d09963 100755 --- a/test +++ b/test @@ -150,11 +150,16 @@ function test_xcode_spm_visionos { } function test_podspec { + PLATFORMS="ios,tvos,watchos,macos" + if [[ ! -z $LATEST_VISIONOS_SDK_VERSION ]]; then + PLATFORMS="$PLATFORMS,visionos" + fi + echo "Gathering CocoaPods installation information..." run bundle exec pod --version echo "Linting podspec..." # Note: remove `--allow-warnings` once old Matcher API has been removed - run bundle exec pod lib lint Nimble.podspec --allow-warnings --skip-import-validation --verbose + run bundle exec pod lib lint Nimble.podspec --allow-warnings --skip-import-validation --verbose --platforms=$PLATFORMS } function test_swiftpm { From 5cf19cabc597936e6bf70b292d9261dd684db9cb Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Tue, 14 Nov 2023 09:18:58 +0100 Subject: [PATCH 12/17] move TARGET_OS_VISION definition to umbrella header --- Nimble.xcodeproj/project.pbxproj | 6 ------ Sources/Nimble/Nimble.h | 7 +++++++ Sources/Nimble/NimblePrefixHeader.pch | 10 ---------- 3 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 Sources/Nimble/NimblePrefixHeader.pch diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index ea9f65e71..eee4eb33a 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -108,7 +108,6 @@ 1FE661571E6574E30035F243 /* ExpectationMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FE661561E6574E20035F243 /* ExpectationMessage.swift */; }; 29EA59641B551ED2002D767E /* ThrowErrorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EA59621B551ED2002D767E /* ThrowErrorTest.swift */; }; 29EA59671B551EE6002D767E /* ThrowError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EA59651B551EE6002D767E /* ThrowError.swift */; }; - 37B050BA2AFE172B00B26672 /* NimblePrefixHeader.pch in Headers */ = {isa = PBXBuildFile; fileRef = 37B050B92AFE172B00B26672 /* NimblePrefixHeader.pch */; }; 472FD1391B9E0A9700C7B8DA /* HaveCount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472FD1341B9E085700C7B8DA /* HaveCount.swift */; }; 472FD13A1B9E0A9F00C7B8DA /* HaveCountTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472FD1361B9E094B00C7B8DA /* HaveCountTest.swift */; }; 4793854E1BA0BB2500296F85 /* ObjCHaveCountTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4793854C1BA0BB2500296F85 /* ObjCHaveCountTest.m */; }; @@ -294,7 +293,6 @@ 1FE661561E6574E20035F243 /* ExpectationMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpectationMessage.swift; sourceTree = ""; }; 29EA59621B551ED2002D767E /* ThrowErrorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThrowErrorTest.swift; sourceTree = ""; }; 29EA59651B551EE6002D767E /* ThrowError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThrowError.swift; sourceTree = ""; }; - 37B050B92AFE172B00B26672 /* NimblePrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NimblePrefixHeader.pch; sourceTree = ""; }; 472FD1341B9E085700C7B8DA /* HaveCount.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HaveCount.swift; sourceTree = ""; }; 472FD1361B9E094B00C7B8DA /* HaveCountTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HaveCountTest.swift; sourceTree = ""; }; 4793854C1BA0BB2500296F85 /* ObjCHaveCountTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCHaveCountTest.m; sourceTree = ""; }; @@ -460,7 +458,6 @@ 1F1A742D1940169200FFFC47 /* Info.plist */, 1FD8CD0C1968AB07008ED995 /* Matchers */, 1F1A742E1940169200FFFC47 /* Nimble.h */, - 37B050B92AFE172B00B26672 /* NimblePrefixHeader.pch */, 1FD8CD241968AB07008ED995 /* Utils */, ); name = Nimble; @@ -773,7 +770,6 @@ files = ( CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */, CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */, - 37B050BA2AFE172B00B26672 /* NimblePrefixHeader.pch in Headers */, 1F1871DF1CA89EF500A34BF2 /* NMBStringify.h in Headers */, 1F1871DD1CA89EF500A34BF2 /* DSL.h in Headers */, 1F1871DE1CA89EF500A34BF2 /* NMBExceptionCapture.h in Headers */, @@ -1121,7 +1117,6 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Sources/$(PROJECT_NAME)/NimblePrefixHeader.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -1194,7 +1189,6 @@ ENABLE_TESTING_SEARCH_PATHS = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; - GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Sources/$(PROJECT_NAME)/NimblePrefixHeader.pch"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; diff --git a/Sources/Nimble/Nimble.h b/Sources/Nimble/Nimble.h index 1072c2641..2fb81305e 100644 --- a/Sources/Nimble/Nimble.h +++ b/Sources/Nimble/Nimble.h @@ -1,4 +1,11 @@ #import + +// When running below Xcode 15, TARGET_OS_VISION is not defined. Since the project has TREAT_WARNINGS_AS_ERROS enabled +// we need to workaround this warning. +#ifndef TARGET_OS_VISION + #define TARGET_OS_VISION 0 +#endif /* TARGET_OS_VISION */ + #import #import #import diff --git a/Sources/Nimble/NimblePrefixHeader.pch b/Sources/Nimble/NimblePrefixHeader.pch deleted file mode 100644 index c362d0984..000000000 --- a/Sources/Nimble/NimblePrefixHeader.pch +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef NimblePrefixHeader_pch -#define NimblePrefixHeader_pch - -// When running below Xcode 15, TARGET_OS_VISION is not defined. Since the project has TREAT_WARNINGS_AS_ERROS enabled -// we need to workaround this warning. -#ifndef TARGET_OS_VISION - #define TARGET_OS_VISION 0 -#endif /* TARGET_OS_VISION */ - -#endif /* NimblePrefixHeader_pch */ From 3ff34fc02d5a4130d055ba731a1af27c4c304d99 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Tue, 14 Nov 2023 09:19:16 +0100 Subject: [PATCH 13/17] bump CwlPreconditionTesting to 2.2.0 --- Cartfile.private | 2 +- Cartfile.resolved | 2 +- .../Sources/CwlCatchException/CwlCatchException.swift | 2 +- .../CwlPreconditionTesting/CwlBadInstructionException.swift | 2 +- .../CwlPreconditionTesting/CwlCatchBadInstruction.swift | 2 +- Package@swift-5.9.swift | 3 +-- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cartfile.private b/Cartfile.private index a9f3a0a80..77f011443 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ github "mattgallagher/CwlCatchException" ~> 2.0 -github "bitmovin-engineering/CwlPreconditionTesting" "bitmovin/main" +github "mattgallagher/CwlPreconditionTesting" ~> 2.2 diff --git a/Cartfile.resolved b/Cartfile.resolved index da40ae26d..d1e256c45 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "bitmovin-engineering/CwlPreconditionTesting" "1a3d129278e6e1b0622fdc965fe4d0f9b6cea3e3" github "mattgallagher/CwlCatchException" "2.1.2" +github "mattgallagher/CwlPreconditionTesting" "2.2.0" diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift index 8232fcb46..d6dbe4a0a 100644 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift +++ b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift @@ -20,7 +20,7 @@ import Foundation -#if SWIFT_PACKAGE +#if SWIFT_PACKAGE || COCOAPODS import CwlCatchExceptionSupport #endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift index e6e70cfe3..002219dc9 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift @@ -22,7 +22,7 @@ import Foundation -#if SWIFT_PACKAGE +#if SWIFT_PACKAGE || COCOAPODS import CwlMachBadInstructionHandler #endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift index 35b8eb711..833abc15d 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -23,7 +23,7 @@ import Foundation import Swift -#if SWIFT_PACKAGE +#if SWIFT_PACKAGE || COCOAPODS import CwlCatchException import CwlMachBadInstructionHandler #endif diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift index 0a2eebdd4..3a52f3140 100644 --- a/Package@swift-5.9.swift +++ b/Package@swift-5.9.swift @@ -19,8 +19,7 @@ let package = Package( ), ], dependencies: [ - // TODO: use official repo once merged - .package(url: "https://github.com/bitmovin-engineering/CwlPreconditionTesting.git", branch: "bitmovin/feature/visionos-support"), + .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .upToNextMajor(from: "2.2.0")), ], targets: { var testHelperDependencies: [PackageDescription.Target.Dependency] = ["Nimble"] From 1972142da3ecb628dae357da3f4bc4812e8a38de Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 21 Dec 2023 15:25:09 +0100 Subject: [PATCH 14/17] link CwlPreconditionTesting on visionOS --- Nimble.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index 4a5054e9f..d0a551929 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -141,7 +141,7 @@ 89C297CE2A92AB34002A143F /* AsyncPromiseTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89C297CD2A92AB34002A143F /* AsyncPromiseTest.swift */; }; 89D8AC852B3211C600410644 /* CwlCatchException in Frameworks */ = {isa = PBXBuildFile; productRef = 89D8AC842B3211C600410644 /* CwlCatchException */; }; 89D8AC872B3211EA00410644 /* CwlPosixPreconditionTesting in Frameworks */ = {isa = PBXBuildFile; platformFilters = (tvos, watchos, ); productRef = 89D8AC862B3211EA00410644 /* CwlPosixPreconditionTesting */; }; - 89D8AC892B3211EA00410644 /* CwlPreconditionTesting in Frameworks */ = {isa = PBXBuildFile; platformFilters = (driverkit, ios, maccatalyst, macos, ); productRef = 89D8AC882B3211EA00410644 /* CwlPreconditionTesting */; }; + 89D8AC892B3211EA00410644 /* CwlPreconditionTesting in Frameworks */ = {isa = PBXBuildFile; platformFilters = (driverkit, ios, maccatalyst, macos, xros, ); productRef = 89D8AC882B3211EA00410644 /* CwlPreconditionTesting */; }; 89EEF5A52A03293100988224 /* AsyncMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89EEF5A42A03293100988224 /* AsyncMatcher.swift */; }; 89EEF5B72A032C3200988224 /* AsyncPredicateTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89EEF5B22A032C2500988224 /* AsyncPredicateTest.swift */; }; 89EEF5C02A06211C00988224 /* AsyncHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89EEF5BB2A06210D00988224 /* AsyncHelpers.swift */; }; From c08b06085f513beca37c1abe314d75c7ef15801a Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Thu, 21 Dec 2023 15:33:32 +0100 Subject: [PATCH 15/17] add visionOS for to dependencies array --- Nimble.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nimble.podspec b/Nimble.podspec index 670858631..5285a75ba 100644 --- a/Nimble.podspec +++ b/Nimble.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| 'OTHER_SWIFT_FLAGS' => '$(inherited) -suppress-warnings', } - [s.osx, s.ios].each do |platform| + [s.osx, s.ios, s.visionos].each do |platform| platform.dependency 'CwlMachBadInstructionHandler', '~> 2.1.0' platform.dependency 'CwlCatchException', '~> 2.1.0' end From 9eaf3be0c40b924bd5de66e5bb4626774ff4b781 Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Wed, 17 Jan 2024 11:23:19 +0100 Subject: [PATCH 16/17] add CI execution for visionOS with Xcode 15.2 --- .github/workflows/ci-xcode.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-xcode.yml b/.github/workflows/ci-xcode.yml index 8e55af81b..d3b0abefe 100644 --- a/.github/workflows/ci-xcode.yml +++ b/.github/workflows/ci-xcode.yml @@ -32,7 +32,7 @@ jobs: runs-on: macos-13 strategy: matrix: - xcode: ["14.3.1"] + xcode: ["14.3.1", "15.2"] fail-fast: false env: DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode }}.app" @@ -42,6 +42,8 @@ jobs: - run: ./test ios - run: ./test tvos - run: ./test watchos + - run: ./test visionos + if: matrix.xcode == '15.2' xcode_spm: name: Xcode ${{ matrix.xcode }} (Swift Package) From 6eb588189a4941efe9eaab83e60ba78aa5ee1c9e Mon Sep 17 00:00:00 2001 From: David Steinacher Date: Wed, 17 Jan 2024 20:24:32 +0100 Subject: [PATCH 17/17] remove visionOS testing on Xcode 15.2 * it looks like the visionOS simulator is not created by default on the used macOS image --- .github/workflows/ci-xcode.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci-xcode.yml b/.github/workflows/ci-xcode.yml index d3b0abefe..8e55af81b 100644 --- a/.github/workflows/ci-xcode.yml +++ b/.github/workflows/ci-xcode.yml @@ -32,7 +32,7 @@ jobs: runs-on: macos-13 strategy: matrix: - xcode: ["14.3.1", "15.2"] + xcode: ["14.3.1"] fail-fast: false env: DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode }}.app" @@ -42,8 +42,6 @@ jobs: - run: ./test ios - run: ./test tvos - run: ./test watchos - - run: ./test visionos - if: matrix.xcode == '15.2' xcode_spm: name: Xcode ${{ matrix.xcode }} (Swift Package)