Importing SDWebImage into Swift project - ios

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

Related

Unable to import and use SSZipArchive in Xcode 10.2 Swift 4 by manually drag and drop. Lot's of semantic issue errors

I created Fresh new Xcode iOS project and followed below steps.
Drag & Drop SSZipArchive folder in Xcode project.
Created Briging Header and imported Header file I.e. #Import "SSZipArchive.h"
Added libz.tbd and security framework to a target
Then after it gave lot's of semantic issues. Can somebody please help me on this. It Would be really helpful if there is a video of importing this files in XCode iOS project. Please help me.
For reference please see screenshot below
enter image description here
Can somebody please help me on importing manually.
https://github.com/ZipArchive/ZipArchive from this
Add the SSZipArchive folder that contain minizip folder to your project.
Add the libz and libiconv libraries to your target.
Add the Security framework to your target.
Add the following GCC_PREPROCESSOR_DEFINITIONS: HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB MZ_ZIP_NO_SIGNING $(inherited).
Remove info.plist under target-> build phase-> copy bundle resources.

objective-C #import with route

When I used a third-party SDK, I followed the guide to import the SDK package into my project by drawing the floder into the project navigator.
The guide show I can use it by adding:
#import "package.h"
but I got an error 'package.h' file not found.
Then I found using  #import "SDK/a/package.h" is OK.
The sample project given with the SDK also just use the name without path.
Am I use the wrong way to import the Code? or did I miss some steps before using them?
You need to enable "Target membership" option in project navigator for header file, under "Utility view".
If that does not work, make sure your ".h" file it's added on Build phases -> Headers -> Public.

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.

opencv2/opencv.hpp file not found in Xcode

I have built openCV to get opencv2.framework. I added this to my xcode iOS project by going to "build phases->Link Binary With Libraries", then tried to include "opencv2/opencv.hpp" in my project.
I get the error "opencv2/opencv.hpp" not found. But the file exists in the framework. I have tried to find a solution online but nothing has worked for me.
The file I'm trying to include it in is a .mm file. I have made "compile sources as" objective-c++. Any help would be great.
What worked for me was very simple:
*NOTE THE DIFFERENCE FOR IOS vs. OS X PROJECTS
FOR IOS:
Put the opencv download (for 3.0.0 it is just a drag and drop kind of thing) into the project specific Xcode folder. Then set the Frame Search Paths to $(PROJECT_DIR). The Frame Search Path is located under the Build Settings. No other paths need to be set.
Lastly, right click in the navigator pane and click "Add Files to..." in order to add in the opencv library from the project folder.
FOR OSX:
check out Tim's tutorial: https://www.youtube.com/watch?v=OVSPfUmNyOw
I solve the problem by adding to the FRAMEWORK_SEARCH_PATHS the absolute path were I had the framework I needed to use:
You should use your own path obviously. ;-)
Took me 4 hours to figure this out. This is how I got this to work :
Along with the opencv framework add the following frameworks in the build phases:
Accelerate, AssetsLibrary, AVFoundation
, CoreGraphics
, CoreImage
, CoreMedia
, CoreVideo
, QuartzCore
, UIKit
, Foundation.
Then, in the .pch file add these lines before UIKit and Foundation imports :
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
In my case the symbolic links to the header files were broken. This was caused by cloning the following great example project:
https://github.com/BloodAxe/OpenCV-Tutorial
In the cloned project, the header files were not reachable anymore. After reimporting the opencv2.framework from the official opencv ios download site (OpenCV for iOS), the headers were available again. XCode should look as follows:
The following is a screenshot of a Xcode project with broken headers.
With broken header files, the xcode project looks as follows:
Make sure in Build Settings for the Target, you have the Framework Search Path in the Search Paths section set to the correct path to where your framework is located in your directory. You can do this by clicking to the right of Framework Search Path in the white space, click the + sign and add $(PROJECT_DIR) then click + again and add $(inherited). Make sure the framework is located in your main directory for your project at hand. This worked for me, as I encountered the same problem.
Hope this helps!
I used openCV in my project and implementing it with cocoapods was impossible because version of library was too old, so i decided to implement it as static library. create folder in your project and add library there, in build settings find library and framework search path and add link to your openCV folder. It will work without any error. Also you should add openCV header file in prefixPatch.
More Detail Instruction 100% Works:
1) Download framework from official website: OpenCV
2) In Project Directory create folder named: External_SDK
3) Put Opencv framework inside this folder and drag&drop it in Xcode Project (Folder) with Target Membership of your App (Not App_test).
4) In Xcode Project search for yourPrefixHeaderFileName.pch and in the top of the file add this lines:
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
5) after that you should import or include it in .h file, why include? because it's CPP library. If you want to access library with import keywoard than you should do like this: #import <EXAMPLE>
6) In build settings search for library and framework search path and add link to your EXTERNAL_SDK folder. To read framework directly from your folder. Find and change ALWAYS_SEARCH_USER_PATHS = YES
and in HEADER_SEARCH_PATHS add $(inherited) and /usr/include/FRAMEWORK_PATH
Hope this answer will help someone.
And the best practice is to call
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
Only header files.
From my experience, it is not necessary to add so many other frameworks. Instead, only need opencv2 and add "#import " in prefixheader.pch
The thing is that MUST set correct Framework Search Paths as mentioned above unless opencv2 framework folder is in your project directory.
Notice: don't set wrong location in Framework Search Paths as there are two "YourProjectName". Set the 1st one (belongs to TARGETS), not the 2nd one(belongs to PROJECT). I made the mistake.
Here is my answer for this.
Environment: XCode 8.1
Download page: http://opencv.org/downloads.html. Choose any link for iOS.
Important step: while downloading opencv2.framework, you must use ".zip" format, not ".framework" format, afterwards, unzip it to opencv2.framework. It is weird, but it should work. Meanwhile, you have to rename it to opencv2.framework if the unzipped one is not.
just drag and drop the framework to your iOS project. No any settings are required. You could refer to this for testing : www.youtube.com/watch?v=ywUBHqxwM5Q.
I ran into some issues when I went to Target-->Build Phases-->Link Binary With Libraries. When I added opencv2.framework from there, my app would not launch.
Instead, I just dragged and dropped the framework under the directory "Frameworks" in XCode and that worked. I didn't change anything else.

