apple-swift-package-bootstrap
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApple Swift Package Bootstrap
Apple Swift Package 引导初始化工具
Purpose
用途
Create a new Swift package repository with one top-level entry point and a simplicity-first Swift baseline. is the runtime wrapper, and remains the implementation core for scaffold creation and validation.
scripts/run_workflow.pyscripts/bootstrap_swift_package.sh创建带有单一顶层入口、遵循简约优先Swift基线的新Swift包代码仓库。是运行时封装脚本,是脚手架创建和校验的核心实现。
scripts/run_workflow.pyscripts/bootstrap_swift_package.shWhen To Use
适用场景
- Use this skill for new Swift package scaffolding.
- Use this skill when the user wants consistent package defaults, generation, and immediate validation.
AGENTS.md - Use this skill when the user wants to customize the documented bootstrap defaults for future runs.
- Do not use this skill as the default path for normal Xcode app collaboration work.
- Recommend when the user is working in an existing Xcode project or needs Apple-platform execution after bootstrap.
apple-xcode-workflow - Recommend when the user needs Dash docset search, install, or generation work.
apple-dash-docsets
- 为新Swift包搭建脚手架时使用本工具
- 当用户需要一致的包默认配置、生成和即时校验能力时使用本工具
AGENTS.md - 当用户需要自定义引导默认配置用于后续运行时使用本工具
- 请勿将本工具作为常规Xcode应用协作工作的默认流程
- 当用户在现有Xcode项目中工作,或引导初始化后需要Apple平台执行能力时,推荐使用
apple-xcode-workflow - 当用户需要Dash文档集的搜索、安装或生成工作时,推荐使用
apple-dash-docsets
Single-Path Workflow
单路径工作流
- Collect the required inputs:
nametypedestinationplatformversion_profile- optional
testing_mode - optional
skip_validation
- Normalize aliases exactly as does:
scripts/bootstrap_swift_package.shmacos -> macios -> mobileboth -> multiplatformlatest -> latest-majorminus-one -> current-minus-oneminus-two -> current-minus-two
- Run so documented defaults are loaded from customization state and normalized into one JSON contract.
scripts/run_workflow.py - Select testing mode before scaffold creation:
- require a supported and validated toolchain floor before bootstrap planning continues
Swift 5.10+ - prefer on supported current toolchains
swift-testing - use when explicitly requested or when the supported toolchain requires it
xctest - stop with when the local toolchain is older than
blockedor when the local5.10command cannot select the requested testing modeswift package init
- require a supported and validated
- Let the wrapper invoke the bundled script:
bash
scripts/bootstrap_swift_package.sh --name <Name> --type <library|executable|tool> --destination <dir> --platform <mac|macos|mobile|ios|multiplatform|both> --version-profile <latest-major|current-minus-one|current-minus-two|latest|minus-one|minus-two> --testing-mode <swift-testing|xctest> - Verify the generated repository:
Package.swift.gitAGENTS.mdTests/- and
swift buildunlessswift testwas requested--skip-validation
- Ensure the generated guidance encodes the shared Swift policy:
- apply the detailed local policy in
references/snippets/apple-swift-core.md - keep the generated repo aligned with the simplicity-first, shape-preserving, and anti-ceremony Swift guidance in that snippet
- preserve the project-appropriate logging, telemetry, and SwiftUI architecture guidance from that snippet
- apply the detailed local policy in
- Hand off package execution guidance cleanly:
- use and
swift buildby defaultswift test - recommend for package builds that need Xcode-managed toolchain behavior, such as package builds that depend on Xcode-provided Metal or other Apple-managed build assets
apple-xcode-workflow
- use
- Return one JSON execution summary with the created path, normalized options, and validation result.
- 收集必填输入项:
nametypedestinationplatformversion_profile- 可选
testing_mode - 可选
skip_validation
- 完全按照的规则对别名进行标准化:
scripts/bootstrap_swift_package.shmacos -> macios -> mobileboth -> multiplatformlatest -> latest-majorminus-one -> current-minus-oneminus-two -> current-minus-two
- 运行,从自定义配置中加载已记录的默认值并标准化为统一JSON契约
scripts/run_workflow.py - 在创建脚手架前选择测试模式:
- 继续引导流程前要求本地安装了支持且校验通过的工具链最低版本
Swift 5.10+ - 在支持的当前工具链上优先使用
swift-testing - 当用户明确要求或当前工具链要求时使用
xctest - 当本地工具链版本低于或本地
5.10命令无法选择请求的测试模式时,返回swift package init状态终止流程blocked
- 继续引导流程前要求本地安装了支持且校验通过的
- 由封装脚本调用捆绑的执行脚本:
bash
scripts/bootstrap_swift_package.sh --name <Name> --type <library|executable|tool> --destination <dir> --platform <mac|macos|mobile|ios|multiplatform|both> --version-profile <latest-major|current-minus-one|current-minus-two|latest|minus-one|minus-two> --testing-mode <swift-testing|xctest> - 校验生成的代码仓库:
Package.swift.gitAGENTS.mdTests/- 除非指定了参数,否则执行
--skip-validation和swift build校验swift test
- 确保生成的指南符合通用Swift规范:
- 应用中的详细本地规范
references/snippets/apple-swift-core.md - 保持生成的仓库符合该代码片段中简约优先、结构保留、减少冗余流程的Swift指南
- 保留该代码片段中适配项目的日志、遥测和SwiftUI架构指南
- 应用
- 清晰交接包执行指南:
- 默认使用和
swift buildswift test - 当包构建需要Xcode管理的工具链能力时,比如依赖Xcode提供的Metal或其他Apple管理的构建资产的包构建,推荐使用
apple-xcode-workflow
- 默认使用
- 返回包含创建路径、标准化参数和校验结果的JSON执行摘要
Inputs
输入参数
- : required; must start with a letter and contain only letters, numbers,
name, or_.- - :
type,library, or advanced explicitexecutable.tool - : parent directory for the new package.
destination - :
platform,mac, ormobile, with aliases normalized by the script.multiplatform - :
version_profile,latest-major, orcurrent-minus-one, with aliases normalized by the script.current-minus-two - :
testing_modeorswift-testing.xctest - : optional flag to skip
skip_validationandswift build.swift test - : optional flag to resolve defaults and emit the normalized command contract without creating files.
dry_run - Defaults:
- runtime entrypoint: executable
scripts/run_workflow.py - defaults to
typelibrary - defaults to
destination. - defaults to
platformmultiplatform - defaults to
version_profilecurrent-minus-one - defaults to
testing_modeswift-testing - validation runs unless is passed
--skip-validation - supported and validated Swift toolchain floor is
5.10+
- runtime entrypoint: executable
- : 必填;必须以字母开头,仅包含字母、数字、
name或_- - :
type、library或高级显式类型executabletool - : 新包的父目录
destination - :
platform、mac或mobile,别名由脚本自动标准化multiplatform - :
version_profile、latest-major或current-minus-one,别名由脚本自动标准化current-minus-two - :
testing_mode或swift-testingxctest - : 可选标记,跳过
skip_validation和swift build校验swift test - : 可选标记,仅解析默认值并输出标准化命令契约,不创建实际文件
dry_run - 默认值:
- 运行时入口:可执行文件
scripts/run_workflow.py - 默认值为
typelibrary - 默认值为
destination. - 默认值为
platformmultiplatform - 默认值为
version_profilecurrent-minus-one - 默认值为
testing_modeswift-testing - 除非传入参数,否则默认执行校验
--skip-validation - 支持且校验通过的Swift工具链最低版本为
5.10+
- 运行时入口:可执行文件
Outputs
输出参数
status- : the package was created and verification succeeded
success - : prerequisites, unsupported toolchains, unsupported testing-mode selections, or target-directory constraints prevented the run
blocked - : the script started but did not complete successfully
failed
path_type- : the bundled script completed successfully
primary - : manual scaffold guidance is being used instead of the bundled script
fallback
output- resolved package path
- normalized inputs
- validation result
- one concise next step
status- : 包创建完成且校验通过
success - : 前置依赖缺失、不支持的工具链、不支持的测试模式选择或目标目录约束导致流程无法运行
blocked - : 脚本已启动但未成功完成
failed
path_type- : 捆绑脚本执行成功
primary - : 未使用捆绑脚本,使用手动脚手架指南
fallback
output- 解析后的包路径
- 标准化后的输入参数
- 校验结果
- 简洁的下一步操作建议
Guards and Stop Conditions
拦截与终止条件
- Stop with if
blockedis missing.swift - Stop with if
blockedcannot be parsed into a supported toolchain version.swift --version - Stop with if the local Swift toolchain is older than
blocked.5.10 - Stop with if
blockedis missing.git - Stop with if
blockedis missing.assets/AGENTS.md - Stop with if the target exists and contains non-ignorable files.
blocked - Stop with if
blockedis missing.name - Stop with if the requested testing mode cannot be honored by the active
blockedcommand.swift package init
- 如果缺失命令,返回
swift终止流程blocked - 如果的输出无法解析为支持的工具链版本,返回
swift --version终止流程blocked - 如果本地Swift工具链版本低于,返回
5.10终止流程blocked - 如果缺失命令,返回
git终止流程blocked - 如果缺失文件,返回
assets/AGENTS.md终止流程blocked - 如果目标路径已存在且包含不可忽略的文件,返回终止流程
blocked - 如果缺失参数,返回
name终止流程blocked - 如果当前命令不支持请求的测试模式,返回
swift package init终止流程blocked
Fallbacks and Handoffs
降级方案与流程交接
- Preferred path is always .
scripts/bootstrap_swift_package.sh - Use manual guidance only when the script is unavailable or the user explicitly asks for the manual path.
swift package init - is an advanced explicit passthrough, not a default branch of the workflow.
tool - After a successful scaffold, hand off build, test, or Xcode-managed package execution tasks to .
apple-xcode-workflow - For ordinary package work, prefer and
swift build.swift test - For package builds that need Xcode-managed SDK or toolchain behavior, use and
apple-xcode-workflowguidance instead of stretching the bootstrap skill into an execution skill.xcodebuild - Recommend directly when the user’s next step is Dash docset or cheatsheet management.
apple-dash-docsets - is the top-level runtime entrypoint and converts the shell script result into the documented JSON contract.
scripts/run_workflow.py
- 优先执行路径始终为
scripts/bootstrap_swift_package.sh - 仅当脚本不可用或用户明确要求手动流程时,使用手动指南
swift package init - 是高级显式透传类型,不是工作流的默认分支
tool - 脚手架创建成功后,将构建、测试或Xcode管理的包执行任务交接给
apple-xcode-workflow - 常规包开发工作优先使用和
swift buildswift test - 对于需要Xcode管理的SDK或工具链能力的包构建,使用和
apple-xcode-workflow指南,不要将本引导工具扩展为执行工具xcodebuild - 当用户的下一步操作是Dash文档集或速查表管理时,直接推荐
apple-dash-docsets - 是顶层运行时入口,将Shell脚本的执行结果转换为已定义的JSON契约
scripts/run_workflow.py
Customization
自定义配置
- Use .
references/customization-flow.md - stores and reports customization state.
scripts/customization_config.py - loads runtime-safe defaults from customization state before invoking the shell script.
scripts/run_workflow.py - now honors the wrapper's git and
scripts/bootstrap_swift_package.shcopy flags.AGENTS.md
- 参考
references/customization-flow.md - 用于存储和查询自定义配置状态
scripts/customization_config.py - 在调用Shell脚本前从自定义配置中加载运行时安全的默认值
scripts/run_workflow.py - 现在支持封装脚本传入的git和
scripts/bootstrap_swift_package.sh复制标记AGENTS.md
References
参考资料
Workflow References
工作流参考
references/package-types.md
references/package-types.md
Contract References
契约参考
references/automation-prompts.mdreferences/customization-flow.md
references/automation-prompts.mdreferences/customization-flow.md
Support References
支持参考
- Recommend when the new package repo should start with reusable Apple and Swift baseline policy content next to the generated
references/snippets/apple-swift-core.md.AGENTS.md assets/AGENTS.mdreferences/snippets/apple-swift-core.md
- 当新包仓库需要在生成的旁添加可复用的Apple和Swift基线规范内容时,推荐参考
AGENTS.mdreferences/snippets/apple-swift-core.md assets/AGENTS.mdreferences/snippets/apple-swift-core.md
Script Inventory
脚本清单
scripts/run_workflow.pyscripts/bootstrap_swift_package.shscripts/customization_config.py
scripts/run_workflow.pyscripts/bootstrap_swift_package.shscripts/customization_config.py