在 xcode 中创建框架时保留目录结构

发布于 2024-09-24 19:41:13 字数 239 浏览 2 评论 0原文

我正在尝试在 Xcode 中创建一个框架并已成功完成此操作,但事实证明,Xcode 在复制 中的标头时会展平目录结构复制标头构建阶段。我尝试将文件添加为文件夹引用而不是组,但它甚至不会将头文件识别为头文件!

那么,如何告诉 Xcode 在将头文件复制到我的 .framework-bundle 时保留目录结构?

I'm trying to create a framework in Xcode and have successfully done so, but as it turns out, Xcode flattens the directory structure of when copying headers in the Copy Headers build phase. I've tried adding the files as Folder References instead of the groups, but then it won't even recognize the header-files as header files!

So, how can I tell Xcode to keep the directory structure when copying the header files to my .framework-bundle?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

熟人话多 2024-10-01 19:41:13

在构建阶段 UI 中使用复制文件而不是复制标头

为每个所需的输出文件夹创建单独的复制文件(编辑器 -> 添加构建阶段)。

Use Copy Files instead of Copy Headers in the Build Phases UI.

Create a separate Copy Files (Editor -> Add Build Phase) for each output folder needed.

梓梦 2024-10-01 19:41:13

如果您无法使用文件夹引用,因为文件夹也包含您不想复制的非头文件,请改为添加运行脚本构建阶段:

cd "${SRCROOT}/path/from/project/root/to/headers"

echo 'Copying headers into Framework..'
for H in `find . -name "*.h"`;  do
    echo "copying ${H} to ${BUILT_PRODUCTS_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}/${H}"
    ditto "${H}" "${BUILT_PRODUCTS_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}/${H}"
done

这会将所有 .h 文件从您 cd 的路径复制到 YourFramework.framework/Versions/A/Headers 中,就像标记它们一样正如公众所愿。

If you cannot use a folder reference because the folders contain non-header-files, too, which you don't want to copy, add a Run Script build phase instead:

cd "${SRCROOT}/path/from/project/root/to/headers"

echo 'Copying headers into Framework..'
for H in `find . -name "*.h"`;  do
    echo "copying ${H} to ${BUILT_PRODUCTS_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}/${H}"
    ditto "${H}" "${BUILT_PRODUCTS_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}/${H}"
done

That will copy all .h files from the path you cd'd to into YourFramework.framework/Versions/A/Headers just like marking them as public would.

情话已封尘 2024-10-01 19:41:13

看来这目前不是 xcode 的内置功能,因此您必须恢复到脚本以递归方式复制文件(大概只选择头文件): 在 XCode 的复制标头构建阶段将角色更改为公共时,如何保留子组?

以下是有关如何实现这一目标的讨论: http://www.cocoabuilder.com/archive/xcode/259185-copy-headers-that-preserves-subdirectory-struct.html

It seems that this is not currently a built in feature of xcode, so you must revert to scripts to copy files recursively (presumably selecting only header files): How can I preserve subgroups when changing role to public in Copy Headers build phase in XCode?

Here's a discussion about how to accomplish just that: http://www.cocoabuilder.com/archive/xcode/259185-copy-headers-that-preserves-subdirectory-structure.html

人心善变 2024-10-01 19:41:13

添加源文件夹作为对文件夹的引用(“添加文件...”对话框中的单选按钮)。然后将这些文件夹从“导航器”选项卡拖放到“构建阶段->复制文件”。
此后,标头将位于下一个版本的文件夹中。

Add source folder as reference to folder (radio button in the "Add files..." dialog). Then drag'n'drop those folders from Navigator tab to "Build Phases->Copy Files".
After this headers will be located in folders on next build.

魂归处 2024-10-01 19:41:13

来自这个问题接受的答案:

右键单击“资源”,添加现有文件,选择您的目录
并选择“为任何添加的文件夹创建文件夹引用”。

From this question's accepted answer:

Right click on Resources, add existing files, choose your directory
and select "Create Folder References for any added folders".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文