diff --git a/Sources/BluetoothAccessory/DateComponents.swift b/Sources/BluetoothAccessory/DateComponents.swift index b254ff1..51ac803 100644 --- a/Sources/BluetoothAccessory/DateComponents.swift +++ b/Sources/BluetoothAccessory/DateComponents.swift @@ -6,7 +6,7 @@ // Copyright © 2015 PureSwift. All rights reserved. // -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if canImport(Darwin) import Darwin.C #elseif os(Linux) import Glibc diff --git a/Sources/BluetoothAccessory/POSIXTime.swift b/Sources/BluetoothAccessory/POSIXTime.swift index cc8e50b..1d36113 100644 --- a/Sources/BluetoothAccessory/POSIXTime.swift +++ b/Sources/BluetoothAccessory/POSIXTime.swift @@ -6,7 +6,7 @@ // Copyright © 2015 PureSwift. All rights reserved. // -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if canImport(Darwin) import Darwin.C #elseif os(Linux) import Glibc @@ -87,12 +87,9 @@ internal extension tm { // MARK: - Cross-Platform Support -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) - +#if canImport(Darwin) internal typealias POSIXMicroseconds = __darwin_suseconds_t - #elseif os(Linux) - internal typealias POSIXMicroseconds = __suseconds_t internal func modf(value: Double) -> (Double, Double) { diff --git a/Xcode/BluetoothAccessory.xcodeproj/project.pbxproj b/Xcode/BluetoothAccessory.xcodeproj/project.pbxproj index e67693c..3502f31 100644 --- a/Xcode/BluetoothAccessory.xcodeproj/project.pbxproj +++ b/Xcode/BluetoothAccessory.xcodeproj/project.pbxproj @@ -69,7 +69,7 @@ 6EA074812B95E72D00D31F54 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EA074802B95E72D00D31F54 /* ContentView.swift */; }; 6EA074832B95E72E00D31F54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6EA074822B95E72E00D31F54 /* Assets.xcassets */; }; 6EA074862B95E72E00D31F54 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6EA074852B95E72E00D31F54 /* Preview Assets.xcassets */; }; - 6EA0748B2B95E72E00D31F54 /* Clip.app in Embed App Clips */ = {isa = PBXBuildFile; fileRef = 6EA0747C2B95E72D00D31F54 /* Clip.app */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 6EA0748B2B95E72E00D31F54 /* Clip.app in Embed App Clips */ = {isa = PBXBuildFile; fileRef = 6EA0747C2B95E72D00D31F54 /* Clip.app */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 6EA074912B95E82700D31F54 /* BluetoothAccessory in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074902B95E82700D31F54 /* BluetoothAccessory */; }; 6EA074952B95E82700D31F54 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074942B95E82700D31F54 /* KeychainAccess */; }; 6EA074972B95E82700D31F54 /* DarwinGATT in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074962B95E82700D31F54 /* DarwinGATT */; }; @@ -889,10 +889,7 @@ }; 6EA0748A2B95E72E00D31F54 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - platformFilters = ( - ios, - xros, - ); + platformFilter = ios; target = 6EA0747B2B95E72D00D31F54 /* Clip */; targetProxy = 6EA074892B95E72E00D31F54 /* PBXContainerItemProxy */; }; @@ -1148,11 +1145,12 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = auto; SKIP_INSTALL = YES; - SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1190,10 +1188,11 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = auto; SKIP_INSTALL = YES; - SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Xcode/BluetoothAccessory/TabView.swift b/Xcode/BluetoothAccessory/TabView.swift index bf47e0d..64304c0 100644 --- a/Xcode/BluetoothAccessory/TabView.swift +++ b/Xcode/BluetoothAccessory/TabView.swift @@ -31,11 +31,13 @@ struct AccessoryTabView: View { NavigationView { AccessoriesView(url: $url) .toolbar { + #if os(iOS) Button(action: { setupSheet = true }, label: { Image(systemSymbol: .plus) }) + #endif } if let accessory = url?.accessory, store[cache: accessory] != nil { AccessoryDetailView(accessory: accessory) @@ -83,7 +85,11 @@ struct AccessoryTabView: View { case .setup(let uuid, let keyData): SetupAccessoryView(accessory: uuid, sharedSecret: keyData, success: didSetup) default: + #if os(iOS) SetupAccessoryView(success: didSetup) + #else + EmptyView() + #endif } } } diff --git a/Xcode/BluetoothAccessoryKit/Model/AccessoryManagerFileManager.swift b/Xcode/BluetoothAccessoryKit/Model/AccessoryManagerFileManager.swift index fd231b4..5ac4d4f 100644 --- a/Xcode/BluetoothAccessoryKit/Model/AccessoryManagerFileManager.swift +++ b/Xcode/BluetoothAccessoryKit/Model/AccessoryManagerFileManager.swift @@ -24,9 +24,11 @@ public extension AccessoryManager { do { try await updateCoreDataCache() } catch { assertionFailure("\(error)") } } + #if canImport(CoreSpotlight) && os(iOS) || os(macOS) Task { await updateSpotlight() } + #endif return file } @@ -49,9 +51,11 @@ public extension AccessoryManager { do { try await updateCoreDataCache() } catch { assertionFailure("\(error)") } } + #if canImport(CoreSpotlight) && os(iOS) || os(macOS) Task { await updateSpotlight() } + #endif } } } diff --git a/Xcode/BluetoothAccessoryKit/Views/Detail/NearbyAccessoryView.swift b/Xcode/BluetoothAccessoryKit/Views/Detail/NearbyAccessoryView.swift index 0feeefe..28385da 100644 --- a/Xcode/BluetoothAccessoryKit/Views/Detail/NearbyAccessoryView.swift +++ b/Xcode/BluetoothAccessoryKit/Views/Detail/NearbyAccessoryView.swift @@ -84,7 +84,7 @@ internal extension NearbyAccessoryView { var leftBarButtonItem: some View { if isReloading, canShowActivityIndicator { - #if os(iOS) + #if os(iOS) || os(visionOS) return AnyView( ProgressView() .progressViewStyle(.circular) @@ -106,7 +106,7 @@ internal extension NearbyAccessoryView { }) { Image(systemSymbol: .arrowClockwise) }) - #elseif os(iOS) + #elseif os(iOS) || os(visionOS) return AnyView(EmptyView()) // only pull to refresh supported #endif } diff --git a/Xcode/BluetoothAccessoryKit/Views/Row/AccessoryCharacteristicRow.swift b/Xcode/BluetoothAccessoryKit/Views/Row/AccessoryCharacteristicRow.swift index e34e196..ef6ee55 100644 --- a/Xcode/BluetoothAccessoryKit/Views/Row/AccessoryCharacteristicRow.swift +++ b/Xcode/BluetoothAccessoryKit/Views/Row/AccessoryCharacteristicRow.swift @@ -36,7 +36,16 @@ internal extension AccessoryCharacteristicRow.StateView { var content: some View { switch BluetoothUUID.accessoryCharacteristicType[characteristic.metadata.type] { case .setup: + #if os(iOS) && !APPCLIP return AnyView(AccessoryCharacteristicRow.Setup(accessory: characteristic.accessory)) + #else + return AnyView( + DetailRow( + title: Text(verbatim: characteristic.metadata.name), + detail: detailText + ) + ) + #endif default: return AnyView( DetailRow( diff --git a/Xcode/BluetoothAccessoryKit/Views/Row/SetupCharacteristicRow.swift b/Xcode/BluetoothAccessoryKit/Views/Row/SetupCharacteristicRow.swift index ada44de..37980f1 100644 --- a/Xcode/BluetoothAccessoryKit/Views/Row/SetupCharacteristicRow.swift +++ b/Xcode/BluetoothAccessoryKit/Views/Row/SetupCharacteristicRow.swift @@ -10,6 +10,7 @@ import SwiftUI import Bluetooth import BluetoothAccessory +#if os(iOS) && !APPCLIP public extension AccessoryCharacteristicRow { struct Setup: View { @@ -33,3 +34,4 @@ public extension AccessoryCharacteristicRow { } } } +#endif