Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit a01ed3d

Browse files
yusintokeelerm84
andauthored
[sc-169352] Add ios client nil guards to prevent crashes (#137)
* [sc-169352] Fix RN iOS nil unwrapping bug * Use optional chaining instead * Introduce getLDClient function to safely guard against nil value. Set autocap to none for all textfields. * Update README.md * Update ios/LaunchdarklyReactNativeClient.swift Co-authored-by: Matthew M. Keeler <keelerm84@gmail.com> * Return default values if ldClient is nil during evaluation * Update LaunchdarklyReactNativeClient.swift * Merge useful v7 changes to v6. * Minor cleanup --------- Co-authored-by: Yusinto Ngadiman <yus@launchdarkly.com> Co-authored-by: Matthew M. Keeler <keelerm84@gmail.com>
1 parent 45554a1 commit a01ed3d

File tree

11 files changed

+226
-152
lines changed

11 files changed

+226
-152
lines changed

.gitignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ node_modules/
99
npm-debug.log
1010
yarn-error.log
1111
target/
12-
12+
1313
# Xcode
1414
#
1515
build/
@@ -29,10 +29,9 @@ DerivedData
2929
*.ipa
3030
*.xcuserstate
3131
project.xcworkspace
32-
32+
Pods
33+
3334
# Android/IntelliJ
34-
#
35-
build/
3635
.idea
3736
.gradle
3837
local.properties
@@ -45,6 +44,6 @@ android/.classpath
4544
buck-out/
4645
\.buckd/
4746
*.keystore
48-
47+
4948
# Auto-generated
50-
test-types.js
49+
test-types.js

ManualTestApp/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Wrapper = ({ children }): Node => {
1818

1919
const Body = () => {
2020
const [client, setClient] = useState(null);
21-
const [flagKey, setFlagKey] = useState('flag-key');
21+
const [flagKey, setFlagKey] = useState('dev-test-flag');
2222
const [flagType, setFlagType] = useState('bool');
2323
const [isOffline, setIsOffline] = useState(false);
2424
const [userKey, setUserKey] = useState('user key');
@@ -117,14 +117,14 @@ const Body = () => {
117117
<Switch value={isOffline} onValueChange={setOffline} />
118118
</View>
119119
<Text>User Key:</Text>
120-
<TextInput style={styles.input} onChangeText={setUserKey} value={userKey} />
120+
<TextInput style={styles.input} onChangeText={setUserKey} value={userKey} autoCapitalize="none" />
121121
<View style={styles.row}>
122122
<Button title="Identify" onPress={identify} />
123123
<Button title="Track" onPress={track} />
124124
<Button title="Flush" onPress={flush} />
125125
</View>
126126
<Text>Feature Flag Listener Key:</Text>
127-
<TextInput style={styles.input} onChangeText={setListenerKey} value={listenerKey} />
127+
<TextInput style={styles.input} onChangeText={setListenerKey} value={listenerKey} autoCapitalize="none" />
128128
<View style={styles.row}>
129129
<Button title="Listen" onPress={listen} />
130130
<Button title="Remove" onPress={removeListener} />

ManualTestApp/ios/ManualTestApp.xcodeproj/project.pbxproj

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0B6DA8F6F65AE4D7745E7034 /* libPods-ManualTestApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81200BDA804265B7051B34CC /* libPods-ManualTestApp.a */; };
1011
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
1112
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1213
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1314
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
14-
F24580C912BF168D16B9CE17 /* libPods-ManualTestApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E3FECAE815F45A23A2A17A4 /* libPods-ManualTestApp.a */; };
1515
/* End PBXBuildFile section */
1616

1717
/* Begin PBXFileReference section */
18-
0C0541498E0F816AAC43AFD6 /* Pods-ManualTestApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ManualTestApp.debug.xcconfig"; path = "Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp.debug.xcconfig"; sourceTree = "<group>"; };
18+
00A7AA1002E7C0727A14294F /* Pods-ManualTestApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ManualTestApp.debug.xcconfig"; path = "Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp.debug.xcconfig"; sourceTree = "<group>"; };
1919
13B07F961A680F5B00A75B9A /* ManualTestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ManualTestApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
2020
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ManualTestApp/AppDelegate.h; sourceTree = "<group>"; };
2121
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = ManualTestApp/AppDelegate.m; sourceTree = "<group>"; };
2222
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ManualTestApp/Images.xcassets; sourceTree = "<group>"; };
2323
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ManualTestApp/Info.plist; sourceTree = "<group>"; };
2424
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ManualTestApp/main.m; sourceTree = "<group>"; };
25-
7E3FECAE815F45A23A2A17A4 /* libPods-ManualTestApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ManualTestApp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
25+
367486A52C9EE5715002F16D /* Pods-ManualTestApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ManualTestApp.release.xcconfig"; path = "Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp.release.xcconfig"; sourceTree = "<group>"; };
26+
81200BDA804265B7051B34CC /* libPods-ManualTestApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ManualTestApp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
2627
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = ManualTestApp/LaunchScreen.storyboard; sourceTree = "<group>"; };
27-
AF2AEB7452F6900B99FF48E4 /* Pods-ManualTestApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ManualTestApp.release.xcconfig"; path = "Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp.release.xcconfig"; sourceTree = "<group>"; };
2828
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
2929
/* End PBXFileReference section */
3030

@@ -33,7 +33,7 @@
3333
isa = PBXFrameworksBuildPhase;
3434
buildActionMask = 2147483647;
3535
files = (
36-
F24580C912BF168D16B9CE17 /* libPods-ManualTestApp.a in Frameworks */,
36+
0B6DA8F6F65AE4D7745E7034 /* libPods-ManualTestApp.a in Frameworks */,
3737
);
3838
runOnlyForDeploymentPostprocessing = 0;
3939
};
@@ -57,21 +57,11 @@
5757
isa = PBXGroup;
5858
children = (
5959
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
60-
7E3FECAE815F45A23A2A17A4 /* libPods-ManualTestApp.a */,
60+
81200BDA804265B7051B34CC /* libPods-ManualTestApp.a */,
6161
);
6262
name = Frameworks;
6363
sourceTree = "<group>";
6464
};
65-
7F649E4EEFE2FB4CD7ED4A8A /* Pods */ = {
66-
isa = PBXGroup;
67-
children = (
68-
0C0541498E0F816AAC43AFD6 /* Pods-ManualTestApp.debug.xcconfig */,
69-
AF2AEB7452F6900B99FF48E4 /* Pods-ManualTestApp.release.xcconfig */,
70-
);
71-
name = Pods;
72-
path = Pods;
73-
sourceTree = "<group>";
74-
};
7565
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
7666
isa = PBXGroup;
7767
children = (
@@ -86,7 +76,7 @@
8676
832341AE1AAA6A7D00B99B32 /* Libraries */,
8777
83CBBA001A601CBA00E9B192 /* Products */,
8878
2D16E6871FA4F8E400B85C8A /* Frameworks */,
89-
7F649E4EEFE2FB4CD7ED4A8A /* Pods */,
79+
9D0815E89C722EA13B9E1945 /* Pods */,
9080
);
9181
indentWidth = 2;
9282
sourceTree = "<group>";
@@ -101,21 +91,31 @@
10191
name = Products;
10292
sourceTree = "<group>";
10393
};
94+
9D0815E89C722EA13B9E1945 /* Pods */ = {
95+
isa = PBXGroup;
96+
children = (
97+
00A7AA1002E7C0727A14294F /* Pods-ManualTestApp.debug.xcconfig */,
98+
367486A52C9EE5715002F16D /* Pods-ManualTestApp.release.xcconfig */,
99+
);
100+
name = Pods;
101+
path = Pods;
102+
sourceTree = "<group>";
103+
};
104104
/* End PBXGroup section */
105105

