在 Xcode 中复制捆绑资源时解析符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/540661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:28:53  来源:igfitidea点击:

Resolve symbolic links when copying bundle resources in Xcode

xcodesymlink

提问by zoul

I have a project in Xcode and some resources for the project. The resources contain several symbolic links. When Xcode builds the project, it copies the resources, but does not resolve the symbolic links. Is there a way to tell Xcode to resolve the links? (Ie. have the link targets copied instead of the links themselves.)

我在 Xcode 中有一个项目和该项目的一些资源。资源包含几个符号链接。当 Xcode 构建项目时,它会复制资源,但不会解析符号链接。有没有办法告诉 Xcode 解析链接?(即复制链接目标而不是链接本身。)

Update:Thanks, mouviciel, that was almost it. At first I tried to do it using the Copy Files phase, but the pbxcpprogram called by this phase did not resolve the links either, even though there is some switch called -resolve-src-symlinks. I ended up adding a Run Script phase calling something like this:

更新:谢谢,mouviciel,差不多就是这样。起初我尝试使用 Copy Files 阶段来执行此操作,但是pbxcp此阶段调用的程序也没有解析链接,即使有一些名为-resolve-src-symlinks. 我最终添加了一个运行脚本阶段,调用如下:

rsync -pvtrlL --cvs-exclude \
    $PROJECT_DIR/../Resources* \
    $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH

Fortunate side effect is that I no longer need to keep the Resources group in Xcode updated, whatever changes done in the Resources directory are immediately visible.

幸运的副作用是我不再需要更新 Xcode 中的资源组,资源目录中所做的任何更改都立即可见。

采纳答案by mouviciel

A solution could be to insert a Run Script Build Phase which performs the copy exactly the way you want, i.e., by dereferencing symbolic links (this is the default behaviour of cp).

一个解决方案可能是插入一个运行脚本构建阶段,它完全按照您想要的方式执行复制,即通过取消引用符号链接(这是 cp 的默认行为)。