使用 Xcode 构建后脚本创建 ZIP 存档
我正在开发一个超级简单的小应用程序,我将其作为 ZIP 存档分发。该存档包含应用程序本身、自述文件和一些脚本。我想自动化这个过程,所以我将脚本添加到我的项目中,并通过复制文件构建阶段将它们自动复制到构建文件夹中。
现在,我需要真正自动化归档,因此我编辑了构建方案的构建后操作以包含运行脚本操作,其中包括以下内容:
cd $BUILT_PRODUCTS_DIR
rm -f Kachunk.zip
zip Kachunk Kachunk.app readme.txt chunk.sh dechunk.sh
现在,这很好用,但有一个致命的缺陷。应用程序本身未正确添加。由于某种原因,当 Xcode 运行脚本时,.app 文件尚未完全构建,因此我最终得到一个没有任何内容的应用程序包。
我做错了什么吗?有解决方法吗?
I am working on a super simple little app that I distribute as a ZIP archive. The archive contains the app itself, a readme, and a few scripts. I wanted to automate this process, so I added the scripts to my project and auto-copied them into the build folder with a copy files build phase.
Now, I needed to actually automate the archiving, so I edited the build scheme's post-build actions to include a Run Script action, which included the following:
cd $BUILT_PRODUCTS_DIR
rm -f Kachunk.zip
zip Kachunk Kachunk.app readme.txt chunk.sh dechunk.sh
Now, this works great, but there's a fatal flaw. The app itself is not added properly. For some reason, when Xcode runs the script, the .app file is not fully built yet, so I end up with an app bundle with no contents whatsoever.
Is there something I'm doing wrong? Is there a workaround to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我明白了。问题是 .app 文件实际上是捆绑包,基本上是目录。因此,它复制的是文件夹,而不是其内容。通过在 zip 命令上添加
-r
选项可以轻松修复此问题:然后就可以了!一般来说,复制/压缩 .app“文件”时这似乎是一个问题。
Nevermind, I got it. The problem was that .app files are really bundles, which are basically directories. So, it was copying the folder, but not its contents. This was easily fixed by adding the
-r
option on the zip command:And then it works! This seems to be a problem when copying/zipping .app "files" in general.