Bridging header not found in header file - ios

I have this annoying error that stops me from developing some features in my app.
Here is the thing:
I developed a swift/objc project
The bridging header works every where in my project
I import it in .m files and this works !
Now I have this file EventCell.h:
I import the bridging header in it : no problem
From another file CalendarView.h:
I import EventCell.h in it
And boom
I can't get this issue ! Please help me :)

You cannot import the bridging header into a .h file. You should use forward declarations if you need access to a Swift class.
Use #class MyClassName, or #protocol MyProtocolName

Related

Can't reference framework .h header files from my Swift controller

I'm trying to import a framework made up of Objective-C header files.
I've created a bridging file but when I try to import a header the compiler doesn't recognise it.
This is error Xcode is showing:
Also if I try to reference the Framework in my Swift file as import ArcGIS it doesn't recognise that either.
What am I doing wrong?
You dont have to import ArcGIS header file. Guess you have used Carthage or CocoaPods. The only thing you need is to import ArcGIS
Check the documentation here
https://developers.arcgis.com/ios/swift/guide/install.htm

Where can I get CommonCrypto / CommonCrypto file from?

I have a problem with importing CommonCrypto/CommonCrypto or CommonCrypto/CommonDigest. I need a SHA256 for my Swift code.
I found CommonCrypto github site in Cocoapods.
https://github.com/AlanQuatermain/aqtoolkit
So I have downloaded the file from above.
But I'm getting errors about ARC (I have added Bridging-Header like other tutorials do.)
The header file's name is NSData+CommonCrypto.h and NSData+CommonCrypto.m.
It's not a CommonCrypto/CommonCrypto or CommonCrypto/CommonDigest
Where can I download and get the exact file CommonCrypto for SHA256?
No additional files are required. You need a bridging header first of all, which you already have but for those who don't the easiest way to achieve this is to add an Objective-C file to your project and to accept when it offers to create a bridging header. You can then either import the whole of CommonCrypto (thanks #zaph - see comments) to the bridging header:
#import <CommonCrypto/CommonCrypto.h>
Or the constituent parts:
#import <CommonCrypto/CommonCryptor.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonKeyDerivation.h>
#import <CommonCrypto/CommonSymmetricKeywrap.h>
You can now use CommonCrypto in Swift. For example code see here.
Edit
In Xcode 10 a bridging header is no longer required to import CommonCrypto in Swift. You can simply use:
import CommonCrypto
In fact, you don't need to compile any file to using CommonCrypto, just import it in your project.
or using some wrapper in Swift, just like https://github.com/soffes/Crypto
Let's back to CommonCrypto file,Apple have released it's source code in https://opensource.apple.com/source/

Import vs Bridging Header

Is there a compile time performance improvement when import Foo is used on top of a swift file instead of adding the library to the project through the bridging header using #import <Foo/Foo.h>?

Import RNCryptor to project

I try to import RNCryptor to my project to encrypt some string. But I have trouble to understand how to import that to my objective-c project. I copied the RNCryptor/RNCryptor.swift and RNCryptor.h by drag and drop in to my project. Then it "created a bridging header". After that I tried to debug but I have 38 error messages like: Use of unresolved identifier 'kCCKeySizeAES256' or Use of unresolved identifier 'CCPBKDFAlgorithm'. How can I fix that and how would I use it in a viewController.h file? Normally with #import "RNCryptor.h"
https://github.com/RNCryptor/RNCryptor#obj-c
I think you need to add #import "RNCryptor/RNCryptor.h" to the bridging header file, did you do that?
See the RNCryptor Swift branch
The Bridging Header
CommonCrypto is not a modular header in Xcode 7. This makes it very challenging to import into Swift. To work around this, the necessary header files have been copied into RNCryptor.h, which needs to be bridged into Swift. You can do this either by using RNCryptor as a framework, adding #import "RNCryptor/RNCryptor.h" to your existing bridging header, or making RNCryptor/RNCryptor.h your bridging header in Build Settings, "Objective-C Bridging Header."

ModuleName-Swift.h file not found inside of CocoaPod Project

Issue
I have a CocoaPod project created using pod lib create. There are some Objective-C classes that can be used inside the example project — I am now trying to add a NSObject subclass written in Swift.
The Swift class was created and the bridging header was added to the classes directory.
I try to import the Swift bridging header into the .m file of another class inside the pod project:
#import "PROFlyoutViewController-Swift.h"
When I compile I get 'ModuleName-Swift.h' file not found
When the import statement is:
#import <ModuleName/ModuleName-Swift.h>
or
#import "ModuleName/ModuleName-Swift.h"
it compiles and is usable!
But...
I return to the file, indexing runs (I assume) and all of a sudden I get:
ModuleName/ModuleName-Swift.h file not found.
Autocomplete is broken on that file and any use of that class shows a warning.
Question
When using trying to use a Swift Bridging header within the files of a pod project, how should it be imported? What do I need to do in order to get autocomplete working and compilable?
Try using #import PROFlyoutViewController; instead as it is an external module.
See the below Example of my TableDemo project
To import Swift code into Objective-C from the same target
Import the Swift code from that target into any Objective-C .m file within that target using this syntax and substituting the appropriate name:
#import "TableDemo-Swift.h"
The Swift files in your target will be visible in Objective-C .m files containing this import statement. For information on using Swift from Objective-C code, see Using Swift from Objective-C.

Resources