guide-macos-spm-packaging
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGuide Skill — This is an expert workflow/pattern guide, not API reference documentation. Originally from Dimillian/Skills by Thomas Ricouard. MIT License.
指南技能 — 这是一份专家级工作流/模式指南,而非API参考文档。 最初来自Thomas Ricouard的Dimillian/Skills项目,采用MIT License。
macOS SwiftPM App Packaging (No Xcode)
无需Xcode的macOS SwiftPM应用打包
Overview
概述
Bootstrap a complete SwiftPM macOS app folder, then build, package, and run it without Xcode. Use for the starter layout and + for packaging and release details.
assets/templates/bootstrap/references/packaging.mdreferences/release.md引导搭建一套完整的SwiftPM macOS应用目录,随后无需Xcode即可完成构建、打包和运行。你可以使用作为初始结构,参考 + 了解打包和发布的详细信息。
assets/templates/bootstrap/references/packaging.mdreferences/release.mdTwo-Step Workflow
两步工作流
-
Bootstrap the project folder
- Copy into a new repo.
assets/templates/bootstrap/ - Rename in
MyApp,Package.swift, andSources/MyApp/.version.env - Customize ,
APP_NAME, and versions.BUNDLE_ID
- Copy
-
Build, package, and run the bootstrapped app
- Copy scripts from into your repo (for example,
assets/templates/).Scripts/ - Build/tests: and
swift build.swift test - Package: .
Scripts/package_app.sh - Run: (preferred) or
Scripts/compile_and_run.sh.Scripts/launch.sh - Release (optional): and
Scripts/sign-and-notarize.sh.Scripts/make_appcast.sh - Tag + GitHub release (optional): create a git tag, upload the zip/appcast to the GitHub release, and publish.
- Copy scripts from
-
初始化项目目录
- 将拷贝到新的代码仓库中。
assets/templates/bootstrap/ - 分别修改、
Package.swift和Sources/MyApp/中的version.env命名。MyApp - 自定义、
APP_NAME和版本号。BUNDLE_ID
- 将
-
构建、打包并运行初始化好的应用
- 将下的脚本拷贝到你的仓库中(比如放到
assets/templates/目录下)。Scripts/ - 构建/测试:执行和
swift build命令。swift test - 打包:执行。
Scripts/package_app.sh - 运行:执行(推荐)或
Scripts/compile_and_run.sh。Scripts/launch.sh - 发布(可选):执行和
Scripts/sign-and-notarize.sh。Scripts/make_appcast.sh - 打标签 + GitHub发布(可选):创建git tag,将zip包/appcast文件上传到GitHub Release页面并发布。
- 将
Templates
模板说明
- : Build binaries, create the .app bundle, copy resources, sign.
assets/templates/package_app.sh - : Dev loop to kill running app, package, launch.
assets/templates/compile_and_run.sh - : Generate .icns from an Icon Composer file (requires Xcode install).
assets/templates/build_icon.sh - : Notarize, staple, and zip a release build.
assets/templates/sign-and-notarize.sh - : Generate Sparkle appcast entries for updates.
assets/templates/make_appcast.sh - : Create a stable dev code-signing identity.
assets/templates/setup_dev_signing.sh - : Simple launcher for a packaged .app.
assets/templates/launch.sh - : Example version file consumed by packaging scripts.
assets/templates/version.env - : Minimal SwiftPM macOS app skeleton (Package.swift, Sources/, version.env).
assets/templates/bootstrap/
- :构建二进制文件、生成.app包、拷贝资源、签名。
assets/templates/package_app.sh - :开发闭环脚本,用于杀死正在运行的应用、打包、启动。
assets/templates/compile_and_run.sh - :从Icon Composer文件生成.icns图标(需要安装Xcode)。
assets/templates/build_icon.sh - :对发布版本进行公证、打钉、打包成zip。
assets/templates/sign-and-notarize.sh - :生成用于更新的Sparkle appcast条目。
assets/templates/make_appcast.sh - :创建稳定的开发环境代码签名身份。
assets/templates/setup_dev_signing.sh - :用于启动已打包.app的简易启动器。
assets/templates/launch.sh - :打包脚本使用的示例版本配置文件。
assets/templates/version.env - :最简SwiftPM macOS应用骨架(包含Package.swift、Sources/目录、version.env)。
assets/templates/bootstrap/
Notes
注意事项
- Keep entitlements and signing configuration explicit; edit the template scripts instead of reimplementing.
- Remove Sparkle steps if you do not use Sparkle for updates.
- Sparkle relies on the bundle build number (), so
CFBundleVersioninBUILD_NUMBERmust increase for each update.version.env - For menu bar apps, set when packaging to emit
MENU_BAR_APP=1in Info.plist.LSUIElement
- 请显式配置权限和签名参数,直接修改模板脚本即可,无需重新实现。
- 如果你不使用Sparkle做更新,可以移除相关步骤。
- Sparkle依赖包构建号(),因此每次更新都必须提高
CFBundleVersion中的version.env值。BUILD_NUMBER - 如果是菜单栏应用,打包时设置,即可在Info.plist中生成
MENU_BAR_APP=1配置。LSUIElement