When writing Swift you will eventually run into the situation where you need to include Obj-C based code libraries, lucky for us, Apple has made it super easy by using what is called a “Bridging Header” file.
Here is how you create it,
- Create a new “Header File” file. In XCode this is done by going to “File > New > New File > iOS > Header File”
- Add the module you need to import, for example to import CommonCrypto library you would add “#import <CommonCrypto/CommonDigest.h>”
- Add the file to your Build Settings under the “Swift Compiler – Code Generation” section using the name “Objective-C Bridging Header” and point it to the file created in step 1.
Your file should look something like this.
//
// BurningMan-Bridging-Header.h
// BurningMan
//
// Created by Nickolas Whiting on 11/9/15.
// Copyright © 2015 Applied Informatics. All rights reserved.
//
#import <CommonCrypto/CommonDigest.h>
#import <Google/Analytics.h>
And your build settings should include something like this,
Thats it, you are done!
This is part of our iOS 10 Minute Quick Hack series. Stay tuned for more!
Very interested in America Walks. I am the National Race Walk Development Coordinator as well as one of the 11 members of the IAAF ( International Association of Athletics Federations) That will be having a meeting on May 9 to discuss how we can both generate more interest in the Olympic Track and Field event of Race Walking and be socially responsible and get average citizens to walk more for their health. Wondering if any collaboration may be of benefit?