From 2af025abc3b4e500713f6f8348369e961b3e58da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Fri, 8 Sep 2017 10:13:26 +0200 Subject: [PATCH] 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 --- .env | 3 ++- .env.jenkins | 3 ++- .env.prod | 3 ++- ios/Status-Prefix.pch | 13 +++++++++++++ ios/StatusIm.xcodeproj/project.pbxproj | 4 ++++ ios/StatusIm/AppDelegate.m | 8 ++++++++ 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 ios/Status-Prefix.pch diff --git a/.env b/.env index 4ed47c591d..8eb195e1d5 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ TESTFAIRY_ENABLED=0 WALLET_WIP_ENABLED=1 -NOTIFICATIONS_WIP_ENABLED=1 \ No newline at end of file +NOTIFICATIONS_WIP_ENABLED=1 +DEBUG_LOGS_ENABLED=1 \ No newline at end of file diff --git a/.env.jenkins b/.env.jenkins index d0cc34a358..cef8760256 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -1,3 +1,4 @@ TESTFAIRY_ENABLED=1 WALLET_WIP_ENABLED=1 -NOTIFICATIONS_WIP_ENABLED=0 \ No newline at end of file +NOTIFICATIONS_WIP_ENABLED=0 +DEBUG_LOGS_ENABLED=1 diff --git a/.env.prod b/.env.prod index 077361ebee..a33fc84768 100644 --- a/.env.prod +++ b/.env.prod @@ -1,3 +1,4 @@ TESTFAIRY_ENABLED=0 WALLET_WIP_ENABLED=0 -NOTIFICATIONS_WIP_ENABLED=0 \ No newline at end of file +NOTIFICATIONS_WIP_ENABLED=0 +DEBUG_LOGS_ENABLED=0 \ No newline at end of file diff --git a/ios/Status-Prefix.pch b/ios/Status-Prefix.pch new file mode 100644 index 0000000000..f007adc815 --- /dev/null +++ b/ios/Status-Prefix.pch @@ -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) diff --git a/ios/StatusIm.xcodeproj/project.pbxproj b/ios/StatusIm.xcodeproj/project.pbxproj index e147a03f34..51aa7a92a0 100644 --- a/ios/StatusIm.xcodeproj/project.pbxproj +++ b/ios/StatusIm.xcodeproj/project.pbxproj @@ -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, diff --git a/ios/StatusIm/AppDelegate.m b/ios/StatusIm/AppDelegate.m index 8dcc9ae791..da08616d1b 100644 --- a/ios/StatusIm/AppDelegate.m +++ b/ios/StatusIm/AppDelegate.m @@ -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