Skip to content

Commit d3d2781

Browse files
ky1vstarremonh87
andauthored
Restore support for Xcode 12 (#448)
* Restore support for Xcode 12 * Remove Xcode 13 breaking changes notice from Readme Co-authored-by: Rémon <[email protected]>
1 parent a78dc4e commit d3d2781

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,6 @@ This project uses melos to manage all the packages inside this repo.
178178
Install melos: `dart pub global activate melos`
179179
Setup melos to point to the dependencies in your local folder: `melos bootstrap`
180180

181-
### Xcode 13 breaking changes
182-
183-
Version `4.0.1` added breaking changes for Xcode 13 that are not backwards compatible with Xcode 12. Due to this all users that are not ready to upgrade to Xcode 13 are at adviced to add the following dependency override to the pubspec.yaml of your app untill you are ready to upgrade to the latest Xcode.
184-
185-
```yaml
186-
dependency_overrides:
187-
reactive_ble_mobile: '4.0.0'
188-
```
189-
190181
### FAQ
191182

192183
#### How to handle the BLE undeliverable exception
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#if compiler(<5.5)
2+
import class CoreBluetooth.CBCharacteristic
3+
import class CoreBluetooth.CBService
4+
import class CoreBluetooth.CBPeripheral
5+
6+
// Extensions below are supposed to backport API breaking changes
7+
// in CoreBluetooth framework which Apple introduced with Xcode 13:
8+
//
9+
// ```
10+
// + weak var peripheral: CBPeripheral? { get }
11+
// - unowned(unsafe) var peripheral: CBPeripheral { get }
12+
// ```
13+
//
14+
// Thus this code shadows original property declarations in CoreBluetooth
15+
// and changes their semantics from `unsafe non-optional` to `weak optional`
16+
// to mimic Xcode 13 behaviour.
17+
//
18+
// - Note: This code compiles only when using Xcode 12 and below.
19+
// - SeeAlso: https://forums.swift.org/t/is-unowned-unsafe-t-weak-t-a-breaking-change/49917
20+
21+
extension CBCharacteristic {
22+
@nonobjc
23+
weak var service: CBService? {
24+
return value(forKey: #function) as? CBService
25+
}
26+
}
27+
28+
extension CBService {
29+
@nonobjc
30+
weak var peripheral: CBPeripheral? {
31+
return value(forKey: #function) as? CBPeripheral
32+
}
33+
}
34+
#endif

0 commit comments

Comments
 (0)