xcode 9 I can not use the framework - ios

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?

Related

No Such Module 'Ensembles' Error - importing objective-c framework to use in swift project

I am add Ensembles to my Swift project - found here https://github.com/drewmccormack/ensembles. I have had no luck adding iCloud support to my app and syncing data across devices so hoping this will work.
I have followed the following instructions for adding the framework to my app,
In Finder, drag the Ensembles iOS.xcodeproj project from the
Framework directory into your Xcode project.
Select your App's project root in the source list on the left, and then select the App's target.
In the General tab, click the + button in the Linked
Frameworks and Libraries section.
Choose the libensembles.a library and add it.
Select the Build Settings tab. Locate the Other Linker
Flags setting, and add the flag -ObjC.
This is how it looks in my project, I am unsure if i have done this step right.
Select the Build Phases tab.
Open Target Dependencies, and click the + button.
Locate the
Ensembles Resources iOS product, and add that as a dependency.
Open the Ensembles iOS.xcodeproj project in the source list, and open the Products group.
Drag the Ensembles.bundle product into the Copy
Bundle Resources build phase of your app.
Add the following import in your precompiled header file, or in any files using Ensembles.
It is step 10 that I am having problems with. Do I have to create a bridging header or just import the framework into my swift files ?
This is how I am importing within my CoreDataStack.swift file
import UIKit
import CoreData
import Ensembles
class CoreDataStack: NSObject, CDEPersistentStoreEnsembleDelegate {
}
This gives me the error;
No such module 'Ensembles'
I tried creating a bridging header by doing the following;
Add new header file
Import Ensembles
This is how that looks;
#ifndef Header_h
#define Header_h
#import <Ensembles/Ensembles.h>
#endif /* Header_h */
But still no luck, does anybody know where I am going wrong when trying to import the framework to use with my swift project ?
When creating a bridging header you do not need to use import.
However I don't think you may be adding a bridging header correctly, go to, file, new, file, add a objective-C file and a dialog should pop up asking if you want to create a bridging header. Add both files but delete the objective-C file and keep the bridging header.
Then import the ensembles framework to the bridging header like so.
#import <Ensembles/Ensembles.h>
When creating a bridging file successfully you should not need to import the framework in your swift files and it should be available throughout your project. See this post for more information - Connect Objective C framework to Swift iOS 8 app (Parse framework)

Installing the Gracenote SDK (GNSDK) within XCode

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.

iOS - "'Foundation/Foundation.h' file not found" Error Inside Custom Framework Inside Swift Project

I have compiled a custom Objective-C Framework which I will be referring to as Custom.framework. I'm having an issue with the files inside the framework when I try to build the project the framework is linked in.
Inside Custom.framework I have my main Header file called Custom.h and the following code is where the problem arises:
#import <Foundation/Foundation.h> // 'Foundation/Foundation.h' file not found
I have a recursive framework and library path set up to where my .framework file is located: /Users/macbook/Library/Developer/Xcode/**
My project and framework files are in /Users/macbook/Sites/
Also my framework appears in red text, but is recognized when I import it if that helps.
As Glenn Howes states in a comment under the question, I needed to change the import to #import Foundation instead of using #import and turn on Enable Modules (C and Objective-C) in my build properties (which I already had).
Have you added Foundation.framework in Scheme --> Build Phases --> Link Binary With Libraries?

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