diff --git a/ios/Status-Prefix.pch b/ios/Status-Prefix.pch deleted file mode 100644 index f007adc815..0000000000 --- a/ios/Status-Prefix.pch +++ /dev/null @@ -1,13 +0,0 @@ -// 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 51aa7a92a0..b2ab9d4c21 100644 --- a/ios/StatusIm.xcodeproj/project.pbxproj +++ b/ios/StatusIm.xcodeproj/project.pbxproj @@ -1987,8 +1987,8 @@ "$(PROJECT_DIR)/Pods/**", "$(PROJECT_DIR)", ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "Status-Prefix.pch"; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -2046,8 +2046,8 @@ "$(PROJECT_DIR)/Pods/**", "$(PROJECT_DIR)", ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "Status-Prefix.pch"; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; 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 da08616d1b..fba1d06c87 100644 --- a/ios/StatusIm/AppDelegate.m +++ b/ios/StatusIm/AppDelegate.m @@ -9,6 +9,7 @@ #import "AppDelegate.h" +#import #import "ReactNativeConfig.h" #import "React/RCTLog.h" #import "RCTBundleURLProvider.h" @@ -17,12 +18,48 @@ #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; @implementation AppDelegate +/* Modified version of RCTDefaultLogFunction that also directs all app logs to TestFairy. */ +RCTLogFunction RCTTestFairyLogFunction = ^( + RCTLogLevel level, + __unused RCTLogSource source, + NSString *fileName, + NSNumber *lineNumber, + NSString *message + ) +{ + NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message); + fprintf(stderr, "%s\n", log.UTF8String); + fflush(stderr); + + /* Only custom part */ + TFLog(log); + + int aslLevel; + switch(level) { + case RCTLogLevelTrace: + aslLevel = ASL_LEVEL_DEBUG; + break; + case RCTLogLevelInfo: + aslLevel = ASL_LEVEL_NOTICE; + break; + case RCTLogLevelWarning: + aslLevel = ASL_LEVEL_WARNING; + break; + case RCTLogLevelError: + aslLevel = ASL_LEVEL_ERR; + break; + case RCTLogLevelFatal: + aslLevel = ASL_LEVEL_CRIT; + break; + } + asl_log(NULL, NULL, aslLevel, "%s", message.UTF8String); + +}; + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { signal(SIGPIPE, SIG_IGN); @@ -32,6 +69,7 @@ NSString *debugLogsEnabled = [ReactNativeConfig envFor:@"DEBUG_LOGS_ENABLED"]; if([debugLogsEnabled isEqualToString:@"1"]){ RCTSetLogThreshold(RCTLogLevelInfo - 1); + RCTSetLogFunction(RCTTestFairyLogFunction); } jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];