zuke.tools.apple
@zuke/apple 1.1.0: @zuke/apple — typed task wrappers for Apple's code-signing tools in Zuke builds: codesign, xcrun notarytool, security and ditto.
zuke on PyPI ↗ 38 symbols
Symbols
class AltoolSettings(ToolSettings) Settings for xcrun altool --upload-app and --validate-app.
-
file(path: str) -> SelfThe
.ipaor.pkgto upload or validate (--file); required. -
type_(platform: Literal['ios', 'macos', 'appletvos', 'visionos']) -> SelfThe app's platform (
--type); required. -
api_key(key_id: str, issuer_id: str) -> SelfAuthenticate with an App Store Connect API key: its key id and issuer id (
--apiKey,--apiIssuer).altoolfindsAuthKey_<keyId>.p8in~/.appstoreconnect/private_keysand its other search directories, or in apiPrivateKeysDir. -
api_private_keys_dir(path: str) -> SelfThe directory holding
AuthKey_<keyId>.p8, passed toaltoolasAPI_PRIVATE_KEYS_DIR. -
apple_id(username: str, password: str) -> SelfAuthenticate with an Apple ID and an app-specific password (
--username,--password). The password is handed toaltoolin an environment variable it reads through@env:, so it is never on the command line, and it is registered with the run's redactor.
class AltoolTasks Typed task functions for xcrun altool.
-
static async upload_app(ctx: ServiceContext, configure: Callable[[AltoolSettings], AltoolSettings]) -> ExecResultUpload an app to App Store Connect:
xcrun altool --upload-app. -
static async validate_app(ctx: ServiceContext, configure: Callable[[AltoolSettings], AltoolSettings]) -> ExecResultValidate an app without uploading it:
xcrun altool --validate-app.
class AppStoreConnectSettings(Settings) Settings for a task that calls the App Store Connect API with an API key (*Users and Access → Integrations* in App Store Connect): the issuer id, the key id, and the AuthKey_<keyId>.p8 private key.
The private key and every token signed with it stay out of progress lines and errors. Declare them in the build as parameter(...).secret() so Zuke masks them in its own output too.
-
issuer_id(id: str) -> SelfThe API key's issuer id, a UUID.
-
key_id(id: str) -> SelfThe API key's id, e.g.
ABC123. -
private_key(pem: str) -> SelfThe private key, as the PEM text of
AuthKey_<keyId>.p8. -
private_key_file(path: str) -> SelfRead the private key from
AuthKey_<keyId>.p8. -
api_url(url: str) -> SelfThe API's base URL,
https://api.appstoreconnect.apple.comby default. It carries the token, so it must behttps:unless it is loopback orZUKE_ALLOW_INSECURE_URLis set.
class CodesignDisplaySettings(CodesignSettings) Settings for codesign --display.
class CodesignSettings(ToolSettings) The shared shape of every codesign operation: the files it acts on and how verbose it is. Each operation subclass names its mode flag and its own options.
-
file(*paths: str) -> SelfThe code to act on (positional) — an app bundle, framework, binary or disk image; repeatable. A relative path starting with
-is passed as./-…socodesigncannot read it as an option. -
verbose(level: float | None=None) -> SelfMore output (
--verbose, or--verbose=<level>with a level).displayshows more of the signature at each level;4lists everything.
class CodesignSignSettings(CodesignSettings) Settings for codesign --sign.
-
identity(value: str) -> SelfThe signing identity (
--sign <identity>): a certificate's common name, a substring of it, or its SHA-1 hash.-signs ad hoc. Required. -
force() -> SelfReplace an existing signature (
--force). -
deep() -> SelfSign nested code as well (
--deep). Apple discourages it for signing. -
options(*flags: str) -> SelfSignature option flags (
--options, comma-joined); repeatable.runtimeenables the hardened runtime notarization requires. -
timestamp(url: str | None=None) -> SelfRequest a secure timestamp (
--timestamp), fromurlwhen given (--timestamp=<url>). Notarization requires one. -
entitlements(path: str) -> SelfThe entitlements plist to embed (
--entitlements). -
keychain(path: str) -> SelfLook the identity up in this keychain only (
--keychain). -
identifier(value: str) -> SelfThe code's identifier (
--identifier), overriding the bundle id.
class CodesignTasks Typed task functions for Apple's codesign.
-
static async sign(ctx: ServiceContext, configure: Callable[[CodesignSignSettings], CodesignSignSettings]) -> ExecResultSign code with
codesign --sign. -
static async verify(ctx: ServiceContext, configure: Callable[[CodesignVerifySettings], CodesignVerifySettings]) -> ExecResultCheck a signature with
codesign --verify; a bad one fails the run. -
static async display(ctx: ServiceContext, configure: Callable[[CodesignDisplaySettings], CodesignDisplaySettings]) -> objectDescribe a signature with
codesign --display.codesignprints the description on stderr, so it is returned parsed, with the raw text and the command output alongside.
class CodesignVerifySettings(CodesignSettings) Settings for codesign --verify.
-
strict() -> SelfApply the strict validation rules notarization uses (
--strict). -
deep() -> SelfVerify nested code as well (
--deep).
class DittoSettings(ToolSettings) Settings for a ditto run.
-
create() -> SelfCreate an archive rather than copy (
-c). -
extract() -> SelfExtract an archive rather than copy (
-x). -
pkzip() -> SelfUse the PKZip format for the archive (
-k) instead of CPIO. -
sequester_rsrc() -> SelfKeep resource forks and HFS metadata in a
__MACOSXdirectory inside the archive (--sequesterRsrc), the way the Finder's own compress does. -
keep_parent() -> SelfPut the source directory itself in the archive, not only its contents (
--keepParent) — what makes a zippedMyApp.appunzip asMyApp.app. -
source(path: str) -> SelfWhat to copy or archive (positional). Required.
-
destination(path: str) -> SelfWhere to write it (positional). Required.
class DittoTasks Typed task functions for macOS ditto.
-
static async copy(ctx: ServiceContext, configure: Callable[[DittoSettings], DittoSettings]) -> ExecResultCopy a file or directory tree with
ditto, metadata intact. -
static async archive(ctx: ServiceContext, configure: Callable[[DittoSettings], DittoSettings]) -> ExecResultWrite a zip archive:
ditto -c -k, then the lambda's settings. -
static async extract(ctx: ServiceContext, configure: Callable[[DittoSettings], DittoSettings]) -> ExecResultUnpack a zip archive:
ditto -x -k, then the lambda's settings.
class ExportOptionsSettings(Settings) Settings for an ExportOptions.plist.
-
method(method: Literal['app-store-connect', 'release-testing', 'enterprise', 'debugging', 'developer-id', 'mac-application', 'validation', 'app-store', 'ad-hoc', 'development']) -> SelfHow the archive is exported (
method); required. -
team_id(id: str) -> SelfThe developer team id (
teamID). -
signing_style(style: Literal['automatic', 'manual']) -> SelfAutomatic or manual signing (
signingStyle). -
signing_certificate(name: str) -> SelfThe certificate to sign with, e.g.
Apple Distribution(signingCertificate). -
provisioning_profile(bundle_id: str, profile: str) -> SelfThe provisioning profile, by name or UUID, for one bundle identifier (
provisioningProfiles); repeatable, once per app and extension. -
destination(destination: Literal['export', 'upload']) -> SelfExport to a directory, or upload to App Store Connect (
destination). -
upload_symbols(enabled: bool) -> SelfInclude symbols for crash reports (
uploadSymbols). -
manage_app_version_and_build_number(enabled: bool) -> SelfLet App Store Connect manage the version and build number (
manageAppVersionAndBuildNumber). -
strip_swift_symbols(enabled: bool) -> SelfStrip Swift symbols from the binary (
stripSwiftSymbols). -
test_flight_internal_testing_only(enabled: bool) -> SelfLimit a TestFlight upload to internal testers (
testFlightInternalTestingOnly).
class NotarytoolHistorySettings(NotarytoolSettings) Settings for xcrun notarytool history.
class NotarytoolInfoSettings(NotarytoolSettings) Settings for xcrun notarytool info <id>.
-
submission_id(id: str) -> SelfThe submission to describe (positional). Required.
class NotarytoolLogSettings(NotarytoolSettings) Settings for xcrun notarytool log <id>.
-
submission_id(id: str) -> SelfThe submission whose log to fetch (positional). Required.
class NotarytoolSettings(ToolSettings) The shared settings of every xcrun notarytool subcommand: the credentials, and the masking of the app-specific password. A subclass names its subcommand and builds its own arguments.
-
key(path: str) -> SelfThe App Store Connect API private key file,
AuthKey_<id>.p8(--key). -
key_id(id: str) -> SelfThe API key's id (
--key-id). -
issuer(uuid: str) -> SelfThe API key's issuer UUID (
--issuer); omit it for an individual key. -
keychain_profile(name: str) -> SelfAuthenticate with credentials saved by
notarytool store-credentials(--keychain-profile). -
keychain(path: str) -> SelfThe keychain to read the keychainProfile from (
--keychain). -
apple_id(email: str) -> SelfThe Apple ID to authenticate as (
--apple-id). -
password(value: str) -> SelfThe Apple ID's app-specific password (
--password). Registered with the run's redactor and masked out of any error this run raises. -
team_id(id: str) -> SelfThe developer team id the Apple ID signs for (
--team-id). -
tool_path(path: str) -> SelfOverride the binary, remembered so a follow-up command uses it too.
-
env(record: Mapping[str, str]) -> SelfMerge environment variables, remembered for a follow-up command too.
-
cwd(path: str) -> SelfSet the working directory, remembered for a follow-up command too.
class NotarytoolSubmitSettings(NotarytoolSettings) Settings for xcrun notarytool submit.
-
file(path: str) -> SelfThe archive to notarize — a
.zip,.pkgor.dmg(positional). Required. -
wait() -> SelfWait for Apple to finish processing (
--wait). With it the result carries the final status, andNotarytoolTasks.submitthrows aNotarizationErrorfor anything butAccepted. -
timeout(duration: str) -> SelfHow long
--waitwaits, e.g.30mor1h(--timeout). Needs wait. -
log_for(id: str) -> NotarytoolLogSettingsSettings for
notarytool log <id>that reuse this submission's credentials, binary, environment and working directory.
class NotarytoolTasks Typed task functions for xcrun notarytool.
-
static async submit(ctx: ServiceContext, configure: Callable[[NotarytoolSubmitSettings], NotarytoolSubmitSettings]) -> objectUpload an archive with
notarytool submitand return the parsed result. With.wait(), a final status other thanAcceptedfetches the submission's log and throws a NotarizationError listing its issues — unless.noThrow()was set, when the result is returned for the caller to inspect. -
static async info(ctx: ServiceContext, configure: Callable[[NotarytoolInfoSettings], NotarytoolInfoSettings]) -> objectRead a submission's status with
notarytool info. -
static async log(ctx: ServiceContext, configure: Callable[[NotarytoolLogSettings], NotarytoolLogSettings]) -> objectFetch and parse a submission's notarization log with
notarytool log. -
static async history(ctx: ServiceContext, configure: Callable[[NotarytoolHistorySettings], NotarytoolHistorySettings]) -> objectList the team's past submissions with
notarytool history.
class ProvisioningProfileSettings(Settings) Settings for ProvisioningProfileTasks.
-
file(path: str) -> SelfRead the profile from a
.mobileprovisionfile. -
base64(text: str) -> SelfTake the profile as base64 — how a CI secret usually holds it (
base64 -i profile.mobileprovision). -
directory(path: str) -> SelfInstall into this directory instead of Xcode's two defaults; repeatable.
-
allow_expired() -> SelfInstall the profile even if it has expired.
class ProvisioningProfileTasks Read and install provisioning profiles.
-
static async inspect(ctx: ServiceContext, configure: Callable[[ProvisioningProfileSettings], ProvisioningProfileSettings]) -> objectRead what a profile says about itself, without installing it.
-
static async install(ctx: ServiceContext, configure: Callable[[ProvisioningProfileSettings], ProvisioningProfileSettings]) -> objectInstall a profile where Xcode looks for it, named by its UUID. Refuses an expired profile unless
.allowExpired().
class SecurityCreateKeychainSettings(SecuritySettings) Settings for security create-keychain.
-
password(value: str) -> SelfThe new keychain's password (
-p). A secret: masked in every rendering of the command. Without itsecurityprompts for one. -
keychain(*paths: str) -> SelfThe keychain(s) to create (positional); repeatable. Required.
class SecurityDeleteKeychainSettings(SecuritySettings) Settings for security delete-keychain.
-
keychain(*paths: str) -> SelfThe keychain(s) to delete (positional); repeatable. Required.
class SecurityFindIdentitySettings(SecuritySettings) Settings for security find-identity.
-
policy(name: str) -> SelfOnly identities usable under this policy (
-p), e.g.codesigning. -
search(value: str) -> SelfOnly identities whose name contains this string (
-s). -
valid() -> SelfOnly valid identities (
-v) — not expired, revoked or untrusted. -
keychain(*paths: str) -> SelfThe keychain(s) to search (positional); the search list when omitted.
class SecurityImportSettings(SecuritySettings) Settings for security import.
-
file(path: str) -> SelfThe file to import, e.g. a
.p12(positional). Required. -
keychain(path: str) -> SelfThe keychain to import into (
-k); the default keychain when omitted. -
passphrase(value: str) -> SelfThe file's passphrase (
-P), e.g. a.p12's export password. A secret: masked in every rendering of the command. -
application(*paths: str) -> SelfAn application allowed to use the imported key without a prompt (
-T), e.g./usr/bin/codesign; repeatable. -
type_(value: Literal['pub', 'priv', 'session', 'cert', 'agg']) -> SelfThe type of item in the file (
-t). -
format(value: Literal['openssl', 'openssh1', 'openssh2', 'bsafe', 'raw', 'pkcs7', 'pkcs8', 'pkcs12', 'netscape', 'x509', 'pemseq']) -> SelfThe file's format (
-f), e.g.pkcs12. -
non_extractable() -> SelfMake the imported private key non-extractable (
-x).
class SecurityListKeychainsSettings(SecuritySettings) Settings for security list-keychains.
-
domain(value: Literal['user', 'system', 'common', 'dynamic']) -> SelfThe preference domain to read or set (
-d). -
set(*keychains: str) -> SelfReplace the search list with these keychains (
-s), in order. Called with none, it empties the list. Repeat calls append.
class SecuritySetKeychainSettings(SecuritySettings) Settings for security set-keychain-settings. With no flags, the keychain never locks on its own — no timeout, and no lock on sleep — which is what a CI keychain wants for the length of a build.
-
lock_on_sleep() -> SelfLock the keychain when the machine sleeps (
-l). -
lock_after_timeout() -> SelfLock the keychain after timeout seconds of inactivity (
-u). -
timeout(seconds: float) -> SelfThe inactivity timeout, in seconds (
-t). -
keychain(path: str) -> SelfThe keychain to configure (positional); the default keychain when omitted.
class SecuritySetKeyPartitionListSettings(SecuritySettings) Settings for security set-key-partition-list, which lets Apple's signing tools use a key without the "allow access" prompt that hangs a headless build.
-
partition_list(*ids: str) -> SelfPartition ids to allow (
-S, comma-joined); repeatable.apple-tool:andapple:covercodesignand the other Apple tools. -
private_keys() -> SelfMatch private keys only (
-s). -
password(value: str) -> SelfThe keychain's password (
-k). A secret: masked in every rendering of the command. Without itsecurityprompts for one. -
keychain(path: str) -> SelfThe keychain to modify (positional); the default keychain when omitted.
class SecuritySettings(ToolSettings) The shared settings of every security subcommand: the binary, and the secret handling for the passwords a subcommand takes. A subclass names its subcommand and builds its own arguments.
class SecurityTasks Typed task functions for macOS security.
-
static async create_keychain(ctx: ServiceContext, configure: Callable[[SecurityCreateKeychainSettings], SecurityCreateKeychainSettings]) -> ExecResultCreate a keychain with
security create-keychain. -
static async delete_keychain(ctx: ServiceContext, configure: Callable[[SecurityDeleteKeychainSettings], SecurityDeleteKeychainSettings]) -> ExecResultDelete a keychain with
security delete-keychain. -
static async unlock_keychain(ctx: ServiceContext, configure: Callable[[SecurityUnlockKeychainSettings], SecurityUnlockKeychainSettings]) -> ExecResultUnlock a keychain with
security unlock-keychain. -
static async set_keychain_settings(ctx: ServiceContext, configure: Callable[[SecuritySetKeychainSettings], SecuritySetKeychainSettings]) -> ExecResultChange a keychain's lock settings with
security set-keychain-settings. -
static async import_(ctx: ServiceContext, configure: Callable[[SecurityImportSettings], SecurityImportSettings]) -> ExecResultImport a certificate or key with
security import. -
static async set_key_partition_list(ctx: ServiceContext, configure: Callable[[SecuritySetKeyPartitionListSettings], SecuritySetKeyPartitionListSettings]) -> ExecResultSet which tools may use a key with
security set-key-partition-list. -
static async list_keychains(ctx: ServiceContext, configure: Callable[[SecurityListKeychainsSettings], SecurityListKeychainsSettings] | None=None) -> objectRead — or, with
.set(...), replace — the keychain search list withsecurity list-keychains. Returns the listed paths; empty after a set, which prints nothing. -
static async find_identity(ctx: ServiceContext, configure: Callable[[SecurityFindIdentitySettings], SecurityFindIdentitySettings] | None=None) -> objectList signing identities with
security find-identity, parsed.
class SecurityUnlockKeychainSettings(SecuritySettings) Settings for security unlock-keychain.
-
password(value: str) -> SelfThe keychain's password (
-p). A secret: masked in every rendering of the command. Without itsecurityprompts for one. -
keychain(path: str) -> SelfThe keychain to unlock (positional); the default keychain when omitted.
class TemporaryKeychainSettings(Settings) Settings for SecurityTasks.temporaryKeychain.
-
certificate(base64_p12: str) -> SelfThe signing certificate and its private key, as a base64-encoded
.p12— the form CI secrets hold it in. Whitespace is ignored. Required. It is decoded only into a0600file that is deleted straight after import, and never appears in a command line or an error message. -
certificate_password(value: str) -> SelfThe
.p12's export password, handed tosecurity import -P. A secret: masked in every rendering of that command. Defaults to empty, for a.p12exported without one —securitywould otherwise prompt. -
identity(filter: str) -> SelfPick the identity whose name contains
filter, or whose SHA-1 hash it is. Needed only when the.p12holds more than one codesigning identity. -
application(*paths: str) -> SelfAn application allowed to use the imported key (
security import -T); repeatable. Defaults to/usr/bin/codesignwhen none is named. -
tool_path(path: str) -> SelfRun this
securitybinary instead of the one onPATH.
class TestFlightSettings(AppStoreConnectSettings) Settings for TestFlightTasks.distribute.
-
bundle_id(id: str) -> SelfThe app's bundle id, e.g.
com.example.app; required. -
build_number(number: str | float) -> SelfThe uploaded build's number,
CFBundleVersion; required. -
version(version: str) -> SelfThe uploaded build's version,
CFBundleShortVersionString— needed when the same build number exists under several versions. -
platform(platform: Literal['IOS', 'MAC_OS', 'TV_OS', 'VISION_OS']) -> SelfThe build's platform — needed when the app ships on several.
-
timeout(duration: str | float) -> SelfThe longest wait for the build to finish processing (
"45m", or ms); default 30 minutes. -
poll_interval(duration: str | float) -> SelfThe time between two looks at the build (
"1m", or ms); default 30 seconds. -
uses_non_exempt_encryption(uses: bool) -> SelfAnswer the export-compliance question: whether the app uses encryption beyond the exempt kinds. Until it is answered — here, or by
ITSAppUsesNonExemptEncryptioninInfo.plist— the build sits at *Missing Compliance* and no tester can install it. -
what_to_test(text: str, locale: str | None=None) -> SelfThe "What to Test" notes testers see, per locale; default locale
en-US. -
group(name: str) -> SelfAdd the build to this beta group, by name; repeatable.
-
submit_for_beta_review() -> SelfSubmit the build for beta review, which external testing needs.
class TestFlightTasks Distribute builds in TestFlight through the App Store Connect API.
-
static async distribute(ctx: ServiceContext, configure: Callable[[TestFlightSettings], TestFlightSettings]) -> objectWait for an uploaded build to be processed, then distribute it in TestFlight as configured.
class XcodebuildArchiveSettings(XcodebuildProjectSettings) Settings for xcodebuild archive.
-
archive_path(path: str) -> SelfWhere to write the
.xcarchive(-archivePath); required.
class XcodebuildExportArchiveSettings(XcodebuildSettings) Settings for xcodebuild -exportArchive.
-
archive_path(path: str) -> SelfThe
.xcarchiveto export (-archivePath); required. -
export_path(path: str) -> SelfThe directory to write the export to (
-exportPath); required. -
export_options_plist(path: str) -> SelfThe export options (
-exportOptionsPlist); required. Write one withXcodebuildTasks.writeExportOptions.
class XcodebuildProjectSettings(XcodebuildSettings) The project flags every build action takes. Each action names itself and its own flags; the project flags come first, then the action, then the build settings.
-
workspace(path: str) -> SelfThe workspace to build, e.g.
App.xcworkspace(-workspace). -
project(path: str) -> SelfThe project to build, e.g.
App.xcodeproj(-project). -
scheme(name: str) -> SelfThe scheme to build (
-scheme); required with a workspace. A later call replaces it. -
configuration(name: str) -> SelfThe build configuration, e.g.
Release(-configuration). A later call replaces it. -
sdk(name: str) -> SelfThe SDK, e.g.
iphoneosoriphonesimulator(-sdk). A later call replaces it. -
destination(specifier: str) -> SelfA destination, e.g.
generic/platform=iOSorplatform=iOS Simulator,name=iPhone 16(-destination); repeatable. -
derived_data_path(path: str) -> SelfWhere intermediate build files go (
-derivedDataPath). -
cloned_source_packages_dir_path(path: str) -> SelfWhere Swift packages are checked out (
-clonedSourcePackagesDirPath). -
result_bundle_path(path: str) -> SelfWrite an
.xcresultbundle with the logs and results (-resultBundlePath). -
xcconfig(path: str) -> SelfApply an
.xcconfigfile's settings over every target (-xcconfig). -
build_setting(name: str, value: str) -> SelfOverride a build setting for every target, e.g.
("DEVELOPMENT_TEAM", "ABCDE12345")→DEVELOPMENT_TEAM=ABCDE12345; repeatable. A condition goes in the name:CODE_SIGN_IDENTITY[sdk=iphoneos*].
class XcodebuildSettings(ToolSettings) Base for all xcodebuild settings: the binary is xcodebuild, on PATH.
-
quiet_output() -> SelfPrint only warnings and errors (
-quiet). -
allow_provisioning_updates() -> SelfLet Xcode create and update provisioning profiles and certificates (
-allowProvisioningUpdates); on CI, pair it with authenticationKey. -
authentication_key(path: str, key_id: str, issuer_id: str) -> SelfSign in to the developer account with an App Store Connect API key instead of an Xcode account: the
AuthKey_<id>.p8file, its key id and its issuer id (-authenticationKeyPath,-authenticationKeyID,-authenticationKeyIssuerID).
class XcodebuildShowBuildSettings(XcodebuildProjectSettings) Settings for xcodebuild -showBuildSettings.
-
json() -> SelfPrint the settings as JSON (
-json).
class XcodebuildTasks Typed task functions for xcodebuild.
-
static async archive(ctx: ServiceContext, configure: Callable[[XcodebuildArchiveSettings], XcodebuildArchiveSettings]) -> ExecResultBuild an
.xcarchive:xcodebuild archive. -
static async export_archive(ctx: ServiceContext, configure: Callable[[XcodebuildExportArchiveSettings], XcodebuildExportArchiveSettings]) -> ExecResultExport an archive to an
.ipa, or upload it:xcodebuild -exportArchive. -
static async show_build_settings(ctx: ServiceContext, configure: Callable[[XcodebuildShowBuildSettings], XcodebuildShowBuildSettings] | None=None) -> ExecResultPrint the resolved build settings:
xcodebuild -showBuildSettings. -
static async write_export_options(ctx: ServiceContext, path: str, configure: Callable[[ExportOptionsSettings], ExportOptionsSettings]) -> NoneWrite an
ExportOptions.plistfor exportArchive topath. Runs no subprocess.