From 008a5c70b98fdc836e2d80e8d67fff7c4387c338 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 11 Dec 2021 20:06:42 +1100 Subject: [PATCH] [mac] Fix linking issue. Removed warnings. --- v2/internal/frontend/desktop/darwin/WailsContext.h | 1 + v2/internal/frontend/desktop/darwin/WailsContext.m | 8 ++++++-- v2/internal/frontend/desktop/darwin/main.m | 3 ++- v2/pkg/commands/build/base.go | 13 ++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.h b/v2/internal/frontend/desktop/darwin/WailsContext.h index 5a47a8ef2..cb8ddc9d2 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.h +++ b/v2/internal/frontend/desktop/darwin/WailsContext.h @@ -12,6 +12,7 @@ #import #if __has_include() +#define USE_NEW_FILTERS #import #endif diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index c98be86c0..aa7a92057 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -500,10 +500,14 @@ #ifdef USE_NEW_FILTERS NSMutableArray *contentTypes = [[NSMutableArray new] autorelease]; for (NSString *filter in filterList) { - UTType *t = [UTType typeWithFilenameExtension:filter]; - [contentTypes addObject:t]; + if (@available(macOS 11.0, *)) { + UTType *t = [UTType typeWithFilenameExtension:filter]; + [contentTypes addObject:t]; + } } + if (@available(macOS 11.0, *)) { [dialog setAllowedContentTypes:contentTypes]; + } #else [dialog setAllowedFileTypes:filterList]; #endif diff --git a/v2/internal/frontend/desktop/darwin/main.m b/v2/internal/frontend/desktop/darwin/main.m index 2f911367a..aec075cc0 100644 --- a/v2/internal/frontend/desktop/darwin/main.m +++ b/v2/internal/frontend/desktop/darwin/main.m @@ -32,7 +32,8 @@ void processCallback(int callbackID) { void processURLRequest(void *ctx, const char* url) { NSLog(@"processURLRequest called"); const char myByteArray[] = { 0x3c,0x68,0x31,0x3e,0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f,0x72,0x6c,0x64,0x21,0x3c,0x2f,0x68,0x31,0x3e }; - ProcessURLResponse(ctx, url, "text/html", (void*)myByteArray, 21); + // void *inctx, const char *url, int statusCode, const char *contentType, void* data, int datalength + ProcessURLResponse(ctx, url, 200, "text/html", (void*)myByteArray, 21); } unsigned char _Users_username_Pictures_SaltBae_png[] = { diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index 22d566afb..fc5f60a5c 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -3,13 +3,15 @@ package build import ( "bytes" "fmt" - "github.com/wailsapp/wails/v2/internal/system" "os" "os/exec" "path/filepath" "runtime" + "strconv" "strings" + "github.com/wailsapp/wails/v2/internal/system" + "github.com/leaanthony/gosod" wailsRuntime "github.com/wailsapp/wails/v2/internal/frontend/runtime" "github.com/wailsapp/wails/v2/internal/frontend/runtime/wrapper" @@ -320,13 +322,18 @@ func (b *BaseBuilder) CompileProject(options *Options) error { return "1" }) if options.Platform == "darwin" { - // Determine verison + // Determine version so we can link to newer frameworks + // Why doesn't CGO have this option?!?! info, err := system.GetInfo() if err != nil { return err } versionSplit := strings.Split(info.OS.Version, ".") - addUTIFramework := versionSplit[0] == "11" + majorVersion, err := strconv.Atoi(versionSplit[0]) + if err != nil { + return err + } + addUTIFramework := majorVersion >= 11 // Set the minimum Mac SDK to 10.13 cmd.Env = upsertEnv(cmd.Env, "CGO_LDFLAGS", func(v string) string { if v != "" {