PureSwift / GATT

Bluetooth Generic Attribute Profile (GATT) for Swift (Supports Linux)
MIT License
64 stars 18 forks source link

GATTCentral with BluetoothLinux' HostController yields linker error #24

Closed fwcd closed 3 years ago

fwcd commented 3 years ago

A simple Swift project using the latest versions of BluetoothLinux and GATT with the following main script

import Bluetooth
import BluetoothLinux
import GATT

let hostController = BluetoothLinux.HostController.default!
let central = GATTCentral<BluetoothLinux.HostController, BluetoothLinux.L2CAPSocket>(hostController: hostController)

causes linking to fail:

<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26ATTMaximumTransmissionUnitV3maxACvgZ'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
link command failed with exit code 1 (use -v to see invocation)
colemancda commented 3 years ago

I assume this is on Swift 5.3

colemancda commented 3 years ago

Your final executable also needs to link to BluetoothGATT, BluetoothGAP, and BluetoothHCI on macOS and Linux

colemancda commented 3 years ago

@fwcd Add this to your CLI tool's dependencies:

.target(
            name: "testtool",
            dependencies: [
                "Bluetooth",
                .product(
                    name: "BluetoothGAP",
                    package: "Bluetooth"
                ),
                .product(
                    name: "BluetoothGATT",
                    package: "Bluetooth"
                ),
                .product(
                    name: "BluetoothHCI",
                    package: "Bluetooth"
                ),
                .product(
                    name: "BluetoothLinux",
                    package: "BluetoothLinux",
                    condition: .when(platforms: [.linux])
                ),
                .product(
                    name: "DarwinGATT",
                    package: "GATT",
                    condition: .when(platforms: [.macOS])
                ),
                .product(
                    name: "BluetoothDarwin",
                    package: "BluetoothDarwin",
                    condition: .when(platforms: [.macOS])
                )
            ]
        )