commit 61bf63fd1487b50073bbec792de1b149b2e45863 Author: Diogo Cruz Diniz Date: Sun Jun 7 18:27:33 2026 +0100 feat: Simple bluetooth status indication diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9dcddd0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc + +/xtool + +*.log diff --git a/.sourcekit-lsp/config.json b/.sourcekit-lsp/config.json new file mode 100644 index 0000000..e7c9738 --- /dev/null +++ b/.sourcekit-lsp/config.json @@ -0,0 +1,5 @@ +{ + "swiftPM": { + "swiftSDK": "arm64-apple-ios" + } +} diff --git a/Info_extra_tags.plist b/Info_extra_tags.plist new file mode 100644 index 0000000..a78e075 --- /dev/null +++ b/Info_extra_tags.plist @@ -0,0 +1,10 @@ + + + + + NSBluetoothAlwaysUsageDescription + This app uses Bluetooth to connect to devices. + NSBluetoothPeripheralUsageDescription + This app uses Bluetooth. + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..afd682b --- /dev/null +++ b/Package.swift @@ -0,0 +1,24 @@ +// swift-tools-version: 6.0 + +import PackageDescription + +let package = Package( + name: "ScoobyTag", + platforms: [ + .iOS(.v15), + .macOS(.v14), + ], + products: [ + // An xtool project should contain exactly one library product, + // representing the main app. + .library( + name: "ScoobyTag", + targets: ["ScoobyTag"] + ), + ], + targets: [ + .target( + name: "ScoobyTag" + ), + ] +) diff --git a/Sources/scoobytag/BluetoothManager.swift b/Sources/scoobytag/BluetoothManager.swift new file mode 100644 index 0000000..1694d91 --- /dev/null +++ b/Sources/scoobytag/BluetoothManager.swift @@ -0,0 +1,23 @@ +import SwiftUI +import CoreBluetooth + +final class BluetoothManager: NSObject, ObservableObject { + private var centralManager: CBCentralManager! + @Published var status = "Starting..." + + override init() { + super.init() + centralManager = CBCentralManager(delegate: self, queue: nil) + } +} + +extension BluetoothManager: CBCentralManagerDelegate { + func centralManagerDidUpdateState(_ central: CBCentralManager) { + switch central.state { + case .poweredOn: + status = "Bluetooth is on" + default: + status = "Bluetooth unavailable" + } +} +} diff --git a/Sources/scoobytag/ContentView.swift b/Sources/scoobytag/ContentView.swift new file mode 100644 index 0000000..dffd709 --- /dev/null +++ b/Sources/scoobytag/ContentView.swift @@ -0,0 +1,16 @@ +import SwiftUI + +struct ContentView: View { + @EnvironmentObject var bluetoothManager: BluetoothManager + + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundStyle(.tint) + Text("Hello, world!") + Text(bluetoothManager.status) + } + .padding() + } +} diff --git a/Sources/scoobytag/ScoobyTagApp.swift b/Sources/scoobytag/ScoobyTagApp.swift new file mode 100644 index 0000000..ef54c4b --- /dev/null +++ b/Sources/scoobytag/ScoobyTagApp.swift @@ -0,0 +1,13 @@ +import SwiftUI +import CoreBluetooth + +@main +struct ScoobyTagApp: App { + @StateObject private var bluetoothManager = BluetoothManager() + var body: some Scene { + WindowGroup { + ContentView() + .environmentObject(bluetoothManager) + } + } +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..8a395a5 --- /dev/null +++ b/makefile @@ -0,0 +1,19 @@ +.PHONY: all deploy log log_err clean + +all: build + +build: + xtool dev build + +deploy: + xtool dev + +log: + idevicesyslog | grep cooby > out.log + +log_err: + cat out.log | grep rror + +clean: + -rm -rf .build + -rm -rf xtool diff --git a/xtool.yml b/xtool.yml new file mode 100644 index 0000000..6e21ef5 --- /dev/null +++ b/xtool.yml @@ -0,0 +1,3 @@ +version: 1 +bundleID: com.example.scoobytag +infoPath: ./Info_extra_tags.plist