Cocoalumberjack: Xcode 9 beta 3 breaks the new os_log logger

Created on 10 Jul 2017  路  17Comments  路  Source: CocoaLumberjack/CocoaLumberjack

Getting the following errors DDOSLogger.m:

DDOSLogger.m:58:17: Static_assert failed "format argument must be a string constant"
DDOSLogger.m:62:17: Static_assert failed "format argument must be a string constant"
DDOSLogger.m:67:17: Static_assert failed "format argument must be a string constant"

The documentation for the format parameter says:

A format string to generate a human-readable log message when the log line is decoded. This string must be a constant string, not dynamically generated. Supports all standard printf types and %@ (objects).

Most helpful comment

if (message) {
        const char *msg = [message UTF8String];

        switch (logMessage->_flag) {
            case DDLogFlagError     :
                os_log_error(OS_LOG_DEFAULT, "%s", msg);
                break;
            case DDLogFlagWarning   :
            case DDLogFlagInfo      :
                os_log_info(OS_LOG_DEFAULT, "%s", msg);
                break;
            case DDLogFlagDebug     :
            case DDLogFlagVerbose   :
            default                 :
                os_log_debug(OS_LOG_DEFAULT, "%s", msg);
                break;
        }
    }

All 17 comments

Just ran into this as well. It doesn't like the use of the value from const char *msg = [message UTF8String]; and instead wants a literal.

I wonder if it's possible to disable the error with some #pragma clang stuff.

We're seeing this too 鈥斅營 made a fork that comments out the parts that don't work, since we weren't using the DDOSLogger in our project anyway. Feel free to use this if you need a temporary work around

pod 'CocoaLumberjack', :git => '[email protected]:supertop/CocoaLumberjack.git', :commit => '3443875e'

I think my commit may have fixed the issue. Can anyone confirm? Testing here shows it works, but I'm going off results from FmwkTest modified to use DDOSLogger instead of DDTTYLogger.

Oh nice, it works 馃帀 (tested by modifying the pod code inside an actual project)

@bpoplauschi Hey! When are you going to release new version with XCode 9 error fix? Thanks.

@Kaspik I can release it, but since Xcode 9 is not officially released yet, I don't think we need to hurry, unless people really need this release fast.

@bpoplauschi I mean - it works also for older XCode and it's proper fix, right? So some small hotfix release just with this would be helpful as most of the developers are using XCode 9 right now to be ready for beginning of September. :) I don't like pointing to master of any pod for AppStore release.

Yeah, been using XCode 9 most of the time, except when archiving a release build, so it'd be helpful 馃槃

if (message) {
        const char *msg = [message UTF8String];

        switch (logMessage->_flag) {
            case DDLogFlagError     :
                os_log_error(OS_LOG_DEFAULT, "%s", msg);
                break;
            case DDLogFlagWarning   :
            case DDLogFlagInfo      :
                os_log_info(OS_LOG_DEFAULT, "%s", msg);
                break;
            case DDLogFlagDebug     :
            case DDLogFlagVerbose   :
            default                 :
                os_log_debug(OS_LOG_DEFAULT, "%s", msg);
                break;
        }
    }

@molon thanks ...it worked like a charm in xcode 9 beta 6 :)

Above snippet worked for me as well. Public version xcode9. Thanks, Molon!!

Should be reopened as it's not fixed

3.2.1 fixed the issue for me with only pod 'CocoaLumberjack' in my Podfile, and still works with the public Xcode 9 release. Something's not right if you guys continue to need a patch.

updating pods did not fix, only the snippet from @molon fixed issue for me. Public Xcode 9 release.

Feel free to PR the snippet.

please~ the @molon snippet helped. Releasing a hot fix would really help:)

Was this page helpful?
0 / 5 - 0 ratings