Prefix Header import in another project - ios

I've a framework project let say ProjectA which is included in another iPhone project ProjectB, so ProjectB is dependent on ProjectA.
ProjectA has a prefix header file in which I've imported one header file of a clss written in ProjectA itself, so this import will be placed in all the classes of ProjectA.
Now what I need is, that imported header has to take place in all the class files inside ProjectB which is dependent on ProjectA.
Please give me suggestions on how to accomplish this.
Thanks in advance.

Edit the code file for ProjectB...
Alternatively, go to the build settings, search for 'prefix' and edit the path which tells the project where the .pch file that it should use is.

Related

Xcode can't find header file

I am trying to make a framework for my project. Into my framework I added the path of my header files to target>Build Settings>header-search path. After that I added this framework to my project by Build Phases>Link Binary With Libraries.
When I want to import the header file which I included in my framework, I get a .h file not found error. Is what I'm trying to do possible? Or am I missing anything?
I created framework like that;
Opened new project as iOS>Framework&Library>Cocoa Touch Framework
I didn't add any class, i just added header search path and library search path and linker flags. I don't think i did a mistake in this part because we do it in every project but first time i m doing this for framework. Then i pressed run and get my framework from Products.
I opened my project and added framework Build Phases>Link Binary With Libraries. I m able to import header file of framework like #import <myframework/framework.h>
After this i added framework also General>Embedded Binaries. Everything look normal but i cannot add headers to my project which i included to my framework with header search path. I have to use header search path because there is tons of headers, i cannot add all of them to my Xcode.
Make sure you all Public Header appears in Public Section else drag and drop .h file to public
Everything look normal but i cannot add headers to my project which i included to my framework with header search path.
It sounds as though you're expecting all the headers that can be found at the path specified by your header search path will become part of your framework, so that if there's a header named SomeHeader.h in your search path, it will be built into your framework and you'll be able to import it into client projects like:
#import <MyFramework/SomeHeader.h>
But that's not the case at all. If you want your framework to provide SomeHeader.h, you need to add that file to the project and, as Meghs Dhameliya already pointed out, you need to specify SomeHeader.h in the Public Headers portion of the Headers build phase. This will make Xcode copy the header file into the framework so that clients of the framework can import the header file. It's not clear that that's what you really want, though... in comments you wrote:
There is a lot of headers in another path. I have to use header search path unfortunately. Kind of company rule.
So it sounds like all projects in your company specify the same header search path so that they have access to these header files. If that's true, then there's no reason for projects to need to #import them from your framework, but in that case it's not clear what the actual problem is. Or, perhaps you're creating the framework so that client projects can get the headers from your framework instead of having to reference the header search path. In that case, you will need to add those headers to the project and specify them as described above.

How to include a class from a subproject

(Xcode 6.1, Objective-C, iPad)
I have an Xcode project with another project--a subproject.
I am trying to #import a class from the subproject in the usual way:
#import "myAwesomeClass.h"
But I'm getting an error:
'myAwesomeClass.h' file not found.
When I open the subproject, the class is right there in the hierarchy.
How do I include a class that exists in the subproject into the main project? Thx :)
The main project are looking for the subproject's headers in its root folder, so if the subproject is not "physically" a child of the main project, you will get this kind of issue.
You can explicitly set a header search path for your main project.
In Xcode, select your project, build settings, and under the Search Paths section you will find a parameter Header Search Paths. Add the desired paths (absolute or relative) and the headers of the subproject will be found

Copy header files into include folder with CocoaPods

I developing a library and I have next use case. For instance, I have project A that has dependency on project B. I want to setup my pod in project B, so both project A and project B have access to my pod functions. So dependency chain will look like:
My Lib
|
B
|
A
Actual code will be compiled and available in runtime in project A almost automatically, but I can't compile it because project A does not see header files from my library. The header files places in Pods/MyLib/MyLib/CustomIdentifier directory (because s.header_dir = 'CustomIdentifier' to have access with import like: #import <CustomIdentifier/Header.h>).
I don't want to specify in project A direct path to header file (I do not want user have to do additional action to install my lib). I want CocoaPods to copy my header files or links to them into Products/../include folder so they will be available automatically.
How can I do it? Preferably with podspec file.
Thank you for you help!
Looks like it has to do with folder paths
Quoting from docs:
header_mappings_dir
A directory from where to preserve the folder structure for the
headers files. If not provided the headers files are flattened.
Examples:
spec.header_mappings_dir = 'src/include'
Helped me with a similar issue.
s.header_mappings_dir = 'armadillo-4.200.0/include/' #allows any folders in here to be avail from project. Namely the folder of headers, armadillo_bits
http://guides.cocoapods.org/syntax/podspec.html#header_mappings_dir

public header files in iOS static library

I have developed static library for my applications. It generates .framework, .bundle, .a files.
I want to enhance the use of library. Currently my framework has 4-5 files as public scope to application. Only those headers are visible to application (Interface). Is there any way to create common header file at build time of framework, which will contain/ imports of all public files from my source code(frame work code.)
e.g. once I build framework code, it will generate .framework which will create/have common.h header file consisting all imports of public files.
By doing this, application needs to import only common.h. I know we can do this manually also. But is there any scope to do this by script at build time?
Thanks.
I tried using script I got success!
Here are the steps:
1. In build script where we create fat binary, we need to find out all .h headers. We need to take path in variable.
2. Loop and collect all public variable
3. Create and locate common.h (This will be path of header folder in .framework)
4. Put all files common.h

How to tell Xcode how to include a library specified with angle brackets?

I often see open source code importing third-party libraries in Xcode / Objective-C implementation files like this:
#import <ThirdPartyLibrary/utilities.h>
but when I drag & drop the file structure and files of such a library in my project, all these imports are corrupted and Xcode does not know where the files are.
I end up hand-modifying every import to look like:
#import "utilities.h"
And include appears it is relative to the current physical folder on the file system. When a library split its files in folders on file system and I drag-drop it in Xcode, Xcode creates groups for the folders. But for import, I have to specify the folder name. Problem is when I am in a folder, for example:
http/httpTools.h
Then when httpTools.h wants to import utilities.h from the root, I have to change
#import <ThirdPartyLibrary/utilities.h>
to
#import "../utilities.h"
which is a chore. After doing this for 5 hours I thought damn, there must be a better way. Can someone explain what is the secret to teaching Xcode a new framework location that can be imported with angle brackets? The framework btw is source code. Not compiled. Just the naked code.
Specify the include path using the compiler flag -I, or the Xcode build settings alias HEADER_SEARCH_PATHS. Of course, you can use build variables when doing so.
Just stumbled upon the same issue, there are two types of search paths in Xcode:
Header Search Paths
User Header Search Paths
If you add your own include folders into Header Search Paths, you can use angled brackets.

Resources