Skip to content

Commit 4ade216

Browse files
authored
fix iOS issues with missing native module (#15)
1 parent 6eae178 commit 4ade216

File tree

5 files changed

+25
-83
lines changed

5 files changed

+25
-83
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To get started with the project, run `yarn` in the root directory to install the
1818
yarn
1919
```
2020

21-
To run the wearos and mobile apps follow this [instructions][1].
21+
To run the wearos and android mobile apps follow this [instructions][1], for iOS follow the same steps and use `pod install` and `yarn ios`.
2222

2323
[1]: https://github.com/fabOnReact/react-native-wear-connectivity?tab=readme-ov-file#how-to-create-a-wearos-app-using-react-native
2424

example/ios/Podfile.lock

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
PODS:
2-
- AppAuth (1.6.2):
3-
- AppAuth/Core (= 1.6.2)
4-
- AppAuth/ExternalUserAgent (= 1.6.2)
5-
- AppAuth/Core (1.6.2)
6-
- AppAuth/ExternalUserAgent (1.6.2):
7-
- AppAuth/Core
82
- boost (1.83.0)
93
- CocoaAsyncSocket (7.6.5)
104
- DoubleConversion (1.1.6)
@@ -74,14 +68,6 @@ PODS:
7468
- FlipperKit/FlipperKitNetworkPlugin
7569
- fmt (6.2.1)
7670
- glog (0.3.5)
77-
- GoogleSignIn (7.0.0):
78-
- AppAuth (~> 1.5)
79-
- GTMAppAuth (< 3.0, >= 1.3)
80-
- GTMSessionFetcher/Core (< 4.0, >= 1.1)
81-
- GTMAppAuth (2.0.0):
82-
- AppAuth/Core (~> 1.6)
83-
- GTMSessionFetcher/Core (< 4.0, >= 1.5)
84-
- GTMSessionFetcher/Core (3.1.1)
8571
- hermes-engine (0.73.4):
8672
- hermes-engine/Pre-built (= 0.73.4)
8773
- hermes-engine/Pre-built (0.73.4)
@@ -958,14 +944,6 @@ PODS:
958944
- React-Mapbuffer (0.73.4):
959945
- glog
960946
- React-debug
961-
- react-native-config (1.5.1):
962-
- react-native-config/App (= 1.5.1)
963-
- react-native-config/App (1.5.1):
964-
- React-Core
965-
- react-native-wear-connectivity (0.1.0):
966-
- glog
967-
- RCT-Folly (= 2022.05.16.00)
968-
- React-Core
969947
- React-nativeconfig (0.73.4)
970948
- React-NativeModulesApple (0.73.4):
971949
- glog
@@ -1133,9 +1111,6 @@ PODS:
11331111
- React-jsi (= 0.73.4)
11341112
- React-logger (= 0.73.4)
11351113
- React-perflogger (= 0.73.4)
1136-
- RNGoogleSignin (11.0.0):
1137-
- GoogleSignIn (~> 7.0)
1138-
- React-Core
11391114
- SocketRocket (0.6.1)
11401115
- Yoga (1.14.0)
11411116

@@ -1192,8 +1167,6 @@ DEPENDENCIES:
11921167
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector-modern`)
11931168
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
11941169
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
1195-
- react-native-config (from `../node_modules/react-native-config`)
1196-
- react-native-wear-connectivity (from `../..`)
11971170
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
11981171
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
11991172
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@@ -1214,12 +1187,10 @@ DEPENDENCIES:
12141187
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
12151188
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
12161189
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
1217-
- "RNGoogleSignin (from `../node_modules/@react-native-google-signin/google-signin`)"
12181190
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
12191191

12201192
SPEC REPOS:
12211193
trunk:
1222-
- AppAuth
12231194
- CocoaAsyncSocket
12241195
- Flipper
12251196
- Flipper-Boost-iOSX
@@ -1230,9 +1201,6 @@ SPEC REPOS:
12301201
- Flipper-PeerTalk
12311202
- FlipperKit
12321203
- fmt
1233-
- GoogleSignIn
1234-
- GTMAppAuth
1235-
- GTMSessionFetcher
12361204
- libevent
12371205
- OpenSSL-Universal
12381206
- SocketRocket
@@ -1293,10 +1261,6 @@ EXTERNAL SOURCES:
12931261
:path: "../node_modules/react-native/ReactCommon/logger"
12941262
React-Mapbuffer:
12951263
:path: "../node_modules/react-native/ReactCommon"
1296-
react-native-config:
1297-
:path: "../node_modules/react-native-config"
1298-
react-native-wear-connectivity:
1299-
:path: "../.."
13001264
React-nativeconfig:
13011265
:path: "../node_modules/react-native/ReactCommon"
13021266
React-NativeModulesApple:
@@ -1337,13 +1301,10 @@ EXTERNAL SOURCES:
13371301
:path: "../node_modules/react-native/ReactCommon/react/utils"
13381302
ReactCommon:
13391303
:path: "../node_modules/react-native/ReactCommon"
1340-
RNGoogleSignin:
1341-
:path: "../node_modules/@react-native-google-signin/google-signin"
13421304
Yoga:
13431305
:path: "../node_modules/react-native/ReactCommon/yoga"
13441306

