Does .h need to be included when using header search path? - iphone

I'm referencing a static library.
I've dragged the library project into my app project and reference it relatively.
The .a file from the library is linked into my app target.
I've added a reference to the librarys .h files' folder via Header Search Paths in the app project.
Then I add an import in my apps .pch file to a particular .h file from the library.
I build and get this error:
some.h: No such file or directory
The project is given info on where to find .h files for the library. Why can't it see them?

Try with
#import <some.h>
instead of
#import "some.h"

I don't think so. I just got one set up today piecing it together from the links below. I didn't include any .h files in search paths. In fact the one tutorial told me to remove any existing search paths (but I had to add them back for another library). Hope this gets you on the right track.
http://www.clintharris.net/2009/iphone-app-shared-libraries/
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
http://blog.costan.us/2009/02/iphone-development-and-code-sharing.html

Related

What is Header Search Path in Xcode 4.3? How to use it?

I want to add one existing project into my new project. I have added if using "Add files to "Project".
When I'm going to import it's .h file in my new .h file. It say file not found.
I have tried to add Path for Header file in Header Search Path in Search Path. But I don't know how.
Which path I have to add in Header Search Path?
And What is Recursion in Header Search Path?
Suppose u have included a third party library or files say "JSONKit" whose path is outside the project folder and have added in your project then you have to specify that particular folder path in your header search path,else you will get an error.below is an example of it

SDWebImage/UIImageView+WebCache.h file not found while archiving [duplicate]

I am fairly new to ios development - trying to use sdwebimage in my iphone project. I believe I completed all basic setups as required. But when I build, I get this error: No such file file or directory near this line:
#import "UIImageView+WebCache.h"
Yes I have added Target Dependencies
I have added libSDWebImage.a in Link Binary With Libraries
I have -all_load -ObjC in Other Linker Flags
I also tried the -force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a (64bit mac)
My Use Header Search Paths is : $(BUILT_PRODUCTS_DIR)
I cleaned the project and rebuilt - but no use.
Build keeps failing. Again, XCode4 code completion "resolves" when I type #import "UI & hit "ctrl+space" which means the lib is visible to xcode. Any pointers will be super helpful. Thanks.
To add the needed header files to the build path do the following.
Select your project file
Select your target
Select Build settings
In the search box enter 'header search paths'
For the Release add "$(SOURCE_ROOT)/SDWebImage" (thats with quotes).
This will work when importing like this #import <SDWebImage/UIImageView+WebCache.h>
I also use SDWebImage.
In my experience I didn't do anything with the linker flags etc.
You only have to add the classes in your project and simply import the "UIImageView+WebCache.h" in your class' header like this:
#import "UIImageView+WebCache.h"
and if you want to use it on an UIImageView object, just use the method
setImageWithURL:placeholderImage:
you can refer to their github for more info
I just ran into this problem and have solved it.
The issue is that when you "drag" the SDWebImage xcode project to your project, Xcode only create a reference to point to those files needed. When you are in debug mode it's fine, it knows where to find those file. However, when you want to archive it (packing everything to be self-contained), it couldn't find it from your search path.
Although you have added $(BUILT_PRODUCTS_DIR) to your search path, but if the actual files that you downloaded are not physically located in your $(BUILT_PRODUCTS_DIR), then Xcode won't find them. This was the problem for me since my SDWebImage files were still sitting in my download folder.
What you want to do is:
1.Move the SDWebImage folders to a place where you won't accidentally delete it. Notice once you've done that, the SDWebImage project file will become red since it's physical location is moved. And it's wired that I could not delete that reference in Xcode, what I ended up doing is add that file again (choosing from the location where I just move it too). You will end up with a red SDWebImage.xcodeproj in your project navigator which you can not delete. It's very annoying but it won't affect anything.
2. If the location you move the SDWebImage stuff to is not in your $(BUILT_PRODUCTS_DIR), then you either move that inside $(BUILT_PRODUCTS_DIR) or as I do, add the path to Target -> Build Settings -> Search Paths -> User Header Search Paths.
Archive and it should work now.
I faced this same problem and was about to go crazy. Like Ravi, I followed the static installation instructions as closely as possible.
I saw the auto suggest for UIImageView+WebCache.h when I was typing #import, but it keeps throwing file not found.
In the end, it was this. In header search paths,
“$(BUILT_PRODUCTS_DIR)” - Wrong.
$(BUILT_PRODUCTS_DIR) - Right.
Embarrassed but now it's working right =)
I've been dealing with this problem for the past hour and noticed something that hasn't been mentioned: Make sure that when you up update header search paths that the "Recursive" option is selected! Otherwise the compiler will not check subfolders.
Worked for me...
I was dealing with the same problem, my two frameworks were not getting found. I tried all the suggested ways in order to resolve the error but it couldnt help. Atlast I deleted the frameworks from my project structure and reloaded them from the original project file and it worked!! Please try this if it helps, It worked for me...
I had a similar issue after pod update. If you are using CocoaPods version higher than 1.0.0 and more than one target in your project, you have to add all the targets into the Podfile.

