Unable to import bridging header - ios

Im trying to link an external Objective-C framework, "frameworkSDK", to my swift project. However I seem to be getting this error :
<unknown>:0: error: failed to import bridging header
I've looked at loads of solutions to my problem but non of them seem to work. Here's what I've done so far :
I've created a "bridingfile.h" at the root of the project and
imported "frameworkSDK.frameworkSDK.h" to the file.
I've made sure Objective-C Bridging Header path was correct under
Swift Compiler - Code Generation.
I've changed my framework search paths to the where the
"frameworkSDK" is located - Code Generation.
Added the path to "bridgingfile.h" to Header Search Paths - Code
Generation.
I've tried to instead create the bridgingfile 1 directory in from
the root folder, and then update accordingly.
Any help would be greatly appreciated! :)

If you are importing an external Objective-C framework, i.e. one stored in, say, frameworkSDK.framework directory structure (bundle), you should not have to worry about a bridging header. Instead do the following:
Under Build Settings set Framework Search Paths to the parent
directory of the frameworkSDK.framework directory.
Also under Build Settings set Runpath Search Paths to
$(FRAMEWORK_SEARCH_PATHS) #executable_path/../Frameworks.
In a Swift file where you want to use the Objective-C framework do
import frameworkSDK.

Related

using module.modulemap to integrate frameworks' objC header in Swift class

I have a framework that contains Objective-C header files. I want to use these header files in the Swift project, in which I am importing this framework.
There are two ways to do it
1) create bridging header file - but, then user will be dependent to create this file, while integrating the framework
2) create module.modulemap file - that I can ship with my framework and user can add it to (which build setting).... <- I need help here
I've tried Import Paths in Swift Compiler - Search Paths and Module Map File in Packaging
In both the cases, I am not able to import the header RandomHeader.
My module.modulemap looks like below
module ToBeShippedFramework
{
header "RandomPublicHeader.h"
export *
}
Is there something different that I need to do?
PS: Please put in comments if you need some more info to understand this question more clearly.

Importing a library in to an Xcode 7 project

So I am trying to add a static library to my project in order to interface with a scanner. I have linked the binary in build phases to the libCaptuvoSDK.a, put the Captuvo.h header file in the project folder, and finally set the project to always search the user paths and added $(BUILT_PRODUCTS_DIR) recursive to the user header search paths. After doing all this I am trying to use #import "Captuvo.h" in my ViewController.swift file and getting the 2 errors Expected identifier in import declaration, and Expected expression. I have tried different combinations of importing and none of them seem to make a difference so I am led to believe the issue is with my process of adding the library.
I am new to Xcode and have never used a third party library in an application before so I feel I may be making a simple mistake or just misinterpreting things. Any help is appreciated!
Okay so I managed to fix my issue! I had imported the static library properly but the real issue was the header file. I fixed my issue by creating a new file in my projects folder named Quick-Scan-Bridging-Header.h. Inside that file is where the #import "Captuvo.h" line belonged. Once that was done I opened the Quick Scan apps build settings and under Objective-C Bridging Header I added the path Quick Scan/Quick-Scan-Bridging-Header. I also added the Header Search Path $(BUILT_PRODUCTS_DIR)
After I did all this I am able to use the Captuvo classes in my ViewController.swift file.

Xcode can't find header file

I am trying to make a framework for my project. Into my framework I added the path of my header files to target>Build Settings>header-search path. After that I added this framework to my project by Build Phases>Link Binary With Libraries.
When I want to import the header file which I included in my framework, I get a .h file not found error. Is what I'm trying to do possible? Or am I missing anything?
I created framework like that;
Opened new project as iOS>Framework&Library>Cocoa Touch Framework
I didn't add any class, i just added header search path and library search path and linker flags. I don't think i did a mistake in this part because we do it in every project but first time i m doing this for framework. Then i pressed run and get my framework from Products.
I opened my project and added framework Build Phases>Link Binary With Libraries. I m able to import header file of framework like #import <myframework/framework.h>
After this i added framework also General>Embedded Binaries. Everything look normal but i cannot add headers to my project which i included to my framework with header search path. I have to use header search path because there is tons of headers, i cannot add all of them to my Xcode.
Make sure you all Public Header appears in Public Section else drag and drop .h file to public
Everything look normal but i cannot add headers to my project which i included to my framework with header search path.
It sounds as though you're expecting all the headers that can be found at the path specified by your header search path will become part of your framework, so that if there's a header named SomeHeader.h in your search path, it will be built into your framework and you'll be able to import it into client projects like:
#import <MyFramework/SomeHeader.h>
But that's not the case at all. If you want your framework to provide SomeHeader.h, you need to add that file to the project and, as Meghs Dhameliya already pointed out, you need to specify SomeHeader.h in the Public Headers portion of the Headers build phase. This will make Xcode copy the header file into the framework so that clients of the framework can import the header file. It's not clear that that's what you really want, though... in comments you wrote:
There is a lot of headers in another path. I have to use header search path unfortunately. Kind of company rule.
So it sounds like all projects in your company specify the same header search path so that they have access to these header files. If that's true, then there's no reason for projects to need to #import them from your framework, but in that case it's not clear what the actual problem is. Or, perhaps you're creating the framework so that client projects can get the headers from your framework instead of having to reference the header search path. In that case, you will need to add those headers to the project and specify them as described above.

Adding sub-project in swift

I have 2 projects in a workspaces, both are built using Swift.
I want to use one of the project as a sub-project of the other one and the classes, which are in the sub-project, in the parent project.
My sub-project is using bridging-header.
I have tried to add one project as a reference to another and imported the class, which is in sub-project, but it didn't work.
Showing me Error: "No such module "
Please help me achieving this?
Fixed the issue, thing i did was:
Removed bridging header file, which was bridging my objective-C and
swift code from my framework and deleted the bridging header file from Build Settings.
Created a file named "Framework-name.h" and copied all the header files, which were there in my bridging header file, into "Framework-name.h" file.
import "Framework-name.h" inside "Framework-name.h" file (this is vey important, it will keep the file at the root level of the framework).
Made "Framework-name.h" and files that were included in Framework-name.h" file public.
Created an aggregate target for my framework. https://medium.com/#syshen/create-an-ios-universal-framework-148eb130a46c
Built the framework.
Drag and drop the created framework into the root level of another sample project.
Test the framework, writing import Framework-name in swift class of the sample project.
Build the project.
Bingo!!!

Swift Compiler Error - failed to import bridging header

I'm trying to integrate Actor App for iOS. On compiling, I get this error :
I checked the path and the ActorClient-Bridging-Header.h is present there.
I have set the proper path to the header file in Build Settings
And this is the folder structure :
What might be the reason for this compilation error?
EDIT
I tried solving the same as mentioned here : Swift Bridging Header import issue and no luck.
Screenshot of the actual path on my disk :
Just go to your project's Framework Search Path,which I assume would be empty and add the path of your SDK folder there.
For adding the path correctly, you can just drag and drop your SDK folder here,the correct path from root will be added automatically.
Hope this will help!!
Bridging header file should be placed at root folder.

Resources