106106
/* Begin PBXNativeTarget section */
107107
13B07F861A680F5B00A75B9A /* ManualTestApp */ = {
108108
isa = PBXNativeTarget;
109109
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ManualTestApp" */;
110110
buildPhases = (
111-
1583E6315095EF5E60C53AA5 /* [CP] Check Pods Manifest.lock */,
111+
29C8EAF979C4977396E87B90 /* [CP] Check Pods Manifest.lock */,
112112
FD10A7F022414F080027D42C /* Start Packager */,
113113
13B07F871A680F5B00A75B9A /* Sources */,
114114
13B07F8C1A680F5B00A75B9A /* Frameworks */,
115115
13B07F8E1A680F5B00A75B9A /* Resources */,
116116
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
117-
6D5C2C8D85E57C53DB6F2B93 /* [CP] Embed Pods Frameworks */,
118-
F1026AFCB683E82B9A2BAC33 /* [CP] Copy Pods Resources */,
117+
AB81F03A081597AC6649A97F /* [CP] Embed Pods Frameworks */,
118+
71BC63C17D964AF72F12BA7C /* [CP] Copy Pods Resources */,
119119
);
120120
buildRules = (
121121
);
@@ -184,7 +184,7 @@
184184
shellPath = /bin/sh;
185185
shellScript = "set -e\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
186186
};
187-
1583E6315095EF5E60C53AA5 /* [CP] Check Pods Manifest.lock */ = {
187+
29C8EAF979C4977396E87B90 /* [CP] Check Pods Manifest.lock */ = {
188188
isa = PBXShellScriptBuildPhase;
189189
buildActionMask = 2147483647;
190190
files = (
@@ -206,38 +206,38 @@
206206
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
207207
showEnvVarsInLog = 0;
208208
};
209-
6D5C2C8D85E57C53DB6F2B93 /* [CP] Embed Pods Frameworks */ = {
209+
71BC63C17D964AF72F12BA7C /* [CP] Copy Pods Resources */ = {
210210
isa = PBXShellScriptBuildPhase;
211211
buildActionMask = 2147483647;
212212
files = (
213213
);
214214
inputFileListPaths = (
215-
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-frameworks-${CONFIGURATION}-input-files.xcfilelist",
215+
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-resources-${CONFIGURATION}-input-files.xcfilelist",
216216
);
217-
name = "[CP] Embed Pods Frameworks";
217+
name = "[CP] Copy Pods Resources";
218218
outputFileListPaths = (
219-
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-frameworks-${CONFIGURATION}-output-files.xcfilelist",
219+
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-resources-${CONFIGURATION}-output-files.xcfilelist",
220220
);
221221
runOnlyForDeploymentPostprocessing = 0;
222222
shellPath = /bin/sh;
223-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-frameworks.sh\"\n";
223+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-resources.sh\"\n";
224224
showEnvVarsInLog = 0;
225225
};
226-
F1026AFCB683E82B9A2BAC33 /* [CP] Copy Pods Resources */ = {
226+
AB81F03A081597AC6649A97F /* [CP] Embed Pods Frameworks */ = {
227227
isa = PBXShellScriptBuildPhase;
228228
buildActionMask = 2147483647;
229229
files = (
230230
);
231231
inputFileListPaths = (
232-
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-resources-${CONFIGURATION}-input-files.xcfilelist",
232+
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-frameworks-${CONFIGURATION}-input-files.xcfilelist",
233233
);
234-
name = "[CP] Copy Pods Resources";
234+
name = "[CP] Embed Pods Frameworks";
235235
outputFileListPaths = (
236-
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-resources-${CONFIGURATION}-output-files.xcfilelist",
236+
"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-frameworks-${CONFIGURATION}-output-files.xcfilelist",
237237
);
238238
runOnlyForDeploymentPostprocessing = 0;
239239
shellPath = /bin/sh;
240-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-resources.sh\"\n";
240+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ManualTestApp/Pods-ManualTestApp-frameworks.sh\"\n";
241241
showEnvVarsInLog = 0;
242242
};
243243
FD10A7F022414F080027D42C /* Start Packager */ = {
@@ -276,7 +276,7 @@
276276
/* Begin XCBuildConfiguration section */
277277
13B07F941A680F5B00A75B9A /* Debug */ = {
278278
isa = XCBuildConfiguration;
279-
baseConfigurationReference = 0C0541498E0F816AAC43AFD6 /* Pods-ManualTestApp.debug.xcconfig */;
279+
baseConfigurationReference = 00A7AA1002E7C0727A14294F /* Pods-ManualTestApp.debug.xcconfig */;
280280
buildSettings = {
281281
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
282282
CLANG_ENABLE_MODULES = YES;
@@ -302,7 +302,7 @@
302302
};
303303
13B07F951A680F5B00A75B9A /* Release */ = {
304304
isa = XCBuildConfiguration;
305-
baseConfigurationReference = AF2AEB7452F6900B99FF48E4 /* Pods-ManualTestApp.release.xcconfig */;
305+
baseConfigurationReference = 367486A52C9EE5715002F16D /* Pods-ManualTestApp.release.xcconfig */;
306306
buildSettings = {
307307
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
308308
CLANG_ENABLE_MODULES = YES;

ManualTestApp/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ PODS:
7474
- glog (0.3.5)
7575
- LaunchDarkly (7.1.0):
7676
- LaunchDarkly/Core (= 7.1.0)
77-
- launchdarkly-react-native-client-sdk (6.2.4):
77+
- launchdarkly-react-native-client-sdk (6.3.0):
7878
- LaunchDarkly (= 7.1.0)
7979
- React-Core
8080
- LaunchDarkly/Core (7.1.0):
@@ -510,13 +510,13 @@ SPEC CHECKSUMS:
510510
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
511511
FlipperKit: d8d346844eca5d9120c17d441a2f38596e8ed2b9
512512
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
513-
glog: bbaccdf9af7ec106ed6f0eb086217dc2bf37414c
513+
glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85
514514
LaunchDarkly: 31da8b77e96cb744417208478bb5b24f35fd2491
515-
launchdarkly-react-native-client-sdk: d40d2a6c7d6e578c6bc528c403e8f94b2cd02ffa
515+
launchdarkly-react-native-client-sdk: ddc05ffeba2a99393cec290528f044025a1d12c9
516516
LDSwiftEventSource: 824ce51a4fa8e79498c9b67ae672bfa802bd7464
517517
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
518518
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
519-
RCT-Folly: 19dac003a3f572f05a3b77277df72906a73469f1
519+
RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685
520520
RCTRequired: cd47794163052d2b8318c891a7a14fcfaccc75ab
521521
RCTTypeSafety: 393bb40b3e357b224cde53d3fec26813c52428b1
522522
React: dec6476bc27155b250eeadfc11ea779265f53ebf

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ We encourage pull requests and other contributions from the community. Check out
4848

4949
## Developing this SDK
5050

51-
- Run `npx react-native doctor` in both the root and ManualTestApp directories and make sure everything is green
51+
- Run `yarn doctor` in both the root and ManualTestApp directories and make sure everything is green
5252
- If watchman fails, you can try installing it manually `brew reinstall watchman`
5353
- Make sure you have [modd](https://github.com/cortesi/modd#install) installed so native code changes are hot reloaded
54-
55-
* For ios run `modd -f modd-ios.conf`
56-
* For android run `modd -f modd-android.conf`
54+
- `cd ManualTestApp && yarn`
55+
- For ios run `modd -f modd-ios.conf`
56+
- For android run `modd -f modd-android.conf`

0 commit comments

Comments
 (0)