Should I specify any path to access the header files in Xcode? - ios

I have the source code for a video decoder. The code was executed without any problem on the MAC terminal.
Now, I need to port it on iOS. The source code has around 20 source files and 40 header files. I have created a project in Xcode 4.2 and put all of these in the project folder, without creating separate folders for headers and source files. When I tried building, its giving errors since the source files are not able to access the needed header files.
Is there any path that I need to specify for the headers?
Please help. Thanks in advance!

What about :
Project Target
Build Settings
User Header Search Paths (set it to your header path)
Always Search User Paths (set it to YES)
*These steps should (normally) resolve any "header not found"-related issues.

Related

Cocoapod path reference error

I have newly added cocoapods into my application, now getting “parser error” while compiling the code in client machine, But the same source code working fine in my system (without any changes).
Please find below error along with screen shot.
../../../FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAccessToken.h
And also i have added this tag ($(inherited) - > non-recursive) into below paths in Target -> Build settings.
Header Search Path,
Framework Search path,
Library Search Path.
i hope this is cocoapods path reference issue, Please any one help me out of this issue.
Note: Have sent file to client as a .zip.
Finally i came up with answer, I have sent source file to client end(other systems) as a .tar.gz format instead of .zip file.
This is solved my issue.Hope it will help for some one in the future.....

XCode - iOS - <OCMock/OCMock.h> file not found

I Have an iOS application that I am trying to add OCMock to in order to better unit test it. I've followed the instruction on ocmock.org as well as instructions I've found in other places but still I cannot get my test code to compile.
Here's what I've done
Added the source code to my project directory
Create the groups in my project to mimic my file system
I selected the option to add to my test targets so the framework was added appropriately as well as the Library Search Path
Then I manually added the headers to the Header Search Path
And added the -ObjC linker flag
Then when I go to import the header file, I get the file not found error
Any ideas what I am missing here???
You have the search path test/libraries/OCMock. Then you have #import <OCMock/OCMock.h>.
This fails because there is no file test/libraries/OCMock/OCMock/OCMock.h.
You use the search path test/libraries, or you can create a prefix directory to hold OCMock and have the search path point at that.
I generally have a directory with the library name and version number before the actually directory.
The directory test/libraries/OCMock-X.X.X could contain the OCMock directory. That way the search path still be more specific: test/libraries/OCMock-X.X.X and you still use OCMock/OCMock.h as the include.
One more thing to check, for anyone else having this problem - I copied OCMock from one project to another and everything looked right, but it wasn't finding the include file. It turned out that even though I had the right groups in Xcode, the files had all been dumped into one directory. I needed to create folders on disk and associate them with the groups in Xcode. The accepted answer here clued me in to what was wrong (though as is often the case, in hindsight it should have been obvious).

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

Two targets, two header files with the same name how to use each header for the right target?

Ok, here's what I've tried.
I have the header files in two separate directories IRL. They're named the same, but are in two different locations.
I want to only include the relevant header file for each target. Lets say for ease of explaination that the header file is called "Config.h".
So I have:
${PRODUCT_DIR}/Header1/Config.h
and
${PRODUCT_DIR}/Header2/Config.h
These files appear in the LHS of Xcode as well in two different groups (Header1 and Header2 which point to the IRL folders).
So now all I need to do is to make Xcode choose the right one from the right folder for each target.
Target1
and
Target2
I have tried adding the path to the User Header Search Paths for each target, but its still choosing the wrong one. I've also tried toggling "Always search user paths" which also doesn't seem to have an effect.
So my question is, is this because they're in the Project directory? Or is it because they're in Xcode in the file manager on the LHS, so therefore Xcode is copying them into the build folder?
The strange thing is it seems to be choosing the header files from the folder with the last name alphabetically...
In previous versions of Xcode I'm sure you could choose which headers to copy into the build folder.
Anyway.. does anyone know how I can fix this so that I can have it select the proper header file for the target?
Many thanks.
The problem I was having was 2 fold:
You need to remove the header files from the project. If they're in Xcode, in the file manager, then they will automatically be included in the project.
You need to use relative paths to your folders in "User Header Search Paths". I was using ${PROJECT_DIR}/path/to/header/folder which gave the right path, but didn't seem to work properly. Changing the entry to ./path/to/header/folder instead worked fine.
I have 4 targets in 1 proyect and more than 40 headers, the best solution in XCode 8
I think the best solution is change the following tag:
Always Search user Paths
To yes an all was fine for me:

Is it possible to Add .pch File in project?

I Download Project for learning purpose. But in this project i got error that is display in MY Screen Shot . i know that Prefix headers are compiled and stored in a cache, and then automatically included in every file during compilation. This can speed up compilation, and lets you include a file without adding an import statement to every file using it. They are not required, and actually slow compilation whenever you change them.
Screenshot
My Question is that is it possible in my case to add .pch file or not ??? if possible then please explain it.
Thanks in Advance.
The screenshot shows that you do not have the pch file added to the physical folder or it is removed somehow from there even though it is added to the project. You need to add that file again and build to remove this error. You can remove the reference from project before doing that and add it as a new file to this project once you have added it in your physical folder.
A red file name in project as shown in screenshot normally represents a missing file from the project folder structure.

Resources