i can find its old implementation that is
#import <BugSense-iOS/BugSenseController.h>
and
[BugSenseController sharedControllerWithBugSenseAPIKey:#"123456" userDictionary:nil sendImmediately:YES]
and i am working in the Swfit Language
Import doesn't support dash (-)
can anyone update me how to import it in Swift, i also checked it on their bugsense documentation but couldn't find any updates
Create an ObjC bridging header help you to import it. First add the framework to your app directory and Xcode will ask you to create the bridging header.
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
Related
I'm trying to integrate Microsoft Bing Speech API with SpeechRecognitionService into my Swift application. Unfortunately, the Microsoft SDK only supports Objective-C atm, so I get around by adding #import "SpeechRecognitionService.h" to the Bridging Header after importing the SpeechSDK.framework, but I got the file not found error.
What am I doing wrong?
EDIT:
I did try import SpeechSDK framework directly into the needed class before but it was not working.
In my case, I'm still using the Bridging Header in order to import the framework. #import "SpeechRecognitionService.h" didn't work but a slight change as below works for me.
#import "SpeechSDK/SpeechRecognitionService.h"
There is no need to add header to bridging header, you can simply import the framework. From apple docs:
Importing External Frameworks
You can import external frameworks that have a pure Objective-C
codebase, a pure Swift codebase, or a mixed-language codebase. The
process for importing an external framework is the same whether the
framework is written in a single language or contains files from both
languages. When you import an external framework, make sure the
Defines Module build setting for the framework you’re importing is set
to “Yes”.
You can import a framework into any Swift file within a different
target using the following syntax:
import FrameworkName
See also “file not found” in Bridging Header when importing Objective-C frameworks into Swift project by CocoaPod
In my case, I'm still using the Bridging Header in order to import the framework. #import "SpeechRecognitionService.h" didn't work but a slight change as below works for me.
#import "SpeechSDK/SpeechRecognitionService.h"
I have a Swift / Parse iPhone project in Xcode. I have added Parse frameworks and as long as I import Bolts and import Parse in my swift file I am able to use all parse functions. I am now wondering, why do I need the Obj C bridging header at all? Currently there is nothing in it, yet everywhere it says that you need to properly setup your bridging header for Parse to work in Swift projects?
The difference is in your deployment target. For iOS8, you can use embedded frameworks, so you can import frameworks just with a simple
import FrameworkName. If you use CocoaPods, you can add use_frameworks! directive to your podfile and you can then use all pods as Frameworks without a bridging header.
If you want to provide a support for iOS7, you have to still use a bridging header, because embedded frameworks are not supported with this version of iOS.
I am totally new to swift and developing my first application for iOS. I need to use DDMathParser with it. I followed guide at their site but i am getting errors at import statement
Expected identifier in import declaration
Expected expression
Import statement syntax:
#import "DDMathParser.h"
I followed This guide.
Bridging header files solved my problem. Thanks
I've made a framework that requires the sqlite3 framework. How do I add a Objective-C Bridging Header for my framework that imports sqlite3 into my Swift file?
I already have a bridging header file for my project, but not for my framework.
I found a Objective-C Bridging Header setting in the target Build Settings. It was hidden by default. Check All instead of Basic.
In recent Xcode versions this solution would give the error Using bridging headers with framework targets is unsupported.
The workaround I've been using is to make the C-header public in the file inspector and import it in MyFramework.h like this example:
#import <MyFramework/MyObjectiveC.h>
How to change the C-header to public
Open your C-header and view the inspector by clicking in the upper right corner. To view the file inspector, click the file icon in the upper right corner.
just import your sqlite3 framework in your objective-c bridging file. You then automatically can use it in Swift.
Apple Docs:
Interoperability is the ability to interface between Swift and Objective-C in either direction, letting you access and use pieces of code written in one language in a file of the other language. As you begin to integrate Swift into your app development workflow, it’s a good idea to understand how you can leverage interoperability to redefine, improve, and enhance the way you write Cocoa apps.
One important aspect of interoperability is that it lets you work with Objective-C APIs when writing Swift code. After you import an Objective-C framework, you can instantiate classes from it and interact with them using native Swift syntax.
EDIT: You even can import an Objective-C framework or Swift framework or a mixed-language framework just into your swift file with import yourFramework
Apple Docs:
Importing External Frameworks
You can import external frameworks that have a pure Objective-C
codebase, a pure Swift codebase, or a mixed-language codebase. The
process for importing an external framework is the same whether the
framework is written in a single language or contains files from both
languages. When you import an external framework, make sure the
Defines Module build setting for the framework you’re importing is set
to Yes.
You can import a framework into any Swift file within a different
target using the following syntax:
SWIFT
import FrameworkName
You can import a framework into any Objective-C .m file within a
different target using the following syntax:
#import FrameworkName;
If I want to use Quartz and I type
import QuartzCore
for some reason, it works. If I type anything else, it doesn't work. When I check the documentation (Command click), it is a blank header file. How do I import headers?
As per the docs, import works for any Objective-C framework (or C library) that is accessible as a module.Objective-C frameworks vend APIs in header files. In Swift, those header files are compiled down to Objective-C modules, which are then imported into Swift as Swift APIs.