feat: Simple bluetooth status indication

This commit is contained in:
2026-06-07 18:27:33 +01:00
commit 61bf63fd14
9 changed files with 125 additions and 0 deletions

12
.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
/xtool
*.log

View File

@@ -0,0 +1,5 @@
{
"swiftPM": {
"swiftSDK": "arm64-apple-ios"
}
}

10
Info_extra_tags.plist Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth to connect to devices.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app uses Bluetooth.</string>
</dict>
</plist>

24
Package.swift Normal file
View File

@@ -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"
),
]
)

View File

@@ -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"
}
}
}

View File

@@ -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()
}
}

View File

@@ -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)
}
}
}

19
makefile Normal file
View File

@@ -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

3
xtool.yml Normal file
View File

@@ -0,0 +1,3 @@
version: 1
bundleID: com.example.scoobytag
infoPath: ./Info_extra_tags.plist