Integrating UrbanAirShip - Header search paths with relative path

I'm trying to integrate UrbanAirShip in my application following these steps .
This is what i've done:
1) I've Unziped the framework in the Project folder so that I have the Airship folder at the same level of other file of my project.
2) I've added the path ./Airship/** to my Header search Paths.
I've also tried with ../Airship/** but it doesn't work.
3) I try to include the right headers
#import "UAirship.h"
#import "UAConfig.h"
#import "UAPush.h"
But xcode complains... saying 'UAirship.h' file not found.
What I'm doing wrong? Have I to include the files into the project?
Neither ./ or ../ worked for me in the Header Search Paths. I ended up using this:
$(PROJECT_DIR)/Airship
Airship folder is in same level as the project.
You mistyped the path to add in the Header Search Paths (forgot one ".") :
./Airship/**
Should be :
../Airship/**
Did you do the following step:
Link against the static library.
Add the libUAirship.a file to the “Link Binary With Libraries” section in the Build Phases tab for your target.
May not be applicable all of two years later, but I encountered a very similar problem today and solved it by using the CocoaPods version of the framework found here:
https://cocoapods.org/pods/UrbanAirship-iOS-SDK
After running pod install, I added the following paths to my Header Search Paths under target project > build settings:
It seemed redundant to me to add both paths, but without the subfolders at /** the AirshipLib.h file wasn't able to locate its dependancies, and without the main folder my Bridging-Header.h file wasn't able to locate AirshipLib.h
Luckily enough I'm using some old Objective-C files from our codebase and incorporating them into a new Swift app, so I already had a Bridging-Header.h file, but if you needed to create one you can find instructions here:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
Finally, I added the following to my Bridging-Header.h file:
#import "AirshipLib.h"
No issues on build and everything from the framework can be easily referenced directly in my files.

Resources