Skip to content

Commit 49ef869

Browse files
authored
Merge pull request #40 from fingerprintjs/topic/simulator-core-telephony-error-messages
Fix Core Telephony API use causing OS-level error msgs on iOS Simulator On iOS Simulator, the `com.apple.commcenter.coretelephony` XPC Service appears to be unavailable and an attempt to communicate with it produces the following error messages originating from `com.apple.CoreTelephony` subsystem. ``` The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process. ``` These error messages pollute the app logs that get printed to the debug console, which makes the debugging inconvenient. To resolve the above inconvenience, the code that uses `CTTelephonyNetworkInfo` API is now conditionally compiled, such that the API is only called when targeting a physical iDevice.
2 parents 70fa210 + 59dc036 commit 49ef869

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/FingerprintJS/Harvesters/CellularNetworkInfoHarvester/CellularNetworkInfoHarvester.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,19 @@ struct CellularNetworkInfoHarvester {
2121
#if os(iOS)
2222
extension CellularNetworkInfoHarvester {
2323

24+
#if !targetEnvironment(simulator)
2425
init() {
2526
self.init(cellularServiceInfoProvider: CTTelephonyNetworkInfo())
2627
}
28+
#else
29+
private struct CellularServiceInfoProviderFake: CellularServiceInfoProviding {
30+
var cellularProviders: [CarrierInfoProviding] { [] }
31+
}
32+
33+
init() {
34+
self.init(cellularServiceInfoProvider: CellularServiceInfoProviderFake())
35+
}
36+
#endif
2737
}
2838

2939
extension CellularNetworkInfoHarvester: CellularNetworkInfoHarvesting {

0 commit comments

Comments
 (0)