feat: Add iOS platform support #60
2 changed files with 17 additions and 15 deletions
Handle xcrun failures via getXCodeSDK/getXCodeClang helpers
commit
f3787d7f83
|
|
@ -28,11 +28,7 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
|
||||||
final iosConfig = codeConfig.iOS;
|
final iosConfig = codeConfig.iOS;
|
||||||
iosSdk = iosConfig.targetSdk;
|
iosSdk = iosConfig.targetSdk;
|
||||||
final minVersion = iosConfig.targetVersion;
|
final minVersion = iosConfig.targetVersion;
|
||||||
iosSdkPath = (await Process.run("xcrun", [
|
iosSdkPath = await getXCodeSDK(sdkType: iosSdk.type);
|
||||||
"--sdk",
|
|
||||||
iosSdk.type,
|
|
||||||
"--show-sdk-path",
|
|
||||||
])).stdout.toString().trim();
|
|
||||||
final archTriple = switch (targetArch) {
|
final archTriple = switch (targetArch) {
|
||||||
Architecture.arm64 => "arm64",
|
Architecture.arm64 => "arm64",
|
||||||
Architecture.x64 => "x86_64",
|
Architecture.x64 => "x86_64",
|
||||||
|
|
@ -45,12 +41,7 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
|
||||||
: "$archTriple-apple-ios$minVersion.0";
|
: "$archTriple-apple-ios$minVersion.0";
|
||||||
extraEnv = {
|
extraEnv = {
|
||||||
"GOOS": "ios",
|
"GOOS": "ios",
|
||||||
"CC": (await Process.run("xcrun", [
|
"CC": await getXCodeClang(sdkType: iosSdk.type),
|
||||||
"--sdk",
|
|
||||||
iosSdk.type,
|
|
||||||
"-f",
|
|
||||||
"clang",
|
|
||||||
])).stdout.toString().trim(),
|
|
||||||
"CGO_CFLAGS": "-isysroot $iosSdkPath -target $iosTargetTriple",
|
"CGO_CFLAGS": "-isysroot $iosSdkPath -target $iosTargetTriple",
|
||||||
"CGO_LDFLAGS": "-isysroot $iosSdkPath -target $iosTargetTriple",
|
"CGO_LDFLAGS": "-isysroot $iosSdkPath -target $iosTargetTriple",
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,22 @@
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
|
|
||||||
Future<String> getXCodeSDK() async {
|
Future<String> _runXcrun(List<String> args, String errorContext) async {
|
||||||
final result = await Process.run("xcrun", ["--show-sdk-path"]);
|
final result = await Process.run("xcrun", args);
|
||||||
|
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
throw Exception("Failed to get XCode SDK\n${result.stderr}");
|
throw Exception("Failed to $errorContext\n${result.stderr}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.stdout.trim();
|
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");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue