Skip to content

Commit 63ec450

Browse files
authored
Merge pull request #629 from Iterable/expo/MOB-11175-make-rn-sdk-compatible-with-expo
[MOB-11175] make-rn-sdk-compatible-with-expo
2 parents c63b9f7 + bf51fd5 commit 63ec450

21 files changed

+224
-148
lines changed

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18
1+
v20.19.0

babel.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
presets: [
3-
['module:react-native-builder-bob/babel-preset', { modules: 'commonjs' }],
4-
],
2+
presets: ['module:react-native-builder-bob/babel-preset'],
53
};

example/Gemfile

+8
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ ruby ">= 2.6.10"
66
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
77
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
88
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'
10+
gem 'concurrent-ruby', '< 1.3.4'
11+
12+
# Ruby 3.4.0 has removed some libraries from the standard library.
13+
gem 'bigdecimal'
14+
gem 'logger'
15+
gem 'benchmark'
16+
gem 'mutex_m'

example/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,23 @@ There are two ways to fix this:
203203
Run `bundle install` in the _example app directory_. You can also try running
204204
it in _ios_ in the _example app directory_.
205205

206+
## Error: `uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger`
207+
208+
This is a known issue with Ruby 3.4.0. You can fix it by running the following:
209+
```bash
210+
gem install xcodeproj -v '< 1.26.0'
211+
gem install concurrent-ruby -v '< 1.3.4'
212+
```
213+
214+
## Unable to build on Xcode 16.3
215+
216+
There is a [known issue](https://github.com/facebook/react-native/issues/50411)
217+
with Xcode 16.3 and [email protected].
218+
219+
Until New Architecture is supporter by Iterable, we cannot upgrade to 0.76.
220+
Therefore, to fix it we need to downgrade Xcode to 16.2.
221+
- [Download Xcode 16.2](https://download.developer.apple.com/Developer_Tools/Xcode_16.2/Xcode_16.2.xip)
222+
206223
## Other
207224
If things are not working and you are stumped as to why, try running the
208225
following in the _example app directory_:

package.json

+12-18
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
"version": "2.0.0-beta",
44
"description": "Iterable SDK for React Native.",
55
"source": "./src/index.tsx",
6-
"main": "./lib/commonjs/index.js",
7-
"module": "./lib/module/index.js",
6+
"main": "./lib/module/index.js",
7+
"types": "./lib/typescript/src/index.d.ts",
88
"exports": {
99
".": {
10-
"import": {
11-
"types": "./lib/typescript/module/src/index.d.ts",
10+
"types": "./lib/typescript/src/index.d.ts",
1211
"default": "./lib/module/index.js"
1312
},
14-
"require": {
15-
"types": "./lib/typescript/commonjs/src/index.d.ts",
16-
"default": "./lib/commonjs/index.js"
17-
}
18-
}
13+
"./package.json": "./package.json"
1914
},
2015
"files": [
2116
"src",
@@ -93,7 +88,7 @@
9388
"prettier": "^3.0.3",
9489
"react": "18.3.1",
9590
"react-native": "0.75.3",
96-
"react-native-builder-bob": "^0.30.2",
91+
"react-native-builder-bob": "^0.40.4",
9792
"react-native-safe-area-context": "^4.11.1",
9893
"react-native-vector-icons": "^10.2.0",
9994
"react-native-webview": "^13.12.3",
@@ -115,6 +110,12 @@
115110
"react-native-vector-icons": "*",
116111
"react-native-webview": "*"
117112
},
113+
"peerDependenciesMeta": {
114+
"expo": {
115+
"optional": true
116+
}
117+
},
118+
"sideEffects": false,
118119
"workspaces": [
119120
"example"
120121
],
@@ -145,12 +146,6 @@
145146
"source": "src",
146147
"output": "lib",
147148
"targets": [
148-
[
149-
"commonjs",
150-
{
151-
"esm": true
152-
}
153-
],
154149
[
155150
"module",
156151
{
@@ -160,8 +155,7 @@
160155
[
161156
"typescript",
162157
{
163-
"project": "tsconfig.build.json",
164-
"esm": true
158+
"project": "tsconfig.build.json"
165159
}
166160
]
167161
]

src/__tests__/IterableInApp.test.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { NativeEventEmitter } from 'react-native';
22

33
import { IterableLogger } from '../core';
4+
import { IterableInAppManager } from '../inApp';
5+
46
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
57

68
import {
@@ -200,13 +202,12 @@ describe('Iterable In App', () => {
200202

201203
// WHEN the simulated local queue is set to the in-app messages
202204
MockRNIterableAPI.setMessages(messages);
205+
const inAppManager = new IterableInAppManager();
203206

204207
// THEN Iterable,inAppManager.getMessages returns the list of in-app messages
205-
return await Iterable.inAppManager
206-
.getMessages()
207-
.then((messagesObtained) => {
208-
expect(messagesObtained).toEqual(messages);
209-
});
208+
return await inAppManager.getMessages().then((messagesObtained) => {
209+
expect(messagesObtained).toEqual(messages);
210+
});
210211
});
211212

212213
test('showMessage_messageAndConsume_returnsClickedUrl', async () => {
@@ -223,13 +224,11 @@ describe('Iterable In App', () => {
223224

224225
// WHEN the simulated clicked url is set to the clicked url
225226
MockRNIterableAPI.setClickedUrl(clickedUrl);
226-
227+
const inAppManager = new IterableInAppManager();
227228
// THEN Iterable,inAppManager.showMessage returns the simulated clicked url
228-
return await Iterable.inAppManager
229-
.showMessage(message, consume)
230-
.then((url) => {
231-
expect(url).toEqual(clickedUrl);
232-
});
229+
return await inAppManager.showMessage(message, consume).then((url) => {
230+
expect(url).toEqual(clickedUrl);
231+
});
233232
});
234233

235234
test('removeMessage_params_methodCalledWithParams', () => {
@@ -243,9 +242,10 @@ describe('Iterable In App', () => {
243242
const location: IterableInAppLocation = IterableInAppLocation.inApp;
244243
const source: IterableInAppDeleteSource =
245244
IterableInAppDeleteSource.deleteButton;
245+
const inAppManager = new IterableInAppManager();
246246

247247
// WHEN Iterable.inAppManager.removeMessage is called
248-
Iterable.inAppManager.removeMessage(message, location, source);
248+
inAppManager.removeMessage(message, location, source);
249249

250250
// THEN corresponding method is called on MockIterableAPI with appropriate parameters
251251
expect(MockRNIterableAPI.removeMessage).toBeCalledWith(
@@ -266,7 +266,8 @@ describe('Iterable In App', () => {
266266
const read: boolean = true;
267267

268268
// WHEN Iterable.inAppManager.setReadForMessage is called
269-
Iterable.inAppManager.setReadForMessage(message, read);
269+
const inAppManager = new IterableInAppManager();
270+
inAppManager.setReadForMessage(message, read);
270271

271272
// THEN corresponding method is called on MockRNIterableAPI with appropriate parameters
272273
expect(MockRNIterableAPI.setReadForMessage).toBeCalledWith(
@@ -280,7 +281,8 @@ describe('Iterable In App', () => {
280281
const paused: boolean = true;
281282

282283
// WHEN Iterable.inAppManager.setAutoDisplayPaused is called
283-
Iterable.inAppManager.setAutoDisplayPaused(paused);
284+
const inAppManager = new IterableInAppManager();
285+
inAppManager.setAutoDisplayPaused(paused);
284286

285287
// THEN corresponding method is called on MockRNIterableAPI with appropriate parameters
286288
expect(MockRNIterableAPI.setAutoDisplayPaused).toBeCalledWith(paused);

src/constants/index.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)