简体   繁体   English

存档我的项目时出现“无法导入桥接头”、“找不到文件”

[英]'Failed to import bridging header', 'file not found', when archiving my project

I was having some trouble when archiving a project with a swift bridging header, and a framework.在使用快速桥接头和框架归档项目时,我遇到了一些麻烦。 It was giving me errors, but only when I Archive.它给了我错误,但仅限于我存档时。 So I made a new project to test this further.所以我做了一个新项目来进一步测试。

Here are my steps:这是我的步骤:

  1. New swift project.新的快速项目。
  2. Add an objective-c file.添加一个objective-c 文件。
  3. When it prompts me to ask about making a bridging header, press yes.当它提示我询问制作桥接头时,请按是。

At this point, I archive.在这一点上,我存档。 It succeeds.它成功了。

  1. Add ASyncDisplayKit.xcodeproj添加 ASyncDisplayKit.xcodeproj
  2. Add libAsyncDisplayKit.a, AssetsLibrary and Photos to "Link Binary With Libraries" build phase.将 libAsyncDisplayKit.a、AssetsLibrary 和 Photos 添加到“Link Binary With Libraries”构建阶段。
  3. Add "-lc++ -ObjC" to project linker flags.将“-lc++ -ObjC”添加到项目链接器标志。
  4. Add #import <AsyncDisplayKit/AsyncDisplayKit.h> to the bridging header.#import <AsyncDisplayKit/AsyncDisplayKit.h>添加到桥接头。

These are the instructions found here .这些是在此处找到的说明。

I archive again, and it fails, with two errors:我再次存档,它失败了,有两个错误:

'AsyncDisplayKit/AsyncDisplayKit.h' file not found找不到“AsyncDisplayKit/AsyncDisplayKit.h”文件

Failed to import bridging header '/Users/Andrew/Desktop/testProject/testProject/testProject-Bridging-Header.h'无法导入桥接头 '/Users/Andrew/Desktop/testProject/testProject/testProject-Bridging-Header.h'

This is replicable.这是可复制的。 I seem to have followed their instructions perfectly well, and I haven't touched the project other than this.我似乎很好地遵循了他们的指示,除此之外我没有接触过该项目。

Interestingly, it builds fine, and runs fine.有趣的是,它构建良好,运行良好。 But archiving, it gives these errors.但是归档时,它会出现这些错误。

Any help is appreciated.任何帮助表示赞赏。

EDIT: If I import it using CocoaPods, it works just fine.编辑:如果我使用 CocoaPods 导入它,它工作得很好。 The problem is that I'm specifically using Submodules, and not CocoaPods, for my project.问题是我专门为我的项目使用子模块,而不是 CocoaPods。 It'd be pandemonium to switch to using both as a solution to this problem.切换到使用两者作为解决此问题的方法将是一片混乱。

This guy has done work to resolve the issue here: https://github.com/nrcmedia/AsyncDisplayKit这家伙已经完成了在这里解决问题的工作: https : //github.com/nrcmedia/AsyncDisplayKit

For the time being switching to this branch will get you past the issue.暂时切换到这个分支会让你解决这个问题。

It is currently under review to be pulled into Facebook here: https://github.com/facebook/AsyncDisplayKit/pull/449目前正在审查将其拉入 Facebook: https : //github.com/facebook/AsyncDisplayKit/pull/449

您是否在 Project Build settings -> swift compiler code generation ->objective-c 桥接标头设置为 testProject-Bridging-Header.h 下检查?

I had the problem with a project where I wanted to share a CoreData database between App and Today App Extension and prepare the App for the AppStore (Archive Build).我在一个项目中遇到了问题,我想在 App 和 Today App Extension 之间共享 CoreData 数据库,并为 AppStore(Archive Build)准备 App。 The reason was that the file '+CoreDataModel.h' was not found and the 'Failed to import brigding header' error message was based on it.原因是找不到文件“+CoreDataModel.h”,“无法导入桥接头”错误消息是基于它的。 It turned out that the corresponding CoreData classes, which were supposed to be generated by XCode, were built in debug mode, but not in release mode, which is finally used in the archive build.原来应该由XCode生成的相应CoreData类是在调试模式下构建的,而不是在发布模式下构建的,最终在归档构建中使用。 The crucial difference was that the release build was built in compilation mode 'Whole Module' without generating the CoreData classes.关键的区别在于发布版本是在编译模式“整个模块”中构建的,而没有生成 CoreData 类。 If you switch to Incremental in XCode under Build Settings > Swift Compiler - Code Generation > Release you could build the app as an archive and upload it to ITunes Connect.如果您在 XCode 中的 Build Settings > Swift Compiler - Code Generation > Release 下切换到 Incremental,您可以将应用程序构建为存档并将其上传到 iTunes Connect。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM