Tooling: RN logs in release builds on iOS device

- DEBUG_LOGS_ENABLED flag enabled everywhere but production
- Adjust log level to conditionally show debug and RN logs
- PrefixHeader for sending app logs to Testfairy
This commit is contained in:
Oskar Thorén 2017-09-08 10:13:26 +02:00 committed by Roman Volosovskyi
parent ef777511dc
commit 2af025abc3
6 changed files with 31 additions and 3 deletions

3
.env
View File

@ -1,3 +1,4 @@
TESTFAIRY_ENABLED=0
WALLET_WIP_ENABLED=1
NOTIFICATIONS_WIP_ENABLED=1
NOTIFICATIONS_WIP_ENABLED=1
DEBUG_LOGS_ENABLED=1

View File

@ -1,3 +1,4 @@
TESTFAIRY_ENABLED=1
WALLET_WIP_ENABLED=1
NOTIFICATIONS_WIP_ENABLED=0
NOTIFICATIONS_WIP_ENABLED=0
DEBUG_LOGS_ENABLED=1

View File

@ -1,3 +1,4 @@
TESTFAIRY_ENABLED=0
WALLET_WIP_ENABLED=0
NOTIFICATIONS_WIP_ENABLED=0
NOTIFICATIONS_WIP_ENABLED=0
DEBUG_LOGS_ENABLED=0

13
ios/Status-Prefix.pch Normal file
View File

@ -0,0 +1,13 @@
// PrefixHeader.pch
#ifndef PrefixHeader_pch
#define PrefixHeader_pch
// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
#endif /* PrefixHeader_pch */
#import "TestFairy.h"
#define NSLog(s, ...) do { NSLog(s, ##__VA_ARGS__); TFLog(s, ##__VA_ARGS__); } while (0)

View File

@ -1987,6 +1987,8 @@
"$(PROJECT_DIR)/Pods/**",
"$(PROJECT_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Status-Prefix.pch";
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
@ -2044,6 +2046,8 @@
"$(PROJECT_DIR)/Pods/**",
"$(PROJECT_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Status-Prefix.pch";
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,

View File

@ -10,12 +10,14 @@
#import "AppDelegate.h"
#import "ReactNativeConfig.h"
#import "React/RCTLog.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
#import "SplashScreen.h"
#import "TestFairy.h"
#import "RNFIRMessaging.h"
/* Macro to send app logs to TestFairy, potential duplicate of prefix header */
#define NSLog(s, ...) do { NSLog(s, ##__VA_ARGS__); TFLog(s, ##__VA_ARGS__); } while (0)
@import Instabug;
@ -26,6 +28,12 @@
signal(SIGPIPE, SIG_IGN);
NSURL *jsCodeLocation;
/* Enable debug logs from React Native for release mode */
NSString *debugLogsEnabled = [ReactNativeConfig envFor:@"DEBUG_LOGS_ENABLED"];
if([debugLogsEnabled isEqualToString:@"1"]){
RCTSetLogThreshold(RCTLogLevelInfo - 1);
}
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation