macos-spm-app-packaging by dimillian/skills
npx skills add https://github.com/dimillian/skills --skill macos-spm-app-packaging引导创建一个完整的 SwiftPM macOS 应用文件夹,然后无需 Xcode 即可构建、打包和运行它。使用 assets/templates/bootstrap/ 作为初始布局,参考 references/packaging.md 和 references/release.md 获取打包和发布详情。
引导项目文件夹
assets/templates/bootstrap/ 复制到新的仓库中。Package.swift、Sources/MyApp/ 和 version.env 中的 MyApp。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
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。从引导到运行应用的最短路径:
# 1. 复制并重命名骨架项目
cp -R assets/templates/bootstrap/ ~/Projects/MyApp
cd ~/Projects/MyApp
sed -i '' 's/MyApp/HelloApp/g' Package.swift version.env
# 2. 复制脚本
cp assets/templates/package_app.sh Scripts/
cp assets/templates/compile_and_run.sh Scripts/
chmod +x Scripts/*.sh
# 3. 构建并启动
swift build
Scripts/compile_and_run.sh
在关键步骤后运行这些命令,以便在进入下一阶段之前尽早发现失败。
打包后 (Scripts/package_app.sh):
# 确认 .app 包结构完整
ls -R build/HelloApp.app/Contents
# 检查二进制文件是否存在且可执行
file build/HelloApp.app/Contents/MacOS/HelloApp
签名后 (Scripts/sign-and-notarize.sh 或临时开发签名):
# 检查签名和权利
codesign -dv --verbose=4 build/HelloApp.app
# 验证该包在本地通过 Gatekeeper 检查
spctl --assess --type execute --verbose build/HelloApp.app
公证和装订后:
# 确认装订票据已附加
stapler validate build/HelloApp.app
# 重新运行 Gatekeeper 以确认公证被识别
spctl --assess --type execute --verbose build/HelloApp.app
| 症状 | 可能原因 | 恢复措施 |
|---|---|---|
软件资源已上传 | 同一版本的重复提交 | 增加 version.env 中的 BUILD_NUMBER 并重新打包。 |
包无效:无效的代码签名权利 | .entitlements 文件中的权利与配置不匹配 | 对照 Apple 允许的权利集审核权利;移除不受支持的键。 |
可执行文件未启用强化运行时 | codesign 调用中缺少 --options runtime 标志 | 编辑 sign-and-notarize.sh,在所有 codesign 调用中添加 --options runtime。 |
| 公证挂起 / 无状态邮件 | xcrun notarytool 网络或凭据问题 | 运行 xcrun notarytool history 检查状态;如果过期,重新导出 App Store Connect API 密钥。 |
公证成功后 stapler validate 失败 | 票据尚未传播 | 等待约 60 秒,然后重新运行 xcrun stapler staple。 |
assets/templates/package_app.sh: 构建二进制文件,创建 .app 包,复制资源,签名。assets/templates/compile_and_run.sh: 开发循环,用于终止正在运行的应用、打包、启动。assets/templates/build_icon.sh: 从 Icon Composer 文件生成 .icns(需要安装 Xcode)。assets/templates/sign-and-notarize.sh: 对发布版本进行公证、装订和压缩。assets/templates/make_appcast.sh: 为更新生成 Sparkle appcast 条目。assets/templates/setup_dev_signing.sh: 创建稳定的开发代码签名身份。assets/templates/launch.sh: 用于打包的 .app 的简单启动器。assets/templates/version.env: 由打包脚本使用的示例版本文件。assets/templates/bootstrap/: 最小的 SwiftPM macOS 应用骨架(Package.swift, Sources/, version.env)。CFBundleVersion),因此 version.env 中的 BUILD_NUMBER 必须在每次更新时递增。MENU_BAR_APP=1,以在 Info.plist 中生成 LSUIElement。每周安装量
400
仓库
GitHub 星标数
2.3K
首次出现
2026年1月20日
安全审计
安装于
codex332
opencode322
claude-code322
gemini-cli302
cursor274
github-copilot267
Bootstrap a complete SwiftPM macOS app folder, then build, package, and run it without Xcode. Use assets/templates/bootstrap/ for the starter layout and references/packaging.md + references/release.md for packaging and release details.
Bootstrap the project folder
assets/templates/bootstrap/ into a new repo.MyApp in Package.swift, Sources/MyApp/, and version.env.APP_NAME, BUNDLE_ID, and versions.Build, package, and run the bootstrapped app
assets/templates/ into your repo (for example, Scripts/).swift build and swift test.Scripts/package_app.sh.Scripts/compile_and_run.sh (preferred) or Scripts/launch.sh.Scripts/sign-and-notarize.sh and Scripts/make_appcast.sh.Shortest path from bootstrap to a running app:
# 1. Copy and rename the skeleton
cp -R assets/templates/bootstrap/ ~/Projects/MyApp
cd ~/Projects/MyApp
sed -i '' 's/MyApp/HelloApp/g' Package.swift version.env
# 2. Copy scripts
cp assets/templates/package_app.sh Scripts/
cp assets/templates/compile_and_run.sh Scripts/
chmod +x Scripts/*.sh
# 3. Build and launch
swift build
Scripts/compile_and_run.sh
Run these after key steps to catch failures early before proceeding to the next stage.
After packaging (Scripts/package_app.sh):
# Confirm .app bundle structure is intact
ls -R build/HelloApp.app/Contents
# Check that the binary is present and executable
file build/HelloApp.app/Contents/MacOS/HelloApp
After signing (Scripts/sign-and-notarize.sh or ad-hoc dev signing):
# Inspect signature and entitlements
codesign -dv --verbose=4 build/HelloApp.app
# Verify the bundle passes Gatekeeper checks locally
spctl --assess --type execute --verbose build/HelloApp.app
After notarization and stapling:
# Confirm the staple ticket is attached
stapler validate build/HelloApp.app
# Re-run Gatekeeper to confirm notarization is recognised
spctl --assess --type execute --verbose build/HelloApp.app
| Symptom | Likely Cause | Recovery |
|---|---|---|
The software asset has already been uploaded | Duplicate submission for same version | Bump BUILD_NUMBER in version.env and repackage. |
Package Invalid: Invalid Code Signing Entitlements | Entitlements in .entitlements file don't match provisioning | Audit entitlements against Apple's allowed set; remove unsupported keys. |
The executable does not have the hardened runtime enabled | Missing flag in invocation |
assets/templates/package_app.sh: Build binaries, create the .app bundle, copy resources, sign.assets/templates/compile_and_run.sh: Dev loop to kill running app, package, launch.assets/templates/build_icon.sh: Generate .icns from an Icon Composer file (requires Xcode install).assets/templates/sign-and-notarize.sh: Notarize, staple, and zip a release build.assets/templates/make_appcast.sh: Generate Sparkle appcast entries for updates.assets/templates/setup_dev_signing.sh: Create a stable dev code-signing identity.assets/templates/launch.sh: Simple launcher for a packaged .app.assets/templates/version.env: Example version file consumed by packaging scripts.CFBundleVersion), so BUILD_NUMBER in version.env must increase for each update.MENU_BAR_APP=1 when packaging to emit LSUIElement in Info.plist.Weekly Installs
400
Repository
GitHub Stars
2.3K
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex332
opencode322
claude-code322
gemini-cli302
cursor274
github-copilot267
--options runtimecodesignEdit sign-and-notarize.sh to add --options runtime to all codesign calls. |
| Notarization hangs / no status email | xcrun notarytool network or credential issue | Run xcrun notarytool history to check status; re-export App Store Connect API key if expired. |
stapler validate fails after successful notarization | Ticket not yet propagated | Wait ~60 s, then re-run xcrun stapler staple. |
assets/templates/bootstrap/: Minimal SwiftPM macOS app skeleton (Package.swift, Sources/, version.env).