-
-
Notifications
You must be signed in to change notification settings - Fork 2
Installation
Latisha. edited this page Dec 27, 2024
·
1 revision
This guide walks you through setting up LibDC-Swift in your iOS or macOS project.
- Xcode 15.0 or later
- Swift 5.10 or later
- iOS 15.0+ / macOS 12.0+
- iOS device with BLE capability
- macOS device with BLE capability
- Physical access to supported dive computer
-
bluetooth-le
capability in your app's entitlements - Privacy usage description for Bluetooth in Info.plist
-
In Xcode, open your project and select File → Add Packages...
-
Enter the package repository URL:
https://latishab/LibDC-Swift.git
-
Select the version rule:
- Up to Next Major (recommended)
- Up to Next Minor
- Exact Version
-
Add the package to your target
- Clone the repository:
git clone https://latishab/LibDC-Swift.git
-
Drag the
LibDC-Swift
folder into your Xcode project -
In the "Add files" dialog:
- Check "Copy items if needed"
- Create groups for added folders
- Add to your target
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app needs Bluetooth to connect to dive computers</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app needs Bluetooth to connect to dive computers</string>
import LibDCSwift
@main
struct YourApp: App {
@StateObject private var bleManager = CoreBluetoothManager.shared
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(bleManager)
}
}
}
import LibDCSwift
struct ContentView: View {
@EnvironmentObject var bleManager: CoreBluetoothManager
@StateObject var diveDataVM = DiveDataViewModel()
var body: some View {
// Your view content
}
}
-
Check Bluetooth permissions:
- Verify Info.plist entries
- Check app permissions in device settings
- Ensure Bluetooth is enabled on device
-
Debug steps:
// Enable detailed logging
Logger.shared.setMinLevel(.debug)
Logger.shared.setShowRawData(true)
-
Device not appearing:
- Ensure device is in pairing mode
- Check device battery level
- Verify device support in documentation
- Go to your iOS bluetooth settings, and forget device for the dive computer you have connected
-
Connection failing:
// Enable connection logging
bleManager.setLogging(enabled: true)
// Monitor connection state
bleManager.$connectedDevice
.sink { device in
if device == nil {
print("Connection lost or failed")
}
}
-
Package Resolution Fails:
- Clean build folder (Shift + Cmd + K)
- Clean package cache:
rm -rf ~/Library/Caches/org.swift.swiftpm/
- Update package references
-
Library Not Found:
- Verify target membership
- Check framework embedding
- Rebuild project
- Missing Bluetooth Permission:
// Check authorization status
if CBCentralManager.authorization == .allowedAlways {
// Proceed with BLE operations
} else {
// Handle unauthorized state
}
- Background Operation Issues:
- Add required background modes to Info.plist
- Implement proper state restoration
After successful installation:
- Review the Usage Guide for basic operations
- Check Device Support for your specific dive computer
- Explore API Reference for detailed documentation
If you encounter issues not covered here:
- Check the GitHub Issues for similar problems
- Create a new issue with:
- Detailed problem description
- Steps to reproduce
- Environment information
- Relevant code snippets