Powered by
Powered by
HuntMyIdeas-Inspire You To Make It Happen
Follow
   Me
  • Blogs
  • About Me
  • Home

How To Add  A SWIFT Bridging Header in iOS?

8/18/2018

0 Comments

 
What is a Swift Bridging Header?

A Swift bridging header is the communication media  with your Objective-C classes from your Swift classes.

Bridging header plays an important role in Swift that allows to run the Swift code along with some codebase written in Objective C. 
Let's explain with an example.

Suppose,you are creating a project in Swift,of course you need to write the whole code in Swift programming language.

​But there are some classes or libraries you may use in your Swift project such as 
SVProgressHUD haven’t been rewritten in Swift and you will need to use a bridging header to use them.
Read:
How do you perform wireless debugging in Xcode 9 and iOS11 ?

Xcode gives option to create Bridging Header for my Project automatically

Whenever you Add a new Swift file to your Xcode project and try to  name it ,Xcode will show  an alert box asking if you would like to create a bridging header.  

Note: 
If you skip the prompt for creating a bridging header, Xcode will decline the option for you.

But it's not a big task ,you can create it manually.

How to create a bridging header manually in xcode?
Step 1:

Create a new file to Xcode
​

-Go to File > New > File, then select “Source” and click “Header File“.


-You can rename the file as “Yourproject-Bridging-Header.h” and It will ask for creating a bridging header.Create and click  finish button.

-Go to project build settings and find the “Swift Compiler – Code Generation” section.  

 You can find it faster to type in “Swift Compiler” into the search box. 

Note: 

If you don’t have a “Swift Compiler – Code Generation” section which means you need to add a Swift file to your project.

You should add a Swift file, then try again.

Next to “Objective-C Bridging Header”, make sure you are adding the name/path of your header file.  

If your file exists in your project’s root folder ,then you can put the name of the header file there.

 Examples:  

“ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.

Open up your newly created bridging header and import your Objective-C classes using #import statements.  

Each classes listed in this file will be accessible from your swift classes.

​Hope it will help.
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Enter your email address:

    Delivered by FeedBurner

    RSS Feed

    Archives

    December 2019
    August 2018
    January 2018
    December 2017
    November 2017
    October 2017
    August 2017
    April 2017
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014


    ​​Categories

    All
    Affiliate Marketing
    Alexa Rank
    Apple's Latest Updates
    Blog Tips
    Cocos2d X
    Cocos2d-x
    Google AdSense Tips
    Grab-some-ultimate-ideas
    How-to-create-a-twinkling-star-background-effect-in-ios
    In-App Purchase Tutorial In Cocos2d-x (C++) Using SDKBOX
    Ios Interview Questions And Answers
    IOS Multiple Choice Questions And Answers
    Objective C
    Online Business
    Python
    Secrets To Effective IPhone App Marketing
    SEO Tips
    Swift Interview Questions
    Swift Tutorials
    Top 10 Articles Objective C
    Top 10 Articles-Objective-C
    Top 10 Popular Movies Ever
    Top 10 Popular Things To Know
    Top 10 Ultimate Issues Xcode
    Top 400 IOS Interview Questions
    Top IOS Sample Projects To Learn From
    Top Secrets To App Marketing
    UICollectionView
    Unity 3D
    Xcode

WELCOME TO HUNTMYIDEAS

Picture
I am Jitendra Gochhayat,an iOS Developer,Designer,blogger,
​from Odisha,India.
I write about ​​​blog tips and,
Make money online Tips,
​Objective C tutorials
SUSCRIBE TO NEWSLETTER

    Subscribe to this blog and receive notifications of new posts by email

Suscribe
Picture
Picture
Picture
Picture
Picture
HuntMyIdeas-2016 Powered By Weebly
Picture
Powered by Create your own unique website with customizable templates.
Powered by
Powered by