goreleaser / goreleaser-cross

Docker image for Golang cross-compiling with CGO
MIT License
151 stars 26 forks source link

Error: /Headers/NSBundle.h:91:143: error: function does not return NSString #45

Open iamkhalidbashir opened 1 year ago

iamkhalidbashir commented 1 year ago

I am recieving this error when building a wails app with -tags=desktop,production

In file included from /root/go/pkg/mod/github.com/wailsapp/wails/v2@v2.5.1/pkg/assetserver/webview/request_darwin.go:9:
In file included from /usr/local/osxcross/bin/../SDK/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
/usr/local/osxcross/bin/../SDK/MacOSX12.0.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(12.0), ios(15.0), watchos(8.0), tvos(15.0));
                                                         ~~~~~~~~~~~~~~                                                                       ^                  ~
/usr/local/osxcross/bin/../SDK/MacOSX12.0.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 /root/go/pkg/mod/github.com/wailsapp/wails/v2@v2.5.1/pkg/assetserver/webview/request_darwin.go:9:
In file included from /usr/local/osxcross/bin/../SDK/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:130:
/usr/local/osxcross/bin/../SDK/MacOSX12.0.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 * _Nullable error))completionHandler;
                                                                                                                                                                       ^
/usr/local/osxcross/bin/../SDK/MacOSX12.0.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 * _Nullable error))completionHandler;
                                                                                                                                            ^
In file included from /root/go/pkg/mod/github.com/wailsapp/wails/v2@v2.5.1/pkg/assetserver/webview/request_darwin.go:10:
In file included from /usr/local/osxcross/bin/../SDK/MacOSX12.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebKit.h:39:
In file included from /usr/local/osxcross/bin/../SDK/MacOSX12.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKFrameInfo.h:30:
/usr/local/osxcross/bin/../SDK/MacOSX12.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebView.h:337:237: error: unknown type name '_Nullable_result'
- (void)callAsyncJavaScript:(NSString *)functionBody arguments:(nullable NSDictionary<NSString *, id> *)arguments inFrame:(nullable WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^ _Nullable)(_Nullable_result id, NSError * _Nullable error))completionHandler NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0));

When solutions I found is this:- https://github.com/tpoechtrager/osxcross/issues/345

Which requires me to set CXXFLAGS=-DNS_FORMAT_ARGUMENT(A)=

But how to set this flag?

troian commented 1 year ago

in a target for Darwin try set CGO_CXXFLAGS: "-DNS_FORMAT_ARGUMENT(A)=" in the env section