master
 1const std = @import("std");
 2
 3pub const requires_symlinks = true;
 4pub const requires_ios_sdk = true;
 5
 6pub fn build(b: *std.Build) void {
 7    const test_step = b.step("test", "Test it");
 8    b.default_step = test_step;
 9
10    const optimize: std.builtin.OptimizeMode = .Debug;
11    const target = b.resolveTargetQuery(.{
12        .cpu_arch = .aarch64,
13        .os_tag = .ios,
14    });
15
16    const exe = b.addExecutable(.{
17        .name = "main",
18        .root_module = b.createModule(.{
19            .root_source_file = null,
20            .optimize = optimize,
21            .target = target,
22            .link_libc = true,
23        }),
24    });
25
26    if (std.zig.system.darwin.getSdk(b.allocator, &target.result)) |sdk| {
27        b.sysroot = sdk;
28        exe.root_module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
29        exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
30        exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) });
31    } else {
32        exe.step.dependOn(&b.addFail("no iOS SDK found").step);
33    }
34
35    exe.root_module.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} });
36    exe.root_module.linkFramework("Foundation", .{});
37    exe.root_module.linkFramework("UIKit", .{});
38
39    const check = exe.checkObject();
40    check.checkInHeaders();
41    check.checkExact("cmd BUILD_VERSION");
42    check.checkExact("platform IOS");
43    test_step.dependOn(&check.step);
44}