Skip to content

Commit 9a6f99a

Browse files
fix(ios): enable JSContext to be inspectable (#13812)
* fix(ios): enable JSContext to be inspectable In iOS 16.4 the default state for whether a JSContext is inspectable became false and the owner of the context must explicitly set it to be inspectable. This commit enables the JSContext to be inspectable and I have verified this works for both Safari and VS Code debugging. However, for security concerns it's probably best that we disable this in production I assume. How to do that, I have no idea. It probably also needs to be guarded to only be set on iOS 16.4+ Refs https://webkit.org/blog/13966/webkit-features-in-safari-16-4/https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/ * refactor: guard usage of JSGlobalContextSetInspectable * refactor: use different guard * refactor: use YES instead of true, add production check * fix(ios): add prod-check to debugger handler --------- Co-authored-by: Hans Knöchel <h.knoechel@lambus.com>
1 parent b45b6d4 commit 9a6f99a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m

+9
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ - (void)booted:(id)bridge
248248
}
249249
[_queuedApplicationSelectors removeAllObjects];
250250
}
251+
252+
// Ensure that the JSContext is debuggable during development
253+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400
254+
BOOL isProduction = [TiSharedConfig.defaultConfig.applicationDeployType isEqualToString:@"production"];
255+
256+
if (!isProduction) {
257+
JSGlobalContextSetInspectable([[(KrollBridge *)bridge krollContext] context], YES);
258+
}
259+
#endif
251260
}
252261
}
253262

iphone/TitaniumKit/TitaniumKit/Sources/Misc/TiSharedConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
5151
@property (nonatomic, strong, nullable) NSString *applicationDescription;
5252

5353
/**
54-
Deploy type of the application, e.g. "development", currently **unused**.
54+
Deploy type of the application, e.g. "development", "test" or "production"
5555
*/
5656
@property (nonatomic, strong, nullable) NSString *applicationDeployType;
5757

0 commit comments

Comments
 (0)
close