简体   繁体   中英

'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.
  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
  2. Add libAsyncDisplayKit.a, AssetsLibrary and Photos to "Link Binary With Libraries" build phase.
  3. Add "-lc++ -ObjC" to project linker flags.
  4. Add #import <AsyncDisplayKit/AsyncDisplayKit.h> to the bridging header.

These are the instructions found here .

I archive again, and it fails, with two errors:

'AsyncDisplayKit/AsyncDisplayKit.h' file not found

Failed to import bridging header '/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. The problem is that I'm specifically using Submodules, and not CocoaPods, for my project. 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

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

您是否在 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). The reason was that the file '+CoreDataModel.h' was not found and the 'Failed to import brigding header' error message was based on it. 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. The crucial difference was that the release build was built in compilation mode 'Whole Module' without generating the CoreData classes. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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