Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning 'myframe-Bridging-Header.h' in Xcode 8.3

Tags:

xcode8

swift3

I updated Xcode to Version 8.3 (8E162) and in my unit test file I have this warning:

Implicit import of bridging header 'myframe-Bridging-Header.h' via module 'myframe' is deprecated and will be removed in a later version of Swift

on this line:

@testable import myframe 

How to fix this warning?

like image 945
Vadim Nikolaev Avatar asked Mar 30 '17 11:03

Vadim Nikolaev


People also ask

How do I import a bridging header in Swift?

Alternatively, you can create a bridging header yourself by choosing File > New > File > [operating system] > Source > Header File. Edit the bridging header to expose your Objective-C code to your Swift code: In your Objective-C bridging header, import every Objective-C header you want to expose to Swift.

How do you use bridging headers in framework?

As the error states, bridging headers are not allowed in Frameworks. The Importing Code from Within the Same Framework Target section of the Mix & Match apple documentation hints at this. As they say, you need to "In your umbrella header file, import every Objective-C header you want to expose to Swift".


2 Answers

That article helped me to fix the warning: https://bugs.swift.org/browse/SR-3801

I selected:

chain the import by adding #import "App-Bridging-Header.h" to any existing unit test bridging header you have

like image 71
Vadim Nikolaev Avatar answered Sep 30 '22 17:09

Vadim Nikolaev


So it has nothing to do with that line per se (which threw me for a loop) and you are not supposed to change it. What is happening is that the @testable import would normally automatically import the module bridging header as well and now it does not anymore.

Like SR-3801 says the solution is to either:

  1. explicitly import the App bridging header into your unit tests (via a build setting) or
  2. chain the import by adding #import "App-Bridging-Header.h" to any existing unit test bridging header you have

I already had a Test-Bridging-Header.h where I added #import "MODULE-Bridging-Header.h" as part of solution 2 which I think is preferable. Now the test bridging header chains in the module bridging header and the warning disappears.

like image 20
Alper Avatar answered Sep 30 '22 18:09

Alper