13451307
SPEC CHECKSUMS:
1346-
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
13471308
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
13481309
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
13491310
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
@@ -1359,9 +1320,6 @@ SPEC CHECKSUMS:
13591320
FlipperKit: 37525a5d056ef9b93d1578e04bc3ea1de940094f
13601321
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
13611322
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
1362-
GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842
1363-
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
1364-
GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72
13651323
hermes-engine: b2669ce35fc4ac14f523b307aff8896799829fe2
13661324
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
13671325
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
@@ -1386,8 +1344,6 @@ SPEC CHECKSUMS:
13861344
React-jsinspector: 9ac353eccf6ab54d1e0a33862ba91221d1e88460
13871345
React-logger: 0a57b68dd2aec7ff738195f081f0520724b35dab
13881346
React-Mapbuffer: 63913773ed7f96b814a2521e13e6d010282096ad
1389-
react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8
1390-
react-native-wear-connectivity: 218d8a95c3fcec75a3c49ee0a3ac729d8eb471b2
13911347
React-nativeconfig: d7af5bae6da70fa15ce44f045621cf99ed24087c
13921348
React-NativeModulesApple: 0123905d5699853ac68519607555a9a4f5c7b3ac
13931349
React-perflogger: 8a1e1af5733004bdd91258dcefbde21e0d1faccd
@@ -1408,7 +1364,6 @@ SPEC CHECKSUMS:
14081364
React-runtimescheduler: ed48e5faac6751e66ee1261c4bd01643b436f112
14091365
React-utils: 6e5ad394416482ae21831050928ae27348f83487
14101366
ReactCommon: 840a955d37b7f3358554d819446bffcf624b2522
1411-
RNGoogleSignin: fc408799f1990a12497a32f64280c0fe353ffcc1
14121367
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
14131368
Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70
14141369

src/index.tsx

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { NativeModules, Platform } from 'react-native';
2-
import { watchEvents, watchEventsMock } from './subscriptions';
3-
import { sendMessage, sendMessageMock } from './messages';
4-
import type { WatchEvents } from './types';
5-
import type {
6-
ReplyCallback,
7-
ErrorCallback,
8-
SendMessage,
9-
} from './NativeWearConnectivity';
2+
import { watchEvents } from './subscriptions';
3+
import { sendMessage } from './messages';
4+
import type { ReplyCallback, ErrorCallback } from './NativeWearConnectivity';
105

116
const LINKING_ERROR =
127
`The package 'react-native-wear-connectivity' doesn't seem to be linked. Make sure: \n\n` +
@@ -32,20 +27,5 @@ const WearConnectivity = WearConnectivityModule
3227
}
3328
);
3429

35-
let sendMessageExport: SendMessage;
36-
let watchEventsExport: WatchEvents;
37-
38-
if (Platform.OS === 'ios') {
39-
sendMessageExport = sendMessageMock;
40-
watchEventsExport = watchEventsMock;
41-
} else {
42-
sendMessageExport = sendMessage;
43-
watchEventsExport = watchEvents;
44-
}
45-
46-
export {
47-
sendMessageExport as sendMessage,
48-
watchEventsExport as watchEvents,
49-
WearConnectivity,
50-
};
30+
export { sendMessage, watchEvents, WearConnectivity };
5131
export type { ReplyCallback, ErrorCallback };

src/messages.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Platform } from 'react-native';
12
import type { SendMessage, Payload } from './NativeWearConnectivity';
23
import { WearConnectivity } from './index';
34
import { LIBRARY_NAME, IOS_NOT_SUPPORTED_WARNING } from './constants';
@@ -30,4 +31,9 @@ const sendMessage: SendMessage = (message, cb, errCb) => {
3031
const sendMessageMock: SendMessage = () =>
3132
console.warn(LIBRARY_NAME + 'message' + IOS_NOT_SUPPORTED_WARNING);
3233

33-
export { sendMessage, sendMessageMock };
34+
let sendMessageExport: SendMessage = sendMessageMock;
35+
if (Platform.OS !== 'ios') {
36+
sendMessageExport = sendMessage;
37+
}
38+
39+
export { sendMessageExport as sendMessage };

src/subscriptions.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { NativeModules, NativeEventEmitter } from 'react-native';
1+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
22
import type { AddListener, WatchEvents } from './types';
33
import { LIBRARY_NAME, IOS_NOT_SUPPORTED_WARNING } from './constants';
44

55
const _addListener: AddListener = (event, cb) => {
6+
const nativeWatchEventEmitter = new NativeEventEmitter(
7+
NativeModules.AndroidWearCommunication
8+
);
69
if (!event) {
710
throw new Error('Must pass event');
811
}
@@ -18,23 +21,21 @@ const _addListener: AddListener = (event, cb) => {
1821
return () => sub.remove();
1922
};
2023

21-
const nativeWatchEventEmitter = new NativeEventEmitter(
22-
NativeModules.AndroidWearCommunication
23-
);
24-
2524
const _addListenerMock: AddListener = () => {
2625
console.warn(LIBRARY_NAME + 'watchEvents' + IOS_NOT_SUPPORTED_WARNING);
2726
return () => {};
2827
};
2928

30-
const watchEventsMock: WatchEvents = {
29+
let watchEvents: WatchEvents = {
3130
addListener: _addListenerMock,
32-
on: _addListener,
31+
on: _addListenerMock,
3332
};
3433

35-
const watchEvents: WatchEvents = {
36-
addListener: _addListener,
37-
on: _addListener,
38-
};
34+
if (Platform.OS !== 'ios') {
35+
watchEvents = {
36+
addListener: _addListener,
37+
on: _addListener,
38+
};
39+
}
3940

40-
export { watchEvents, watchEventsMock };
41+
export { watchEvents };

0 commit comments

Comments
 (0)