Skip to content

Commit

Permalink
Don't compile SFSafeSymbols for App Clip
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Mar 4, 2024
1 parent 3348b9d commit ac9fc97
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 18 deletions.
8 changes: 0 additions & 8 deletions Xcode/BluetoothAccessory.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
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 */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6EA074912B95E82700D31F54 /* BluetoothAccessory in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074902B95E82700D31F54 /* BluetoothAccessory */; };
6EA074932B95E82700D31F54 /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074922B95E82700D31F54 /* SFSafeSymbols */; };
6EA074952B95E82700D31F54 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074942B95E82700D31F54 /* KeychainAccess */; };
6EA074972B95E82700D31F54 /* DarwinGATT in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074962B95E82700D31F54 /* DarwinGATT */; };
6EA074992B95E82700D31F54 /* GATT in Frameworks */ = {isa = PBXBuildFile; productRef = 6EA074982B95E82700D31F54 /* GATT */; };
Expand Down Expand Up @@ -300,7 +299,6 @@
files = (
6EA074992B95E82700D31F54 /* GATT in Frameworks */,
6EA0749B2B95E82700D31F54 /* CoreDataModel in Frameworks */,
6EA074932B95E82700D31F54 /* SFSafeSymbols in Frameworks */,
6EA0749D2B95E82700D31F54 /* CoreModel in Frameworks */,
6EA074912B95E82700D31F54 /* BluetoothAccessory in Frameworks */,
6EA074952B95E82700D31F54 /* KeychainAccess in Frameworks */,
Expand Down Expand Up @@ -642,7 +640,6 @@
name = Clip;
packageProductDependencies = (
6EA074902B95E82700D31F54 /* BluetoothAccessory */,
6EA074922B95E82700D31F54 /* SFSafeSymbols */,
6EA074942B95E82700D31F54 /* KeychainAccess */,
6EA074962B95E82700D31F54 /* DarwinGATT */,
6EA074982B95E82700D31F54 /* GATT */,
Expand Down Expand Up @@ -1387,11 +1384,6 @@
isa = XCSwiftPackageProductDependency;
productName = BluetoothAccessory;
};
6EA074922B95E82700D31F54 /* SFSafeSymbols */ = {
isa = XCSwiftPackageProductDependency;
package = 6E2C9BC829CF6224002F1B28 /* XCRemoteSwiftPackageReference "SFSafeSymbols" */;
productName = SFSafeSymbols;
};
6EA074942B95E82700D31F54 /* KeychainAccess */ = {
isa = XCSwiftPackageProductDependency;
package = 6E2C9BCE29CF62F3002F1B28 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
appClipInvocationURLString = "https://bluetoothaccessory.com/setup/4359683A-82E9-40A8-9987-977DB87B9040/GRbaLLQstRbblmlxBe6WqMKbSbcRo8k8UrenQ23PfEs"
appClipInvocationURLString = "https://bluetoothaccessory.com/setup/43730062-645B-4AB8-A463-A7924F9172E9/1LWUq5Wgsxb76LdbcV9YdJM12zD-H2hcqp7qIcALrWs"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand All @@ -53,7 +53,7 @@
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
appClipInvocationURLString = "https://bluetoothaccessory.com/setup/4359683A-82E9-40A8-9987-977DB87B9040/GRbaLLQstRbblmlxBe6WqMKbSbcRo8k8UrenQ23PfEs"
appClipInvocationURLString = "https://bluetoothaccessory.com/setup/43730062-645B-4AB8-A463-A7924F9172E9/1LWUq5Wgsxb76LdbcV9YdJM12zD-H2hcqp7qIcALrWs"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
Expand Down
222 changes: 219 additions & 3 deletions Xcode/BluetoothAccessoryKit/Extensions/SFSymbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,45 @@

import Foundation
import BluetoothAccessory
#if canImport(SFSafeSymbols) && !APPCLIP
import SFSafeSymbols
#endif

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public extension AccessoryType {

var symbol: SFSymbol {

guard #available(iOS 16, *) else {
switch self {
case .bridge, .wiFiRouter, .rangeExtender:
return .serverRack
case .doorLock:
return .lockFill
case .lightbulb:
return .lightbulbFill
case .switch, .programmableSwitch:
return .switch2
case .thermostat:
return .thermometer
case .solarPanel:
return .sunMaxFill
case .inverter, .generator, .outlet:
return .boltSquareFill
case .securitySystem:
return .lockShieldFill
case .ipCamera:
return .cameraFill
case .speaker, .audioReceiver:
return .hifispeakerFill
case .television, .televisionSetTopBox:
return .tvInsetFilled
case .televisionStreamingStick:
return .mediastick
default:
return .serverRack
}
}

switch self {
case .other:
return .sensorFill
Expand All @@ -35,7 +68,7 @@ public extension AccessoryType {
case .solarPanel:
return .sunMaxFill
case .switch:
return .switchProgrammable
return .lightswitchOn
case .thermostat:
return .thermometerHigh
case .sensor:
Expand Down Expand Up @@ -90,10 +123,193 @@ public extension AccessoryType {
}
}

// MARK: - SFSymbols

#if DEBUG
import SwiftUI

#if APPCLIP
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
public struct SFSymbol: RawRepresentable, Equatable, Hashable {
public let rawValue: String

public init(rawValue: String) {
self.rawValue = rawValue
}
}

// 1.0 Symbols
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
public extension SFSymbol {

static let exclamationmarkOctagon = SFSymbol(rawValue: "exclamationmark.octagon")

static let exclamationmarkOctagonFill = SFSymbol(rawValue: "exclamationmark.octagon.fill")

static let checkmarkCircleFill = SFSymbol(rawValue: "checkmark.circle.fill")

static let checkmarkCircle = SFSymbol(rawValue: "checkmark.circle")

/// 􀇾
static let exclamationmarkTriangle = SFSymbol(rawValue: "exclamationmark.triangle")

/// 􀇿
static let exclamationmarkTriangleFill = SFSymbol(rawValue: "exclamationmark.triangle.fill")

static let lockFill = SFSymbol(rawValue: "lock.fill")

/// 􀛭
static let lightbulb = SFSymbol(rawValue: "lightbulb")

/// 􀛮
static let lightbulbFill = SFSymbol(rawValue: "lightbulb.fill")

/// 􀇬
static let thermometer = SFSymbol(rawValue: "thermometer")

/// 􀆮
static let sunMaxFill = SFSymbol(rawValue: "sun.max.fill")

static let lockShieldFill = SFSymbol(rawValue: "lock.shield.fill")

static let cameraFill = SFSymbol(rawValue: "camera.fill")

static let hifispeakerFill = SFSymbol(rawValue: "hifispeaker.fill")


}

// 2.0 Symbols
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public extension SFSymbol {

static let serverRack = SFSymbol(rawValue: "server.rack")

static let switch2 = SFSymbol(rawValue: "switch.2")
}

// 3.0 Symbols
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public extension SFSymbol {

static let boltSquareFill = SFSymbol(rawValue: "bolt.square.fill")

static let tvInsetFilled = SFSymbol(rawValue: "tv.inset.filled")

static let mediastick = SFSymbol(rawValue: "mediastick")

}

// 4.0 Symbols
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
public extension SFSymbol {

static let sensorFill = SFSymbol(rawValue: "sensor.fill")

static let fanFloorFill = SFSymbol(rawValue: "fan.floor.fill")

static let doorGarageClosed = SFSymbol(rawValue: "door.garage.closed")

static let lightbulbLedFill = SFSymbol(rawValue: "lightbulb.led.fill")

static let poweroutletTypeBFill = SFSymbol(rawValue: "poweroutlet.type.b.fill")

static let boltBatteryblockFill = SFSymbol(rawValue: "bolt.batteryblock.fill")

static let switchProgrammable = SFSymbol(rawValue: "switch.programmable")

static let lightswitchOn = SFSymbol(rawValue: "lightswitch.on")

static let lightswitchOnFill = SFSymbol(rawValue: "lightswitch.on.fill")

static let thermometerHigh = SFSymbol(rawValue: "thermometer.high")

static let lightBeaconMaxFill = SFSymbol(rawValue: "light.beacon.max.fill")

static let doorLeftHandClosed = SFSymbol(rawValue: "door.left.hand.closed")

static let windowVerticalClosed = SFSymbol(rawValue: "window.vertical.closed")

static let windowShadeOpen = SFSymbol(rawValue: "window.shade.open")

static let wifiRouterFill = SFSymbol(rawValue: "wifi.router.fill")

static let webCameraFill = SFSymbol(rawValue: "web.camera.fill")

static let videoDoorbellFill = SFSymbol(rawValue: "video.doorbell.fill")

static let airPurifierFill = SFSymbol(rawValue: "air.purifier.fill")

static let heaterVerticalFill = SFSymbol(rawValue: "heater.vertical.fill")

static let airConditionerHorizontalFill = SFSymbol(rawValue: "air.conditioner.horizontal.fill")

static let humidifierAndDropletsFill = SFSymbol(rawValue: "humidifier.and.droplets.fill")

static let dehumidifierFill = SFSymbol(rawValue: "dehumidifier.fill")

static let sprinklerAndDropletsFill = SFSymbol(rawValue: "sprinkler.and.droplets.fill")

static let spigotFill = SFSymbol(rawValue: "spigot.fill")

static let showerFill = SFSymbol(rawValue: "shower.fill")

static let hifireceiverFill = SFSymbol(rawValue: "hifireceiver.fill")

static let tvAndMediaboxFill = SFSymbol(rawValue: "tv.and.mediabox.fill")


}

@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public extension Label where Title == Text, Icon == Image {

/// Creates a label with a system symbol image and a title generated from a
/// localized string.
///
/// - Parameter systemSymbol: The `SFSymbol` describing this image. No image is shown if nil is passed.
init(_ titleKey: LocalizedStringKey, systemSymbol: SFSymbol?) {
self.init(titleKey, systemImage: systemSymbol?.rawValue ?? "")
}

/// Creates a label with a system symbol image and a title generated from a
/// string.
///
/// - Parameter systemSymbol: The `SFSymbol` describing this image. No image is shown if nil is passed.
@_disfavoredOverload
init<S>(_ title: S, systemSymbol: SFSymbol?) where S : StringProtocol {
self.init(title, systemImage: systemSymbol?.rawValue ?? "")
}
}

@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
public extension SwiftUI.Image {

/// Creates a system symbol image.
///
/// - Parameter systemSymbol: The `SFSymbol` describing this image.
init(systemSymbol: SFSymbol) {
self.init(systemName: systemSymbol.rawValue)
}

// AppIntents serves as a placeholder SDK to check if the iOS 16.0, macOS 13.0, ... SDKs are available
#if canImport(AppIntents)
/// Creates a system symbol image with a variable value.
///
/// - Parameter systemSymbol: The `SFSymbol` describing this image.
/// - Parameter variableValue: An optional value between 0.0 and 1.0 that the rendered image can use to customize its appearance, if specified. If the symbol doesn’t support variable values, this parameter has no effect. Use the SF Symbols app to look up which symbols support variable values.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
init(systemSymbol: SFSymbol, variableValue: Double?) {
self.init(systemName: systemSymbol.rawValue, variableValue: variableValue)
}
#endif
}

#endif

// MARK: - Previews

#if DEBUG

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
struct AccessorySymbol_Previews: PreviewProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import Foundation
import SwiftUI
import Bluetooth
import BluetoothAccessory
#if canImport(SFSafeSymbols)
import SFSafeSymbols
#endif

public struct AccessoryDetailView: View {

Expand Down Expand Up @@ -126,7 +129,6 @@ internal extension AccessoryDetailView {
ScrollView {
VStack(alignment: .leading, spacing: 16) {

if #available(iOS 16, macOS 13, *) {
VStack {
Spacer()
HStack {
Expand All @@ -140,7 +142,7 @@ internal extension AccessoryDetailView {
Spacer()
}
.frame(maxHeight: 150)
}

/*
ForEach(services) { service in
Section(service.name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ internal extension SetupAccessoryView {
ScrollView {
VStack(alignment: .leading, spacing: 16) {

if #available(iOS 16, macOS 13, *) {
Spacer()
HStack {
Spacer()
Expand All @@ -255,7 +254,6 @@ internal extension SetupAccessoryView {
Spacer()
}
Spacer()
}

HStack {
Text("Name:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Bluetooth
import GATT
import DarwinGATT
import BluetoothAccessory
import SFSafeSymbols

/// List of Paired Accessories
public struct AccessoriesView: View {
Expand Down

0 comments on commit ac9fc97

Please sign in to comment.