btzy / nativefiledialog-extended

Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation issue with macOS SDK 12.3

jdumas opened this issue · comments

Hi there. When trying to build Tracy (wolfpld/tracy#368) on a recently upgraded macOS, I encountered the following compilation issue with NFD:

cd /Users/jedumas/external/git/nativefiledialog-extended/build/src && /Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -I/Users/jedumas/external/git/nativefiledialog-extended/src/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -nostdlib -fno-exceptions -fno-rtti -MD -MT src/CMakeFiles/nfd.dir/nfd_cocoa.m.o -MF CMakeFiles/nfd.dir/nfd_cocoa.m.o.d -o CMakeFiles/nfd.dir/nfd_cocoa.m.o -c /Users/jedumas/external/git/nativefiledialog-extended/src/nfd_cocoa.m
In file included from /Users/jedumas/external/git/nativefiledialog-extended/src/nfd_cocoa.m:8:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:10:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos...
                                                         ~~~~~~~~~~~~~~                                                                       ^                  ~
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
        #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
                                                      ^          ~
In file included from /Users/jedumas/external/git/nativefiledialog-extended/src/nfd_cocoa.m:8:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:10:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:130:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:168: error: expected ')'
- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullabl...
                                                                                                                                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:141: note: to match this '('
- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullabl...
                                                                                                                                            ^
/Users/jedumas/external/git/nativefiledialog-extended/src/nfd_cocoa.m:78:13: warning: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTypes instead
      [-Wdeprecated-declarations]
    [dialog setAllowedFileTypes:allowedFileTypes];
            ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property 'allowedFileTypes' is declared deprecated here
@property (nullable, copy) NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use -allowedContentTypes instead", macos(10.3,12.0));
                                                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
1 warning and 2 errors generated.
make[2]: *** [src/CMakeFiles/nfd.dir/nfd_cocoa.m.o] Error 1
make[1]: *** [src/CMakeFiles/nfd.dir/all] Error 2
make: *** [all] Error 2

To reproduce, specify the OSX_SYSROOT folder when calling CMake:

cmake -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/ ..

Thanks for reporting the issue, I'll take a look. It builds fine on the GitHub hosted runners though, so perhaps they aren't using the latest SDK.

As per my comment in the tracy issue, there are two issues at play here - the use of an old version of Apple Clang, and the allowedFileTypes deprecation.

The allowedFileTypes deprecation will be tracked separately in #58. I'll close this issue for now, but do reopen it if the macOS 12 SDK still won't compile even after you have updated your compiler.