{"id":21373961,"url":"https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock","last_synced_at":"2025-07-13T08:31:51.353Z","repository":{"id":40412235,"uuid":"244843514","full_name":"NordicSemiconductor/IOS-CoreBluetooth-Mock","owner":"NordicSemiconductor","description":"Mocking library for CoreBluetooth framework.","archived":false,"fork":false,"pushed_at":"2024-02-19T19:46:17.000Z","size":3442,"stargazers_count":211,"open_issues_count":3,"forks_count":47,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-04-14T06:10:42.348Z","etag":null,"topics":["ble","bluetooth-low-energy","corebluetooth","mock","mocking-framework","nrf5x"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NordicSemiconductor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-04T08:13:48.000Z","updated_at":"2024-06-18T21:29:35.906Z","dependencies_parsed_at":"2024-06-18T21:29:26.547Z","dependency_job_id":"74f9766b-4e4a-42b1-92f9-13b72aa9b7dc","html_url":"https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock","commit_stats":{"total_commits":220,"total_committers":18,"mean_commits":"12.222222222222221","dds":"0.11818181818181817","last_synced_commit":"b522df5fc0eae2a4ccea1bd8dc732265003a48a3"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NordicSemiconductor%2FIOS-CoreBluetooth-Mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NordicSemiconductor%2FIOS-CoreBluetooth-Mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NordicSemiconductor%2FIOS-CoreBluetooth-Mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NordicSemiconductor%2FIOS-CoreBluetooth-Mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NordicSemiconductor","download_url":"https://codeload.github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225868484,"owners_count":17537048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ble","bluetooth-low-energy","corebluetooth","mock","mocking-framework","nrf5x"],"created_at":"2024-11-22T08:29:36.866Z","updated_at":"2024-11-22T08:29:59.996Z","avatar_url":"https://github.com/NordicSemiconductor.png","language":"Swift","funding_links":[],"categories":["OOM-Leaks-Crash"],"sub_categories":["Bluetooth"],"readme":"# Core Bluetooth Mock\n\n![Version number](https://img.shields.io/cocoapods/v/CoreBluetoothMock) \n[![Platform](https://img.shields.io/cocoapods/p/CoreBluetoothMock.svg?style=flat)](https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![SPM compatible](https://img.shields.io/badge/SPM-compatible-green?style=flat)](https://swift.org/package-manager)\n\nThe *Core Bluetooth Mock* library was designed to emulate *Core Bluetooth* objects, providing easy way to test \nBluetooth-enabled apps. As the native Bluetooth API is not supported on a simulator, using this library you can run, test \nand take screenshots of such apps without the need of a physical phone or tablet. You may also start working on the\niOS app when your peripheral is still under development.\n\n### Core Bluetooth?\n\nThe [Core Bluetooth](https://developer.apple.com/documentation/corebluetooth) framework provides the classes needed \nfor your apps to communicate with Bluetooth-equipped low energy (LE) wireless technology. It requires an iPhone or iPad to \nwork making Bluetooth-enabled apps difficult to test. As the documentation states:\n\n\u003e Don’t subclass any of the classes of the Core Bluetooth framework. Overriding these classes isn’t supported and results in \n   undefined behavior.\n\n### Core Bluetooth Mock!\n\nThe *Core Bluetooth Mock* library defines a number of **CBM...** classes and constants, that wrap or imitate the corresponding\n**CB...** counterparts from *Core Bluetooth* framework. For example, `CBMCentralManager` has the same API and \nbehavior as `CBCentralManager`, etc. On physical iDevices all calls to `CBMCentralManager` and `CBMPeripheral` are\nforwarded to their native equivalents, but on a simulator a user defined mock implementation is used. \n\n## Requirements\n\nThe *Core Bluetooth Mock* library is available only in *Swift*, and compatible with \n* iOS 12.0+[^1], \n* macOS 10.14+, \n* tvOS 12.0+[^1],\n* watchOS 4.0+\n\n(with some features available only on newer platforms).\n\n\u003e [!Note]\n\u003e For projects running Objective-C we recommend https://github.com/Rightpoint/RZBluetooth library.\n\n[^1]: Xcode 15 dropped support for iOS 9.0 and tvOS 9.0 in simulator. Now the minimum supported version is 12.0 for both platforms.\n\n## Installation\n\nThe library support [CocoaPods](https://github.com/CocoaPods/CocoaPods), [Carthage](https://github.com/Carthage/Carthage) and \n[Swift Package Manager](https://swift.org/package-manager).\n\n\u003cdetails\u003e\n   \u003csummary\u003eCocoaPods\u003c/summary\u003e\n\n- Create/Update your **Podfile** with the following contents\n\n    ```ruby\n    target 'YourAppTargetName' do\n        pod 'CoreBluetoothMock'\n    end\n    ```\n\n- Install dependencies\n\n    ```bash\n    pod install\n    ```\n\n- Open the newly created `.xcworkspace`\n\u003c/details\u003e\n\u003cdetails\u003e\n   \u003csummary\u003eCarthage\u003c/summary\u003e\n   \n- Create a new **Cartfile** in your project's root with the following contents\n\n    ```\n    github \"https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock\" ~\u003e x.y // Replace x.y with your required version\n    ```\n    \n- Build with carthage\n\n    ```bash\n    carthage update --platform iOS // also supported are tvOS, watchOS and macOS\n    ```\n\n- Copy the **CoreBluetoothMock.framework** from *Carthage/Build* to your project and follow [instructions from Carthage](https://github.com/Carthage/Carthage).\n\u003c/details\u003e\n\u003cdetails\u003e\n   \u003csummary\u003eSwift Package Manager\u003c/summary\u003e\n\n- In Xcode: *File -\u003e Swift Packages -\u003e Add package dependency*, \ntype *https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock.git* and set required version, branch or commit.\n\n- If you have *Swift.package* file, include the following dependency:\n  ```swift\n  dependencies: [\n      // [...]\n      .package(name: \"CoreBluetoothMock\", \n               url: \"https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock.git\", \n               .upToNextMajor(from: \"x.y\")) // Replace x.y with your required version\n  ]\n  ```\n  and add it to your target:\n  ```swift\n  targets: [\n      // [...]\n      .target(\n          name: \"\u003cYour target name\u003e\",\n          dependencies: [\"CoreBluetoothMock\"]),\n  ]\n  ```\n\u003c/details\u003e\n\n## Documentation\n\nThe documentation of the library is available [here](https://nordicsemiconductor.github.io/IOS-CoreBluetooth-Mock/documentation/corebluetoothmock).\n\n## Migration from *CoreBluetooth*\n\nMigration example is available [here](https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock-Example).\nSee [Pull Request #1](https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock-Example/pull/1) for \nstep-by-step guide.\n\n\u003e [!Note]\n\u003e The migration example application currently does not use mocks in tests. \nFor that, check out the **Example** folder in this repository with *nRF Blinky* app, which is\nusing mock peripherals in Unit Tests and UI Tests. See below.\n\n# Sample application: nRF Blinky\n\nnRF Blinky is an example app targeted towards newcomer BLE developers, and also demonstrating the use \nof *Core Bluetooth Mock* library. This application controls an LED on an\n[nRF5DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits)\nand receive notifications whenever the button on the kit is pressed and released.\n\nThe mock implementation is used in Unit tests and UI tests. \nSee [AppDelegate.swift](Example/nRFBlinky/AppDelegate.swift) where the mock environment is set up and\nand [UITests.swift](Example/Tests) and [UITests.swift](Example/UI%20Tests/UITests.swift) classes.\n\nThe mock peripherals are defined in [MockPeripherals.swift](Example/nRFBlinky/MockPeripherals.swift).\n\n### Nordic LED and Button Service\n\nA simplified proprietary service by Nordic Semiconductor, containing two characteristics one to control LED3 and Button1:\n- Service UUID: **`00001523-1212-EFDE-1523-785FEABCD123`**\n  - First characteristic controls the LED state (On/Off).\n    - UUID: **`00001525-1212-EFDE-1523-785FEABCD123`**\n    - Value: **`1`** =\u003e LED On\n    - Value: **`0`** =\u003e LED Off\n  - Second characteristic notifies central of the button state on change (Pressed/Released).\n    - UUID: **`00001524-1212-EFDE-1523-785FEABCD123`**\n    - Value: **`1`** =\u003e Button Pressed\n    - Value: **`0`** =\u003e Button Released\n  \n  For full specification, check out \n  [documentation](https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/ble_sdk_app_blinky.html?cp=8_1_4_2_2_3).\n\n### Requirements\n\n- An iOS device with BLE capabilities, or a simulator (to run the mock).\n- A [Development Kit](https://www.nordicsemi.com/Software-and-Tools/Development-Kits) (unless testing mock).\n- The Blinky example firmware to flash on the Development Kit. For your convenience, we have bundled two firmwares in this project under the Firmwares directory.\n- To get the latest firmwares and check the source code, you may go directly to our [Developers website](http://developer.nordicsemi.com/nRF5_SDK/) and download the SDK version you need, then you can find the source code and hex files to the blinky demo in the directory `/examples/ble_peripheral/ble_app_blinky/`\n- The LBS (LED Button Service) is also supported in nRF Connect SDK: [here](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_lbs/README.html).\n-  More information about the nRFBlinky example firmware can be found in the [documentation](https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/ble_sdk_app_blinky.html?cp=8_1_4_2_2_3).\n\n### Installation and usage\n\n- Prepare your Development kit.\n  - Plug in the Development Kit to your computer via USB.\n  - Power On the Development Kit.\n  - The Development Kit will now appear as a Mass storage device.\n  - Drag (or copy/paste) the appropriate HEX file onto that new device.\n  - The Development Kit LEDs will flash and it will disconnect and reconnect.\n  - The Development Kit is now ready and flashed with the nRFBlinky example firmware.\n\n- Start Xcode and run build the project against your target iOS Device (**Note:** BLE is not available in the iOS simulator, so the iOS device is a requirement to test with real hardware).\n  - Launch the **nRF Blinky** app on your iOS device.\n  - The app will start scanning for nearby peripherals.\n  - Select the **Nordic_Blinky** peripheral that appears on screen (**Note:** if the peripheral does not show up, ensure that it's powered on and functional).\n  - Your iOS device will now connect to the peripheral and state is displayed on the screen.\n  - Changing the value of the Toggle switch will turn LED 3 on or off.\n  - Pressing Button 1 on the Development Kit will show the button state as Pressed on the app.\n  - Releasing Button 1 will show the state as Released on the App.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNordicSemiconductor%2FIOS-CoreBluetooth-Mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNordicSemiconductor%2FIOS-CoreBluetooth-Mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNordicSemiconductor%2FIOS-CoreBluetooth-Mock/lists"}