Installing the Gracenote SDK (GNSDK) within XCode - ios

I am attempting to get the GNSDK framework working within XCode but I'm having some issues. I dragged the framework file from the example project into my project and adding a bridging header (since the rest of my project is in Swift). The bridging header consists of:
#import <GnSDKObjC/Gn.h>
However, XCode returns that this header file cannot be found. This is what my "frameworks" look like:
Frameworks screenshot
Note that adding or removing the .plist and .pch files does nothing. Any help would be appreciated.

Do you see the framework in the "Link Binary With Libraries" dropdown? Click on your project name (1st item in your Project Navigator). You should be able to see them in the main window. You could try deleting it and adding from here.

Related

xcode 9 I can not use the framework

In the sample program I added my framework to "Link Binary With Libraries".
I added it manually via Add Other because it was not the same workspace
It has been successfully added to the Frameworks category
Added to the Frameworks category, but if enter #import <myFramework/header.h> in ViewController.m, then file not found is printed.
<myFramework... No autocompletion.
What did I do wrong?

Swift bridging header file won't work with use_frameworks

I'm trying to use GoogleidentityToolkit library to handle login an things. I enable use_frameworks! on my pod file, but the module GITkit can't be found. I'm trying to figure out what's going. As far as I know if you use "use_frameworks" you don't need to create any bridging header file, since cocoapods compiles down the library into a single module, so later you can imported as usual on your*.swift files.
What do I need to get using Google Identity Toolkit library in Swift?
This question was asked one week after the release of CocoaPods 1.0.0 (at a time where CocoaPods 0.39.0 was still popular), and available version of Google Identity Toolkit was 1.1.3 from 2015, but got deprecated in favor of Firebase Authentication (pod 'FirebaseUI/Auth') following Google I/O 2016.
A) Create a Bridging Header file named
"ProjectName-Bridging-Header.h" in the root folder of your project.
B) Go to the project build settings and set the following values:
"Install objective-c compatibility header" : YES
"Objective-C Bridging Header" : path of your bridging header (e.g. "ProjectName/ProjectName-Bridging-Header.h"
After that you can use the header file to import all your ObjectiveC files which you want use within swift code.
NOTE: if required set the path as a recursive both in the resource headers and the Swift compiler search section.
None of the answers above worked for me or weren't precise enough.
In Xcode 11.4 (Swift 5.2) this solution worked for me:
1. Create a new header file in your project's root directory. I'm not sure if the name of the file actually matters, but Apple's auto-generated bridging header files are named "ProjectName-Bridging-Header.h".
2. Add all the imports you need to the newly created file.
3. In Project Navigator click on your project's name.
4. In the topmost bar choose "Build settings", and in the one a bit lower choose All and Combined.
5. Search for "Swift Compiler" in the upper right corner
6. Find "Swift Compiler- General" tab, expand it and double-click the right side of "Objective-C Bridging Header".
7. All you need to do now is just drag the bridging header file you've created into the pop-up window and hit enter. You're all set!
*Remember that you'll have to update the path to your Bridging Header every time you project's direct path changes
The easiest way I've found is to create a fake .swift file within XCode. This should bring up the prompt to automatically create a bridging header.
File > New > File...
For the filetype, choose Swift.
Allow Xcode to manually create the Swift Bridging Header.
Delete the .swift file you originally created.
Add a new file to Xcode (File > New > File), then select “Source” and click “Header File“.
Name your file “YourProjectName-Bridging-Header.h”.
Create the file.
Navigate to your project build settings and find the “Swift Compiler – Code Generation” section. You may find it faster to type in “Swift Compiler” into the search box to narrow down the results. Note: If you don’t have a “Swift Compiler – Code Generation” section, this means you probably don’t have any Swift classes added to your project yet. Add a Swift file, then try again.
Next to “Objective-C Bridging Header” you will need to add the name/path of your header file. If your file resides in your project’s root folder simply put the name of the header file there. Examples: “ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.Or, simply drag and drop bridging header file from finder to this empty field. This will automatically add the path of bridging header file.
Open up your newly created bridging header and import your Objective-C classes using #import statements. Any class listed in this file will be able to be accessed from your swift classes.
Swift 4 and Xcode 9.3
Create a Bridging Header file:
Xcode> File/New.../File> Header File
Name the file "ProjectName-bridging-header.h"
Save to root of your project folder
Xcode> Go to Build Settings (In the project explorer pane select the top most item, should be your project name and in the right pane select the "Build Settings" topic)
Just below "Build Setting" make sure "All" and "Combined" is selected
In search box type "swift compiler" and find "Objective-C Bridging Header" item
Collapse it and double click to the right of it to edit
Insert the file name of 1. above -> "ProjectName/ProjectName-bridging-header.h" (note the folder path if bridging file is saved in project folder)
Include the #import 's needed
First create briding header file with named "projectname-bridging-header.h" at your project root level.
Now in build settings set your bridging header file path and its objc compatibility header.
Once done, Clean and build your project its work fine.

FMDB not working in swift?

In my project I added FMDB using cocoapods. I then created a bridging header for FMDB. But when I import FMDB.h using #import "FMDB.h" I receive the error "FMDB.h not found".
When I import "#import " from folder, Xcode again gives me errors for importing inside FMDB framework files: "Include of non-modular header inside framework module (module name)"
What is the problem?
I had the same problem and found that none of the FM...h files were even in the folder being used by the code. Once I put them there, it worked.
If you highlight the FMDB.h file in the project navigator, you will see the path being searched for the files in the upper right corner of the screen under "Identity and Type" called "Full Path". If you check that physical location, you will likely find that the files are not there to be found.
enter image description here
Try going to the Build Settings tab under the "Target" and set Allow Non-modular Includes in Framework Modules to YES.
If that doesn't work, try selecting the FMDB.h file in the project navigator. In the target membership area on the right there is a drop down menu next to the target. Select "Public" there. It may be set to "Project" right now.
Hope that helps!

Importing SDWebImage into Swift project

Trying to install SDWebImage into my Swift project. I am using the following instructions (https://github.com/rs/SDWebImage):
Download and unzip the last version of the framework from the download page
Right-click on the project navigator and select "Add Files to "Your Project":
In the dialog, select SDWebImage.framework:
Check the "Copy items into destination group's folder (if needed)" checkbox
So I git clone --recursive the project from GitHub, I drag the .xcodeproj file into my project (since there is no SDWebImage.framework file as far as I can tell, and this has always worked for other frameworks), I complete the rest of the instructions:
In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block
Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature:
Add Linker Flag
Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag
And then I add #import <SDWebImage/UIImageView+WebCache.h> in my bridging header. I build the project and I get: "SDWebImage/UIImageView+WebCache.h" not found. I've tried some variations on these steps and nothing seems to work. What am I doing wrong?
EDIT
Pretty sure this is happening because I'm not pulling in an SDWebImage.framework file, rather the .xcodeproj file. But I've downloaded from zip and cloned the repo, and there doesn't seem to be a .framework file in there...
UPDATE
So apparently I'm just supposed to download the compiled framework, which I found in another answer: https://stackoverflow.com/a/30545367/918065. Maybe? I have no clue. When I imported the .framework file my bridging header worked and recognized #import <SDWebImage/UIImageView+WebCache.h>, but it didn't recognize imageView.sd_.... So still workin on it.
Last compiled framework is 3.7.0 and you can find it in: https://github.com/rs/SDWebImage/releases
For easier access, the direct link to the framework is below: https://github.com/rs/SDWebImage/releases/download/3.6/SDWebImage-3.6.framework.zip
import "SDWebImage/UIImageView+WebCache.h"
For me it helped when I remove SDWebImage from import. So I have this in my project-Bridging-Header.h:
#import "UIImageView+WebCache.h"
more information about iOS bridging header:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
I recommend using CocoaPods for dealing with dependencies.
CocoaPods is a dependency manager that is designed to solve problems like these.
Follow the installation guide on their website: https://cocoapods.org
So nothing was working for me until I finally realized that you're supposed to use not the main SDWebImage folder, but the SDWebImage folder inside of that into the project. Dragging in the .xcodeproj file, the folder as a whole, or the .framework file didn't work. Importing that sub SDWebImage folder, and then utilizing Libor Zapletal's answer: #import "UIImageView+WebCache.h" is what finally got this thing working for me.
This worked in my case:
Add #import <SDWebImage/UIImageView+WebCache.h> in your bridging header
In project Build Settings, set the path of the bridging header file in Objective-C Bridging Header. Ex. My Project/BridgingHeader.h

Swift Import Obj-C Framework

I am having trouble importing a Obj-C Framework into a Swift Project.
Beginning with an empty swift project here is everything I did:
Drag and drop the Tesseract framework into XCode (copy items if needed was checked)
Drag and drop a random .m file into XCode
XCode generated a Bridging Header File for me
Deleted random .m file, leaving bridging header file
Added import statement to the bridging header file
I dont have enough reputation to add pictures but here are links to various parts of my project:
Project File Structure
Project Build Phases
There is a single line of code in the Bridging Header:
#import <TesseractOCR/TesseractOCR.h>
In Build Settings the Obj-C Bridging Header setting is set to:
Swift OCR Test/Swift OCR Test-Bridging-Header.h
In Build Settings the Framework Search Paths setting is set to:
$(inherited) $(PROJECT_DIR)
I receieve a bunch of Apple Mach-O Linker Errors when I build the project. Could someone offer a suggestion about how to get the project set up properly?
Thanks
You need to add libstdc++.dylib to the Linked Frameworks and Libraries in the General tab for your project.

Resources