Skip to content

Commit

Permalink
Fixed visionOS compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Mar 5, 2024
1 parent 7c69784 commit 90b9dc7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Sources/BluetoothAccessory/DateComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions Sources/BluetoothAccessory/POSIXTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
17 changes: 8 additions & 9 deletions Xcode/BluetoothAccessory.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -889,10 +889,7 @@
};
6EA0748A2B95E72E00D31F54 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
platformFilters = (
ios,
xros,
);
platformFilter = ios;
target = 6EA0747B2B95E72D00D31F54 /* Clip */;
targetProxy = 6EA074892B95E72E00D31F54 /* PBXContainerItemProxy */;
};
Expand Down Expand Up @@ -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 = "";
};
Expand Down Expand Up @@ -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 = "";
};
Expand Down
6 changes: 6 additions & 0 deletions Xcode/BluetoothAccessory/TabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI
import Bluetooth
import BluetoothAccessory

#if os(iOS) && !APPCLIP
public extension AccessoryCharacteristicRow {

struct Setup: View {
Expand All @@ -33,3 +34,4 @@ public extension AccessoryCharacteristicRow {
}
}
}
#endif

0 comments on commit 90b9dc7

Please sign in to comment.