feat: Add iOS platform support #60

Merged
Henry-Hiles merged 7 commits from eleboucher/nexus:ios-support into main 2026-08-08 16:35:57 -04:00
2 changed files with 9 additions and 17 deletions
Showing only changes of commit d25d24a692 - Show all commits

Consolidate getXCodeSDK/getXCodeClang into a single getXCodeTool

Erwan Leboucher 2026-08-08 22:30:48 +02:00 committed by eleboucher

View file

@ -28,7 +28,7 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
final iosConfig = codeConfig.iOS;
iosSdk = iosConfig.targetSdk;
final minVersion = iosConfig.targetVersion;
iosSdkPath = await getXCodeSDK(sdkType: iosSdk.type);
iosSdkPath = await getXCodeTool(sdkType: iosSdk.type);
final archTriple = switch (targetArch) {
Architecture.arm64 => "arm64",
Architecture.x64 => "x86_64",
@ -41,14 +41,14 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
: "$archTriple-apple-ios$minVersion.0";
extraEnv = {
"GOOS": "ios",
"CC": await getXCodeClang(sdkType: iosSdk.type),
"CC": await getXCodeTool(sdkType: iosSdk.type, findTool: "clang"),
"CGO_CFLAGS": "-isysroot $iosSdkPath -target $iosTargetTriple",
"CGO_LDFLAGS": "-isysroot $iosSdkPath -target $iosTargetTriple",
};
break;
case OS.macOS:
libFileName = "libgomuks.dylib";
extraEnv = {"SDKROOT": await getXCodeSDK()};
extraEnv = {"SDKROOT": await getXCodeTool()};
break;
case OS.windows:
libFileName = "libgomuks.dll";

View file

@ -1,22 +1,14 @@
import "dart:io";
Future<String> _runXcrun(List<String> args, String errorContext) async {
final result = await Process.run("xcrun", args);
Future<String> getXCodeTool({String? sdkType, String? findTool}) async {
final result = await Process.run("xcrun", [
if (sdkType != null) ...["--sdk", sdkType],
if (findTool != null) ...["-f", findTool] else "--show-sdk-path",
]);
if (result.exitCode != 0) {
throw Exception("Failed to $errorContext\n${result.stderr}");
throw Exception("Failed to run xcrun\n${result.stderr}");
}
return result.stdout.toString().trim();
}
Future<String> getXCodeSDK({String? sdkType}) => _runXcrun([
if (sdkType != null) ...["--sdk", sdkType],
"--show-sdk-path",
], "get XCode SDK");
Future<String> getXCodeClang({String? sdkType}) => _runXcrun([
if (sdkType != null) ...["--sdk", sdkType],
"-f",
"clang",
], "get XCode clang");