2017-10-05 2 views
0

MacOS 10.12에서 완벽하게 작동하는 Apple의 Unified Logging System을 사용하고 있습니다. 나는 10.13 SDK를 대상으로 (그리고 10.12에서 실행)하지만 지금 os_log_error이 나에게 SIGABRT를 제공하고 나는이 오류가 출력 콘솔에 기록 얻을 :High Sierra (10.13)에서 os_log_error를 호출하는 방법

dyld: Symbol not found: __os_log_error_impl 
    Referenced from: /Users/dfrankel/Library/Developer/Xcode/DerivedData/UnrarKit-dlssapvyjlrhkufjcxzwiiojfals/Build/Products/Debug/UnrarKit.framework/Versions/A/UnrarKit (which was built for Mac OS X 10.13) 
    Expected in: /usr/lib/libSystem.B.dylib 

내 단위 테스트에서이납니다 때마다 os_log_erroros_log_fault이 호출되었지만 다른 os_log* 매크로는 모두 정상적으로 실행됩니다.

libSystem.B.tbd을 수동으로 프레임 워크 대상에 추가하고 차이를 만들지 않은 단위 테스트 대상에 수동으로 시도했습니다.

답변

0

os_log_erroros_log_fault 매크로가 모두 10.13 SDK에서 변경되어 더 복잡한 동작을 나타냅니다. 다른 이들은 혼자 남았습니다. 나는 아래의 업데이트 된 매크로를 참조 용으로 붙여 넣었다.

#if OS_LOG_TARGET_HAS_10_13_FEATURES 
#define os_log_error(log, format, ...) __extension__({ \ 
    os_log_t _log_tmp = (log); \ 
    os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; \ 
    if (os_log_type_enabled(_log_tmp, _type_tmp)) { \ 
     OS_LOG_CALL_WITH_FORMAT(_os_log_error_impl, \ 
       (&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \ 
    } \ 
}) 
#else 
#define os_log_error(log, format, ...) \ 
     os_log_with_type(log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__) 
#endif // OS_LOG_TARGET_HAS_10_13_FEATURES 

내 대상이 프레임 워크이기 때문에

, 그것은 가능한 목표는 오래된 운영체제에서 사용할 수 있습니다, 그래서 내가 볼 수있는이 주변에있는 유일한 방법은 OS 버전의 런타임 검사를하는 것입니다, 다음 조건을 선택하는 호출 할 매크로.

BOOL isAtLeast10_13SDK; 

#define MyLogError(format, ...) \ 
    if (isAtLeast10_13SDK) os_log_error(my_log, format, ##__VA_ARGS__); \ 
    else os_log_with_type(my_log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__); 
#define MyLogFault(format, ...) \ 
    if (isAtLeast10_13SDK) os_log_fault(my_log, format, ##__VA_ARGS__); \ 
    else os_log_with_type(my_log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__); 

+ (void)initialize { 
     NSOperatingSystemVersion minVersion; 
#if TARGET_OS_IPHONE 
     minVersion.majorVersion = 11; 
     minVersion.minorVersion = 0; 
     minVersion.patchVersion = 0; 
#else 
     minVersion.majorVersion = 10; 
     minVersion.minorVersion = 13; 
     minVersion.patchVersion = 0; 
#endif 
     isAtLeast10_13SDK = [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:minVersion]; 
} 
관련 문제