From 4c90fbd7d1a65591c1a0b264118d06b62f7f5a4b Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Tue, 7 Jul 2026 18:51:27 -0400 Subject: [PATCH] get xcode sdk --- hook/build.dart | 2 ++ lib/helpers/extensions/get_xcode_sdk.dart | 11 +++++++++++ scripts/generate.dart | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lib/helpers/extensions/get_xcode_sdk.dart diff --git a/hook/build.dart b/hook/build.dart index 2324736..dde0920 100644 --- a/hook/build.dart +++ b/hook/build.dart @@ -1,6 +1,7 @@ import "dart:io"; import "package:hooks/hooks.dart"; import "package:code_assets/code_assets.dart"; +import "package:nexus/helpers/extensions/get_xcode_sdk.dart"; Future main(List args) => build(args, (input, output) async { if (!input.config.buildCodeAssets) return; @@ -16,6 +17,7 @@ Future main(List args) => build(args, (input, output) async { break; case OS.macOS: libFileName = "libgomuks.dylib"; + env = {"SDKROOT": await getXCodeSDK()}; break; case OS.windows: libFileName = "libgomuks.dll"; diff --git a/lib/helpers/extensions/get_xcode_sdk.dart b/lib/helpers/extensions/get_xcode_sdk.dart new file mode 100644 index 0000000..9d7a71a --- /dev/null +++ b/lib/helpers/extensions/get_xcode_sdk.dart @@ -0,0 +1,11 @@ +import "dart:io"; + +Future getXCodeSDK() async { + final result = await Process.run("xcrun", ["--show-sdk-path"]); + + if (result.exitCode != 0) { + throw Exception("Failed to get XCode SDK\n${result.stderr}"); + } + + return result.stdout; +} diff --git a/scripts/generate.dart b/scripts/generate.dart index 446a469..8d72ab1 100644 --- a/scripts/generate.dart +++ b/scripts/generate.dart @@ -1,6 +1,7 @@ import "dart:io"; import "package:ffigen/ffigen.dart"; import "package:path/path.dart"; +import "package:nexus/helpers/extensions/get_xcode_sdk.dart"; void main(List args) async { final repoDir = Directory.fromUri(Platform.script.resolve("../gomuks")); @@ -14,7 +15,10 @@ void main(List args) async { ), headers: Headers( entryPoints: [File(join(repoDir.path, "pkg", "ffi", "gomuksffi.h")).uri], - compilerOptions: ["--no-warnings"], + compilerOptions: [ + "--no-warnings", + if (Platform.isMacOS) "${await getXCodeSDK()}/usr/include", + ], ), functions: Functions.includeAll, ).generate(