使用 Xcode 4 子项目中的静态库和捆绑产品

发布于 2024-12-19 23:09:25 字数 1017 浏览 1 评论 0原文

我有一个包含 2 个项目的工作区:

  1. 一个包含 2 个产品的项目:一个静态库和一个资源包
  2. 一个构建 iOS 应用程序的项目。

第一个项目已添加为第二个项目下的子项目引用。我的静态库构建得很好,它链接到应用程序,一切都很好。但是,我似乎无法将资源包包含在应用程序中。

该捆绑包已添加到应用程序的“构建”方案中。

我尝试将 Resources.bundle 拖到应用程序的“复制构建资源”阶段,但这会在构建时导致此错误:

.../DerivedData/MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator/Resources.bundle: No such file or directory

所以我查看了派生数据目录,我看到 Resources.bundle

MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug 

不是

MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator.  

我认为这是因为该捆绑包不是特定于平台的。因此,我尝试添加一个构建阶段来将捆绑包复制到产品目录。导致此构建错误:

.../DerivedData/MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator/Resources.bundle depends on itself.  This target might include its own product.

但没有 Debug-iphonesimulator/Resources.bundle 文件,因此我看不到此依赖项来自何处。任何建议将不胜感激。

I have a workspace containing 2 projects:

  1. A project that has 2 products: a static library and a resource bundle
  2. A project that builds an iOS app.

The first project has been added as a subproject reference under the second project. I have the static library building fine, it links into the app, all is well. However, I cannot seem to include the resource bundle in the app.

The bundle has been added to the app's 'Build' scheme.

I've tried dragging the Resources.bundle into the app's 'Copy Build Resources' phase, but that results in this error at build time:

.../DerivedData/MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator/Resources.bundle: No such file or directory

So I looked at the derived data directory and I see Resources.bundle in

MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug 

not

MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator.  

I assume this is because the bundle isn't platform specific. So I tried added a build phase to copy the bundle to the Products Directory. Resulting in this build error:

.../DerivedData/MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator/Resources.bundle depends on itself.  This target might include its own product.

But there is no Debug-iphonesimulator/Resources.bundle file, so I don't see where this dependency is coming from. Any advice would be greatly appreciated.

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

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

发布评论

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

评论(1

泡沫很甜 2024-12-26 23:09:25

我想通了。问题是(如上所述)该包不是特定于平台的,因此它输出到 Products/Debug 目录,而应用程序输出到 Products/Debug-iphonesimulator 目录。我必须添加一个运行脚本阶段才能将资源复制到应用程序包中:

SRC="$BUILD_DIR/$CONFIGURATION/Resources.bundle"
DEST="$BUILD_DIR/$CONFIGURATION$EFFECTIVE_PLATFORM_NAME/$FULL_PRODUCT_NAME"
cp -R "$SRC" "$DEST"

I figured it out. The problem is (as mentioned above) that the bundle isn't platform specific so it outputs to to the Products/Debug directory while the app outputs to the Products/Debug-iphonesimulator directory. I had to add a Run Script phase to copy the resource into the app bundle:

SRC="$BUILD_DIR/$CONFIGURATION/Resources.bundle"
DEST="$BUILD_DIR/$CONFIGURATION$EFFECTIVE_PLATFORM_NAME/$FULL_PRODUCT_NAME"
cp -R "$SRC" "$DEST"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文