Skip to content

Commit 88a8308

Browse files
committed
Fixed UIExplorer in Catalyst shell
1 parent 54974d6 commit 88a8308

File tree

6 files changed

+104
-11
lines changed

6 files changed

+104
-11
lines changed

Examples/SampleApp/SampleApp.xcodeproj/project.pbxproj

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
1818
00E356F31AD99517003FC87E /* SampleAppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SampleAppTests.m */; };
1919
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
20+
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
2021
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
2122
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
2223
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
@@ -82,6 +83,13 @@
8283
remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
8384
remoteInfo = SampleApp;
8485
};
86+
139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
87+
isa = PBXContainerItemProxy;
88+
containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
89+
proxyType = 2;
90+
remoteGlobalIDString = 134814201AA4EA6300B7C361;
91+
remoteInfo = RCTSettings;
92+
};
8593
146834031AC3E56700842450 /* PBXContainerItemProxy */ = {
8694
isa = PBXContainerItemProxy;
8795
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
@@ -117,6 +125,7 @@
117125
00E356EE1AD99517003FC87E /* SampleAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SampleAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
118126
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
119127
00E356F21AD99517003FC87E /* SampleAppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SampleAppTests.m; sourceTree = "<group>"; };
128+
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../../Libraries/Settings/RCTSettings.xcodeproj; sourceTree = "<group>"; };
120129
13B07F961A680F5B00A75B9A /* SampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
121130
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = iOS/AppDelegate.h; sourceTree = "<group>"; };
122131
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = iOS/AppDelegate.m; sourceTree = "<group>"; };
@@ -142,6 +151,7 @@
142151
buildActionMask = 2147483647;
143152
files = (
144153
146834051AC3E58100842450 /* libReact.a in Frameworks */,
154+
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
145155
00481BE81AC0C86700671115 /* libRCTWebSocketDebugger.a in Frameworks */,
146156
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
147157
00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */,
@@ -230,6 +240,14 @@
230240
name = "Supporting Files";
231241
sourceTree = "<group>";
232242
};
243+
139105B71AF99BAD00B5F7CC /* Products */ = {
244+
isa = PBXGroup;
245+
children = (
246+
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */,
247+
);
248+
name = Products;
249+
sourceTree = "<group>";
250+
};
233251
13B07FAE1A68108700A75B9A /* SampleApp */ = {
234252
isa = PBXGroup;
235253
children = (
@@ -263,14 +281,15 @@
263281
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
264282
isa = PBXGroup;
265283
children = (
266-
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */,
267284
146833FF1AC3E56700842450 /* React.xcodeproj */,
268-
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
269285
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
270286
00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */,
271287
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
272288
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */,
289+
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */,
273290
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */,
291+
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */,
292+
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
274293
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
275294
00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */,
276295
);
@@ -395,6 +414,10 @@
395414
ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */;
396415
ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
397416
},
417+
{
418+
ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
419+
ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
420+
},
398421
{
399422
ProductGroup = 832341B11AAA6A8300B99B32 /* Products */;
400423
ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
@@ -470,6 +493,13 @@
470493
remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */;
471494
sourceTree = BUILT_PRODUCTS_DIR;
472495
};
496+
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = {
497+
isa = PBXReferenceProxy;
498+
fileType = archive.ar;
499+
path = libRCTSettings.a;
500+
remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */;
501+
sourceTree = BUILT_PRODUCTS_DIR;
502+
};
473503
146834041AC3E56700842450 /* libReact.a */ = {
474504
isa = PBXReferenceProxy;
475505
fileType = archive.ar;

Examples/SampleApp/index.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var SampleApp = React.createClass({
2424
</Text>
2525
<Text style={styles.instructions}>
2626
Press Cmd+R to reload,{'\n'}
27-
Cmd+Control+Z for dev menu
27+
Cmd+D or shake for dev menu
2828
</Text>
2929
</View>
3030
);

Libraries/Settings/RCTSettingsManager.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "RCTBridge.h"
1313
#import "RCTConvert.h"
1414
#import "RCTEventDispatcher.h"
15+
#import "RCTUtils.h"
1516

1617
@implementation RCTSettingsManager
1718
{
@@ -53,13 +54,15 @@ - (void)userDefaultsDidChange:(NSNotification *)note
5354
return;
5455
}
5556

56-
[_bridge.eventDispatcher sendDeviceEventWithName:@"settingsUpdated" body:[_defaults dictionaryRepresentation]];
57+
[_bridge.eventDispatcher
58+
sendDeviceEventWithName:@"settingsUpdated"
59+
body:RCTJSONClean([_defaults dictionaryRepresentation])];
5760
}
5861

5962
- (NSDictionary *)constantsToExport
6063
{
6164
return @{
62-
@"settings": [_defaults dictionaryRepresentation]
65+
@"settings": RCTJSONClean([_defaults dictionaryRepresentation])
6366
};
6467
}
6568

React/Base/RCTConvert.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,9 @@ static id RCTConvertPropertyListValue(id json)
838838
{
839839
if (!json || json == (id)kCFNull) {
840840
return nil;
841-
} else if ([json isKindOfClass:[NSDictionary class]]) {
841+
}
842+
843+
if ([json isKindOfClass:[NSDictionary class]]) {
842844
__block BOOL copy = NO;
843845
NSMutableDictionary *values = [[NSMutableDictionary alloc] initWithCapacity:[json count]];
844846
[json enumerateKeysAndObjectsUsingBlock:^(NSString *key, id jsonValue, BOOL *stop) {
@@ -849,7 +851,9 @@ static id RCTConvertPropertyListValue(id json)
849851
copy |= value != jsonValue;
850852
}];
851853
return copy ? values : json;
852-
} else if ([json isKindOfClass:[NSArray class]]) {
854+
}
855+
856+
if ([json isKindOfClass:[NSArray class]]) {
853857
__block BOOL copy = NO;
854858
__block NSArray *values = json;
855859
[json enumerateObjectsUsingBlock:^(id jsonValue, NSUInteger idx, BOOL *stop) {
@@ -864,15 +868,17 @@ static id RCTConvertPropertyListValue(id json)
864868
for (NSInteger i = 0; i < idx; i++) {
865869
[(NSMutableArray *)values addObject:json[i]];
866870
}
867-
[(NSMutableArray *)values addObject:value];
871+
if (value) {
872+
[(NSMutableArray *)values addObject:value];
873+
}
868874
copy = YES;
869875
}
870876
}];
871877
return values;
872-
} else {
873-
// All other JSON types are supported by property lists
874-
return json;
875878
}
879+
880+
// All other JSON types are supported by property lists
881+
return json;
876882
}
877883

878884
+ (NSPropertyList)NSPropertyList:(id)json

React/Base/RCTUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
RCT_EXTERN NSString *RCTJSONStringify(id jsonObject, NSError **error);
2020
RCT_EXTERN id RCTJSONParse(NSString *jsonString, NSError **error);
2121

22+
// Strip non JSON-safe values from an object graph
23+
RCT_EXTERN id RCTJSONClean(id object);
24+
2225
// Get MD5 hash of a string (TODO: currently unused. Remove?)
2326
RCT_EXTERN NSString *RCTMD5Hash(NSString *string);
2427

React/Base/RCTUtils.m

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,57 @@ id RCTJSONParse(NSString *jsonString, NSError **error)
4242
return [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:error];
4343
}
4444

