This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
BeaconScanner is a macOS desktop application written in Objective-C for scanning and detecting iBeacon devices via Bluetooth Low Energy (BLE). It fills a gap in Apple's macOS ecosystem by providing iBeacon client support that was only available on iOS.
# Install dependencies (requires CocoaPods)
pod install
# Open in Xcode (always use workspace, not project)
open BeaconScanner.xcworkspace
# Build: Cmd+B in Xcode
# Run: Cmd+R in Xcode
# Test: Cmd+U in Xcode- ReactiveCocoa - Reactive programming framework for signal-based communication
- BlocksKit - Block-based API extensions
- libextobjc - Objective-C extensions (@weakify/@strongify macros)
HGBeaconScanner (Singleton)
- Central manager for all Bluetooth scanning operations
- Instantiates
CBCentralManageron a dedicated dispatch queue - Exposes
beaconSignal(RACSignal) for detected beacons - Exposes
bluetoothStateSignalfor Bluetooth state changes - Implements
CBCentralManagerDelegateprotocol
HGBeacon (Model)
- Represents a single iBeacon with UUID, major, minor, measuredPower, RSSI
- Parses 25-byte iBeacon manufacturer data from BLE advertisements
- Static factory methods:
beaconWithAdvertisementDataDictionary:andbeaconWithManufacturerAdvertisementData:
HGBeaconViewController (UI Controller)
- Manages NSTableView displaying detected beacons
- Subscribes to beacon signals and updates UI reactively
- Implements housekeeping to remove stale beacons (15-second timeout)
- Supports beacon recording feature via HGBeaconHistory
HGBeaconScannerreceives BLE advertisements viaCBCentralManagerDelegateHGBeaconparses manufacturer data to extract iBeacon payload- Valid beacons are emitted via
beaconSignal(RACSubject) - Subscribers (like
HGBeaconViewController) receive and process beacon events
The 25-byte payload format:
- Bytes 0-1: Company ID (0x4C = Apple)
- Byte 2: Data type (0x02)
- Byte 3: Data length (0x15 = 21 bytes)
- Bytes 4-19: Proximity UUID (128-bit)
- Bytes 20-21: Major (16-bit, big-endian)
- Bytes 22-23: Minor (16-bit, big-endian)
- Byte 24: Measured Power (calibrated RSSI at 1m)
- Reactive subscriptions: Use RACSignal subscriptions for beacon events, not delegate callbacks
- Signal filtering: Filter
beaconSignalby UUID to listen for specific beacons - Stale beacon cleanup: Periodically purge beacons not heard from recently (see HGBeaconViewController for implementation)