1

I am using CocoaLumberjack pod in my iOS project.

Defined custom macro like,

#define SM_DDLogDebugConst(tag, frmt)   DDLogDebug(([NSString stringWithFormat:@"[DEBUG][%@] %@", tag, frmt]), @"%@")

In code I used the macro like following,

int64_t startTime = [TimeUtils NOW]; // returns timestamp // line = 10
...
int64_t tempTime = [TimeUtils NOW];  // returns timestamp // line = 20
SM_DDLogDebug(TAG_Class, @"elapsed time: %lld", (tempTime - startTime));
...

The problem is when I run infer its detecting DEAD_STORE error in lines 10 & 20 though the variables in the lines have been used in the logging. How to resolve this issue?

Note: my infer command runs in two steps,

xcodebuild clean build -workspace Project.xcworkspace -scheme Main -configuration Release COMPILER_INDEX_STORE_ENABLE=NO OTHER_CFLAGS="-DNS_FORMAT_ARGUMENT(A)= -D_Nullable_result=_Nullable" | tee xcodebuild.log | /usr/local/bin/xcpretty -r json-compilation-database -o compile_commands.json

/usr/local/bin/infer run --keep-going --skip-analysis-in-path Pods --compilation-database-escaped compile_commands.json
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
  • How exactly are you running `infer`? Most likely it is inspecting your app in release mode when your debug logs have been removed. The simplest solution would be to wrap your `startTime` and `endTime` variables into `#ifdef DEBUG` directives, or, you can hide them in macros, too, .e.g `SM_DEBUG_SAVE_START_TIME()` and `SM_DEBUG_SAVE_START_TIME()`. – Sulthan Jan 17 '22 at 18:12
  • @Sulthan I have added how Infer was run. Also there is no macro for skipping log in Release configuration. Is there any default setting in Lumberjack pod side you know of? – Sazzad Hissain Khan Jan 17 '22 at 19:52
  • My fault. I was assuming that you are removing logs from release mode. I recommend switching Xcode to release and checking preprocessed output. That should give your more info. – Sulthan Jan 17 '22 at 20:18

0 Answers0