Integrating UrbanAirShip - Header search paths with relative path - ios

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.

Related

iOS Framework headers not found in some files of the framework

I am developing a framework for my obj-c iOS app.
I followed this tutorial: https://www.raywenderlich.com/65964/create-a-framework-for-ios
My framework files builds correctly and I can import it into my sample project and it builds correctly. But my project doesn't perform as expected.
When I did deeper into my framework headers, I find my problem.
Certain header files allow me to CMD-Click on the imports to view the corresponding header files in my project.
So for example:
In TestFile.h, I have: #import <Framework/SomeFile.h>, I can CMD-Click on this grand and I get linked to SomeFile.h
In TestFile2.h, I also have: #import <Framework/SomeFile.h>. When I CMD-Click on this, I get the Question Mark symbol indicating that the file isn't found.
In my Framework Project, I have a directory structure like so:
FrameworkProj.xcodeproj
->FrameworkProj
->FrameworkHeaders.h
->Folder
->some files
->some folders
->Folder
I'm wondering if I haven't set a flag in my Build Settings that doesn't recursively link the files to my compiled framework, but I'm wondering why can I see the files in my headers files if this is the case.
Thanks very much!
May seem stupid but I solved this problem with a single line.
I needed to include -all_load in Target > Build Settings > Other Linker Flags

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.

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

Can't include Objective C Files into Project?

I want to include an Objective-C project (https://github.com/soffes/ssziparchive) into my Swift Project so that I can include the SSZipArchive into my project. I need this so I can unzip a file. As included in the instructions on the Github, I included the folder minizip, SSZipArchive.h, and SSZipArchive.m into my project. I have also created a bridging header where I included the following import into my project #import "SSZipArchive.h". However, when I try to type SSZipArchive on Xcode, the autocomplete doesn't occur, leading me to believe that SSZipArchive isn't included properly in my project. Any ideas on how to do so? I have already looked at numerous links on how to include Objective-C projects into Swift and I have found that I simply need to include the corresponding header files for my project to work.
I guess that you haven't set bridging header path properly. It's a very common problem, but easy one to fix.
Go to the Project Settings -> Build Settings -> Search, and search for bridg, and under Objective-C Bridging Header set the path of your bridging header file (carefully inspect it's path in Finder first, since it may be in some sub-directory of your project).
Also make sure that all your included header files have target of your application. To check if they have, click on the header file, open up Utilities from the right side and under Target Membership, make sure the first target is checked.

Unable to find headers in static library

I'd like to add DTCoreText to my project. I followed the instructions (starting at the DTCoreTExt GitHub page) to setup the project using CocoaPods. Finally I've created a "libPod.a" library file.
I've added the library file to my project (by copying the file in to a project sub-folder and added the file to the "Linked Frameworks and Libraries".
Finally I've tried to run the "Smoke test" as defined in the "DTCoreText Programming Guide".
Without success. XCode can't find the DTCoreText.h file (or any other file of this lib).
Have I missed something? Please help! :o)
Did you check the Header Search Paths in the Build Settings to ensure the path is correct?
Thanks to #Michael and #eharo2, you pointed into the right direction.
I wasn't aware that it's necessary to copy ALL header files together with the library file.
Btw. the relevant path is defined in the Build Settings under Search Paths in Library Search Paths

Resources