Skip to content

BMR11/SwiftCoreBluetoothDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Core Bluetooth Demo

This repository contains the complete working demos used in the San Diego iOS Developers talk: "Interfacing with Bluetooth Devices in Swift" presented on September 9th, 2025.

🎯 What This Demo Contains

This is a hands-on demonstration of Apple's Core Bluetooth framework in Swift, showing how iOS and macOS devices communicate with each other and with Nordic nRF52 development boards using Bluetooth Low Energy (BLE).

The demos illustrate real-world BLE connectivity patterns with working code you can run, modify, and learn from.

event-flyer-2

Talk Slides Youtube Video


🔑 Live Demo Apps Included

1. MyCoreBluetoothDemo - Central App (iOS/macOS)

  • Complete app using CBCentralManager in Swift
  • Runs on both iOS and macOS with native interfaces
  • Scans and connects to LBS (Light Button Service) peripherals
  • Discovers services & characteristics automatically
  • Reads button state from connected peripherals
  • Controls LED on connected peripherals
  • Clean, modern SwiftUI interface with debug logging

2. MyPeripheral - Peripheral App (iOS/macOS)

  • Complete app using CBPeripheralManager in Swift
  • Runs on both iOS and macOS with native interfaces
  • Advertises LBS (Light Button Service) - Nordic's standard service
  • Simulates button press/release with visual feedback
  • Receives LED control commands from central devices
  • Real-time button state notifications to connected centrals

3. Cross-Platform Communication Matrix

  • iOS ↔ iOS communication (Central ↔ Peripheral)
  • macOS ↔ macOS communication (Central ↔ Peripheral)
  • iOS ↔ macOS communication (Central ↔ Peripheral)
  • iOS/macOS ↔ Nordic nRF52 communication (with LBS service)
  • Implements Nordic's LBS specification for embedded device communication

🎥 Demo Videos


🛠 Requirements

  • Xcode 15+
  • Swift 5.0+
  • iOS 17.5+ / macOS 14.5+
  • Bluetooth Low Energy enabled hardware
  • (Optional) Nordic nRF52 Development Kit with Light Button Service

🖥️ Supported Platforms

  • iOS: iPhone, iPad (Central or Peripheral)
  • macOS: MacBook, iMac (Central or Peripheral)
  • Cross-platform: Any combination of iOS/macOS devices can communicate

🚀 Quick Start - Run the Live Demo

  1. Clone and open the project in Xcode:
git clone https://github.com/BMR11/SwiftCoreBluetoothDemo.git
cd SwiftCoreBluetoothDemo
open SwiftCoreBluetoothDemo.xcodeproj
  1. Run both apps on different devices/simulators:

    • MyCoreBluetoothDemo (Central) - Run on iPhone/iPad/Mac
    • MyPeripheral (Peripheral) - Run on another iPhone/iPad/Mac
  2. Test the LBS connection:

    • Option A - iOS/macOS Peripheral: Start the Peripheral app first (it will begin advertising LBS service)
    • Option B - nRF52 DK Peripheral: Flash the nRF52 DK with Nordic's LBS sample code
    • Start the Central app and tap "Start Scan"
    • Connect to the discovered peripheral
    • Press/release the button on peripheral and see it reflected on central
    • Toggle the LED on central and see it controlled on peripheral!

🔧 Using nRF52 DK as LBS Peripheral

If you have a Nordic nRF52 Development Kit:

  1. Flash the LBS sample to your nRF52 DK using nRF Connect SDK
  2. Build and run the peripheral_lbs sample from Nordic's examples
  3. The nRF52 will advertise the LBS service automatically
  4. Use the Central app to connect and interact with the physical hardware
  5. Press the physical button on the nRF52 to see it reflected in the Central app
  6. Toggle the LED in the Central app to control the physical LED on the nRF52

💡 Perfect for Learning

  • Production-ready code you can study and modify
  • Complete BLE implementation from scanning to data exchange
  • Modern SwiftUI interfaces with proper error handling
  • Nordic nRF52 LBS service - standard for embedded device communication
  • Real-world patterns used in IoT and embedded device applications

📚 Technical References

🎓 Talk Details

"Interfacing with Bluetooth Devices in Swift"
Presented at San Diego iOS Developers
September 9th, 2025

This repository contains the exact working code demonstrated during the talk, ready for you to run, explore, and build upon.


👤 Author: Rajni Gediya
Staff Software Engineer | BLE Medical Device & App Systems


About

This repo is a simple Core Bluetooth demo app in Swift, created to showcase scanning, connecting, and communicating with BLE peripherals. I originally built it as part of a talk, and it serves as a minimal reference for learning or experimenting with BLE on iOS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages