Skip to content

Commit

Permalink
Disable dev mode on ship builds (#888) (#903)
Browse files Browse the repository at this point in the history
* revert dev mode on ship builds

* rctuicolor

* remove unused variable

* pod install
  • Loading branch information
HeyImChris committed Nov 18, 2021
1 parent 72028c0 commit acca3c1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 44 deletions.
16 changes: 7 additions & 9 deletions Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -966,15 +966,13 @@ - (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)data
UIImage *image = RCTDecodeImageWithData(data, size, scale, resizeMode);

#if !TARGET_OS_OSX && RCT_DEV // TODO(macOS GH#774)
if ([[self->_bridge devSettings] isDevModeEnabled]) { // TODO(OSS Candidate ISS#2710739)
CGSize imagePixelSize = RCTSizeInPixels(image.size, UIImageGetScale(image)); // TODO(macOS GH#774)
CGSize screenPixelSize = RCTSizeInPixels(RCTScreenSize(), RCTScreenScale());
if (imagePixelSize.width * imagePixelSize.height >
screenPixelSize.width * screenPixelSize.height) {
RCTLogInfo(@"[PERF ASSETS] Loading image at size %@, which is larger "
"than the screen size %@", NSStringFromCGSize(imagePixelSize),
NSStringFromCGSize(screenPixelSize));
}
CGSize imagePixelSize = RCTSizeInPixels(image.size, UIImageGetScale(image)); // TODO(macOS GH#774)
CGSize screenPixelSize = RCTSizeInPixels(RCTScreenSize(), RCTScreenScale());
if (imagePixelSize.width * imagePixelSize.height >
screenPixelSize.width * screenPixelSize.height) {
RCTLogInfo(@"[PERF ASSETS] Loading image at size %@, which is larger "
"than the screen size %@", NSStringFromCGSize(imagePixelSize),
NSStringFromCGSize(screenPixelSize));
}
#endif

Expand Down
3 changes: 1 addition & 2 deletions React/Base/RCTDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
#if DEBUG
#define RCT_DEV 1
#else
// Dev Mode is now enabled or disabled at runtime via the -[RCTDevSettings isDevModeEnabled] property
#define RCT_DEV 1
#define RCT_DEV 0
#endif
#endif

Expand Down
4 changes: 1 addition & 3 deletions React/Base/RCTRootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,7 @@ - (NSMenu *)menuForEvent:(NSEvent *)event
{
NSMenu *menu = nil;
#if __has_include("RCTDevMenu.h") && RCT_DEV
if ([[_bridge devSettings] isDevModeEnabled]) {
menu = [[_bridge devMenu] menu];
}
menu = [[_bridge devMenu] menu];
#endif
if (menu == nil) {
menu = [super menuForEvent:event];
Expand Down
4 changes: 2 additions & 2 deletions React/CoreModules/RCTDevLoadingView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)setBridge:(RCTBridge *)bridge
name:RCTJavaScriptDidFailToLoadNotification
object:nil];

if ([[bridge devSettings] isDevModeEnabled] && bridge.loading) { // TODO(OSS Candidate ISS#2710739)
if (bridge.loading) {
[self showWithURL:bridge.bundleURL];
}
}
Expand Down Expand Up @@ -339,7 +339,7 @@ + (NSString *)moduleName
+ (void)setEnabled:(BOOL)enabled
{
}
- (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor
- (void)showMessage:(NSString *)message color:(RCTUIColor *)color backgroundColor:(RCTUIColor *)backgroundColor // TODO(macOS GH#774) RCTUIColor
{
}
- (void)showMessage:(NSString *)message withColor:(NSNumber *)color withBackgroundColor:(NSNumber *)backgroundColor
Expand Down
1 change: 0 additions & 1 deletion React/CoreModules/RCTDevMenu.mm
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ - (void)setDefaultJSBundle
#if TARGET_OS_OSX // [TODO(macOS GH#774)
- (NSMenu *)menu
{
NSMenu *menu = nil;
if ([_bridge.devSettings isSecondaryClickToShowDevMenuEnabled]) {
NSMenu *menu = nil;
if (_bridge) {
Expand Down
8 changes: 0 additions & 8 deletions React/CoreModules/RCTDevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@

- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource;

// [TODO(OSS Candidate ISS#2710739)
/**
* Whether Dev Mode is enabled meaning the development tools
* such as the debug executors, dev menu, red box, etc. are available.
*/
@property (nonatomic, assign, setter=setDevModeEnabled:) BOOL isDevModeEnabled;
// ]TODO(OSS Candidate ISS#2710739)

@property (nonatomic, readonly) BOOL isHotLoadingAvailable;
@property (nonatomic, readonly) BOOL isLiveReloadAvailable;
@property (nonatomic, readonly) BOOL isRemoteDebuggingAvailable;
Expand Down
12 changes: 0 additions & 12 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,6 @@ - (BOOL)isDeviceDebuggingAvailable
#endif // RCT_ENABLE_INSPECTOR
}

// [TODO(OSS Candidate ISS#2710739)
RCT_EXPORT_METHOD(setDevModeEnabled:(BOOL)enabled)
{
[self _updateSettingWithValue:@(enabled) forKey:kRCTDevSettingDevModeEnabled];
}

- (BOOL)isDevModeEnabled
{
return [[self settingForKey:kRCTDevSettingDevModeEnabled] boolValue];
}
// ]TODO(OSS Candidate ISS#2710739)

- (BOOL)isRemoteDebuggingAvailable
{
if (RCTTurboModuleEnabled()) {
Expand Down
10 changes: 3 additions & 7 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ - (void)start
#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include(<React/RCTDevLoadingViewProtocol.h>)
// [TODO(OSS Candidate ISS#2710739)
// Note: RCTDevLoadingView should have been loaded at this point, so no need to allow lazy loading.
if ([weakSelf isValid] && [[weakSelf devSettings] isDevModeEnabled]) {
if ([weakSelf isValid]) {
id<RCTDevLoadingViewProtocol> loadingView = [weakSelf moduleForName:@"DevLoadingView"
lazilyLoadIfNecessary:YES];
[loadingView updateProgress:progressData];
Expand Down Expand Up @@ -673,9 +673,7 @@ - (void)_initializeBridge:(std::shared_ptr<JSExecutorFactory>)executorFactory
// This can only be false if the bridge was invalidated before startup completed
if (_reactInstance) {
#if RCT_DEV
if ([[self devSettings] isDevModeEnabled]) { // TODO(OSS Candidate ISS#2710739)
executorFactory = std::make_shared<GetDescAdapter>(self, executorFactory);
} // TODO(OSS Candidate ISS#2710739)
executorFactory = std::make_shared<GetDescAdapter>(self, executorFactory);
#endif

[self _initializeBridgeLocked:executorFactory];
Expand Down Expand Up @@ -1037,9 +1035,7 @@ - (void)executeSourceCode:(NSData *)sourceCode sync:(BOOL)sync
[self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:completion];
}

if (self.devSettings.isDevModeEnabled) { // TODO(OSS Candidate ISS#2710739)
[self.devSettings setupHMRClientWithBundleURL:self.bundleURL];
}
[self.devSettings setupHMRClientWithBundleURL:self.bundleURL];
}

#if RCT_DEV_MENU
Expand Down

0 comments on commit acca3c1

Please sign in to comment.