Expand description
Interact with Apple SDKs.
§Important Concepts
A developer directory is a filesystem tree holding SDKs and tools.
If you have Xcode installed, this is likely /Applications/Xcode.app/Contents/Developer
.
A platform is a target OS/environment that you build applications for.
These typically correspond to *.platform
directories under Platforms
subdirectory in the developer directory. e.g.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
.
An SDK holds header files, library stubs, and other files enabling you
to compile applications targeting a platform for a supported version range.
SDKs usually exist in an SDKs
directory under a platform directory. e.g.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/SDKs/MacOSX12.3.sdk
or /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk
.
§Developer Directories
Developer Directories are modeled via the DeveloperDirectory struct. This type contains functions for locating developer directories and resolving the default developer directory to use.
§Apple Platforms
We model an abstract Apple platform via the Platform enum.
A directory containing an Apple platform is represented by the PlatformDirectory struct.
§Apple SDKs
We model Apple SDKs using the SimpleSdk and ParsedSdk types. The
latter requires the parse
crate feature in order to activate support for
parsing JSON and plist files.
Both these types are essentially a reference to a directory. SimpleSdk
is little more than a reference to a filesystem path. However, ParsedSdk
parses the SDKSettings.json
or SDKSettings.plist
file within the SDK
and is able to obtain rich metadata about the SDK, such as the names of
machine architectures it can target, which OS versions it supports targeting,
and more.
Both these types implement the AppleSdk trait, which you’ll likely want to import in order to use its APIs for searching for and constructing SDKs.
§SDK Searching
This crate supports searching for an appropriate SDK to use given search parameters and requirements. This functionality can be used to locate the most appropriate SDK from many available on the current system.
This functionality is exposed through the SdkSearch struct. See its documentation for more.
§Common Functionality
To locate the default SDK to use, do something like this:
use apple_sdk::{SdkSearch, Platform, SimpleSdk, SdkSorting, AppleSdk};
// This search will honor the `SDKROOT` and `DEVELOPER_DIR` environment variables.
let sdks = SdkSearch::default()
.platform(Platform::MacOsX)
// Ideally we'd call e.g. `.deployment_target("macosx", "11.0")` to require
// the SDK to support a specific deployment target. This requires the
// `ParsedSdk` type, which requires the `parse` crate feature.
.sorting(SdkSorting::VersionDescending)
.search::<SimpleSdk>()
.expect("failed to search for SDKs");
if let Some(sdk) = sdks.first() {
println!("{}", sdk.sdk_path());
}
Structs§
- Developer
Directory - A directory containing Apple platforms, SDKs, and other tools.
- Parsed
Sdk - An Apple SDK with parsed settings.
- Platform
Directory - Represents an Apple Platform directory.
- SdkPath
- Represents an SDK path with metadata parsed from the path.
- SdkSearch
- Search parameters for locating an Apple SDK.
- SdkSettings
Json - Used for deserializing a SDKSettings.json file in an SDK directory.
- SdkSettings
Json Default Properties - Represents the DefaultProperties key in a SDKSettings.json file.
- SdkVersion
- Represents an SDK version string.
- Simple
Sdk - A directory purported to hold an Apple SDK.
- Supported
Target - Represents a SupportedTargets value in a SDKSettings.json file.
Enums§
- Error
- Error type for this crate.
- Platform
- A known Apple platform type.
- SdkSearch
Event - Describes an event during SDK discovery.
- SdkSearch
Location - Represents a location to search for SDKs.
- SdkSorting
- Sorting strategy to apply to SDK searches.
Constants§
- COMMAND_
LINE_ TOOLS_ DEFAULT_ PATH - Default install path for the Xcode command line tools.
- XCODE_
APP_ DEFAULT_ PATH - Default path to Xcode application.
- XCODE_
APP_ RELATIVE_ PATH_ DEVELOPER - Relative path under Xcode.app directories defining a
Developer
directory.
Traits§
- Apple
Sdk - Defines common behavior for types representing Apple SDKs.
Functions§
- command_
line_ tools_ sdks_ directory - Obtain the path to SDKs within an Xcode Command Line Tools installation.
- find_
system_ xcode_ applications - Find all system installed Xcode applications.
- find_
xcode_ apps - Attempt to resolve all available Xcode applications in an
Applications
directory.
Type Aliases§
- SdkProgress
Callback - A callable that receives progress during an SDK search.