Importing Objective-C JSON Framework in Xcode 4

The instructions for installing the JSON Framework seem to be for older versions of Xcode. I'm relatively unfamiliar with Xcode and I can't figure out how to properly import the framework into my project. I selected all of the files in the "Classes" folder (JSON.h, NSObject+JSON.h, etc.) that comes in the download, dragged them into the main area of my project, and added #import <JSON/JSON.h> to my ViewController's .h and .m files, and I get a No such file or directory error for JSON/JSON.h
What am I doing incorrectly here?
If you’ve placed the files under the Classes group and haven’t taken any further action, they’re at the root of your project directory. As such, import it as
#import "JSON.h"
I think you're indicating that you're importing JSON.h from the JSON folder, and it sounds from your description you don't have those in a folder...

adding custom library with project

I have created one library with "Utility.h" file. I want to add that custom library to my another iPhone application. I have added the library to project "frameworks" and I have drag the library to "Library Search Path" it shows like "$(SRCROOT)/libUtility.a". I have imported the header file as #import "Utility.h". But I am getting below error message.
Utility.h No such file or directory.
Please any one help me to resolve this issues.
What is my mistake.
You have to drag the Utility.h file to your project as well along with your library.

How can I use different .h files for several targets?

I have a project with several targets. For most of my classes, I can use a single .h file and change the details in the .m file (adding a different .m file for each target).
For one of my UIViewController subclasses, I need to declare different UILabel IBOutlets for the different targets (each target shows a different set of labels depending on what's available). The problem is that header files can't be targeted. There's no checkbox next to them to specify target membership.
The way I've been dealing with this is to just add outlets for all of the targets and ignore the unused ones. It doesn't seem ideal.
Do I need to use a header build phase for this? What's the best way to deal with this problem? Thanks.
Edit: I should have mentioned that I want all the .h files to have the same name: PlaceViewController.h.
You can use preprocessor directives to selectively include the header files. For instance
#if TARGET_OS
#import "FirstTarget.h"
#else
#import "SecondTarget.h"
#endif
You can use different folders for different targets if the headers are the named the same:
#if TARGET_OS
#import "First/Target.h"
#else
#import "Second/Target.h"
#endif
You can read more about conditionals here.
Headers don't get compiled themselves, but are included in other files which are then compiled. You can use conditional compilation inside those files to include the correct headers for the target. Define a unique symbol in the preprocessor symbols for each target, and include the appropriate headers accordingly:
#if defined(TARGET_ONE)
#include "HeaderOne.h"
#elif defined(TARGET_TWO)
#include "HeaderTwo.h"
#endif
I'm sorry to be answering a couple of years too late, but I recently had the same problem, and there's a way to do this:
Let's say you already created a new target by duplicating the original target. Right-click the first (original) .h file in the Project Navigator and open the file in Finder.
In Xcode, right-click the file, and remove it from the project (only remove reference, do not move to trash).
In Finder, create two folders (you can't have two same-named files in a single folder), and move/copy the original .h file in both of them.
Now, drag-and-drop the first folder somewhere in your project, and when the window with the targets pops out, select only the first target.
Same with the second folder, select only the second target.
Voilà, you should now have two same-named .h files.
Caveats: it seems Xcode has random problems if your .h file has an NS_ENUM. It is probably solvable, but I still haven't figured it out.