Swift iOS模块未部署到预期的调试目录 [英] Swift iOS module not being deployed to expected debug directory

查看:84
本文介绍了Swift iOS模块未部署到预期的调试目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Swift编写的模块/框架,打算在iOS上使用。当我尝试在我的应用程序中包含框架时,我首先注意到构建阶段中有一些红色的未找到提示:

I have a module/framework written in Swift, intended to be used on iOS. When I try to include the framework in my app, I first notice some red "not found" hints in the build phases:

但是,项目 build 很好 - 找到目标依赖项,因此没有编译问题。它只是由此产生的构建框架 - 当然,在启动时,我有一个链接器错误,它无法找到图像。看看构建日志,它在这里看:

But, the project builds fine - the target dependency is found, so there are no compilation issues. It's just the resulting built framework - and sure enough, upon launching, I have a linker error, it can't find the image. Looking at the build log, it's looking here:

/Users/Craig/Projects/Fluffy/build/Debug-iphoneos/

这是有意义的 - 这就是我的框架的构建设置中定义的内容:

Which makes sense - that's what is defined in the Build Settings for my framework:

但副本失败,因为源框架不存在:

But the copy fails, as the source framework doesn't exist:

PBXCp /Users/Craig/projects/Fluffy/build/Debug-iphoneos/Fluffy_iOS.framework /Users/Craig/Library/Developer/Xcode/DerivedData/MyApp-dcjfhcnyzkwzxiejuuxqlsgajreb/Build/Products/Debug-iphoneos/MyApp/Frameworks/Fluffy_iOS.framework
...
error: /Users/Craig/projects/Fluffy/build/Debug-iphoneos/Fluffy_iOS.framework: No such file or directory

但是,查看我的框架的构建日志,我发现实际上 结束了这里:

However, looking at the build log for my framework, I see that it's actually ending up here:

/Users/Craig/Library/Developer/Xcode/DerivedData/Fluffy-fuuewsvogdkycegheyrsabkiicxc/Build/Products/Debug-iphonesimulator/Fluffy_iOS.framework

我想是的有意义 - DerivedData有一段时间以来一直是任何内置产品的默认位置。

I suppose that makes sense - DerivedData has for a while now been the default location for any built products.

当我看一下预期的构建时文件夹,没有太多,很多都是旧的,并且没有一个与Debug配置有关:

And when I take a look at the expected build folder, there's not much, a lot of it is old, and none of it relates to the Debug configuration:

所以我的问题是:为什么我的框架被放在<$ c $中c> DerivedData 文件夹,当它似乎要求在Build Settings中放置在相对于项目的 build 文件夹中?这些参数(每个配置构建产品路径等)是否都被咨询过?

So my questions are: Why is my framework being placed in the DerivedData folder, when it seems to be asking in the Build Settings to be placed in the build folder relative to the project? Are these parameters (per-configuration build products path, etc.) consulted at all?

而且,我该如何协调这个?我的应用程序如何知道在框架中查找正确的DerivedData文件夹,以可扩展的方式查找正确的配置(调试与发布),并且无需手动指定它的绝对路径即可工作?

And, what should I do to reconcile this? How can my application know to look in the right DerivedData folder for the framework, for the right configuration (debug vs. release) in a way that is extensible and will work without me having to manually specify the absolute path to it?

推荐答案

好的,所以我想出了如何解决这个问题。这假设您有工作区,并且您已将框架作为项目包含在工作空间中,并且您正尝试从包含框架的工作空间中的另一个项目构建产品。

Okay, so I figured out how to work around this. This assumes you have workspace and you have included the framework as a project in the workspace and you are trying to build a product from another project in the workspace which includes the framework.

您需要做的是找出框架的构建位置。它通常是 DeriveData 目录下的一些疯狂目录。转到Finder,找到刚刚尝试构建的配置。

What you need to do is find out where the framework is being built. It's usually some crazy directory under the DeriveData directory. Go to the Finder and find it for the configuration you just tried to build.

在产品目标的常规设置中,在嵌入式二进制文件下,将该文件拖入其中。现在应该将它放在 Project Navigator 中。您还应该在嵌入式二进制文件下面的链接框架和库中看到它。

In the product target's General settings, under Embedded Binaries, drag that file into it. This should now place it in the Project Navigator. You should also see it in the Linked Frameworks and Libraries which was underneath Embedded Binaries.

转到项目导航器并选择文件并在文件检查器下查看。在那里,将位置更改为相对于构建产品

Go to the Project Navigator and select the file and view it under the File Inspector. There, change the Location to Relative to Build Products.

在目标的构建设置中,对于框架搜索路径,添加 $(BUILT_PRODUCTS_DIR) 并使其递归。删除添加框架时自动添加的条目。它将是一个显式路径,其中包含DerivedData路径。

In the target's Build Settings, for Framework Search Paths, add $(BUILT_PRODUCTS_DIR) and make that recursive. Delete the entry that was automatically added when you added the framework. It will be an explicit path which has the DerivedData path in it.

执行深度清理并删除 DerivedData 良好衡量的目录。

Do a deep clean and delete the DerivedData directory for good measure.

构建。

您现在应该看到框架变黑并且应该正常工作。

You should now see the framework turn black and it should work properly.

这篇关于Swift iOS模块未部署到预期的调试目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