Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

isSdkInstalled

Public Function
std.zig.system.darwin.isSdkInstalled
pub fn isSdkInstalled(gpa: Allocator, io: Io) bool

Check if SDK is installed on Darwin without triggering CLT installation popup window.

Simply invoking xcrun will inevitably trigger the CLT installation popup. Therefore, we resort to invoking xcode-select --print-path and checking if the status is nonzero.

stderr from xcode-select is ignored.

If error.OutOfMemory occurs in Allocator, this function returns null.

Params

File

zig/system/darwin.zig:19
19
20
21
22
23
24
25
26
27
28
29
30
31
pub fn isSdkInstalled(gpa: Allocator, io: Io) bool {
    const result = std.process.run(gpa, io, .{
        .argv = &.{ "xcode-select", "--print-path" },
    }) catch return false;
    defer {
        gpa.free(result.stderr);
        gpa.free(result.stdout);
    }
    return switch (result.term) {
        .exited => |code| if (code == 0) result.stdout.len > 0 else false,
        else => false,
    };
}