45+
id RCTJSONClean(id object)
46+
{
47+
static dispatch_once_t onceToken;
48+
static NSSet *validLeafTypes;
49+
dispatch_once(&onceToken, ^{
50+
validLeafTypes = [[NSSet alloc] initWithArray:@[
51+
[NSString class],
52+
[NSMutableString class],
53+
[NSNumber class],
54+
[NSNull class],
55+
]];
56+
});
57+
58+
if ([validLeafTypes containsObject:[object classForCoder]]) {
59+
return object;
60+
}
61+
62+
if ([object isKindOfClass:[NSDictionary class]]) {
63+
__block BOOL copy = NO;
64+
NSMutableDictionary *values = [[NSMutableDictionary alloc] initWithCapacity:[object count]];
65+
[object enumerateKeysAndObjectsUsingBlock:^(NSString *key, id item, BOOL *stop) {
66+
id value = RCTJSONClean(item);
67+
values[key] = value;
68+
copy |= value != item;
69+
}];
70+
return copy ? values : object;
71+
}
72+
73+
if ([object isKindOfClass:[NSArray class]]) {
74+
__block BOOL copy = NO;
75+
__block NSArray *values = object;
76+
[object enumerateObjectsUsingBlock:^(id item, NSUInteger idx, BOOL *stop) {
77+
id value = RCTJSONClean(item);
78+
if (copy) {
79+
[(NSMutableArray *)values addObject:value];
80+
} else if (value != item) {
81+
// Converted value is different, so we'll need to copy the array
82+
values = [[NSMutableArray alloc] initWithCapacity:values.count];
83+
for (NSInteger i = 0; i < idx; i++) {
84+
[(NSMutableArray *)values addObject:object[i]];
85+
}
86+
[(NSMutableArray *)values addObject:value];
87+
copy = YES;
88+
}
89+
}];
90+
return values;
91+
}
92+
93+
return (id)kCFNull;
94+
}
95+
4596
NSString *RCTMD5Hash(NSString *string)
4697
{
4798
const char *str = [string UTF8String];

0 commit comments

Comments
 (0)