Linking one xcode project from another - ios

I have two xcode project for example A and B. I include project B into A and try to import some header files of project B. Project B is built successfully but when I try to build project A It throws error as header file not found. How can I resolve this?

In Xcode, for Project A check your build settings->Header Search Paths and User Header Search Paths. Do they contain the path of the header files for Project B? If not, add the path in one of these fields.
Watch out:
Including a header in a Header Search Path involves writing this:
#import <header.h>
whereas importing a header in a User Header Search Path involves this:
#import "header.h"
I would recommend putting it in the Header Search paths to distinguish including headers from project A and project B in your code. It improves readability in my opinion.

Related

Importing a library in to an Xcode 7 project

So I am trying to add a static library to my project in order to interface with a scanner. I have linked the binary in build phases to the libCaptuvoSDK.a, put the Captuvo.h header file in the project folder, and finally set the project to always search the user paths and added $(BUILT_PRODUCTS_DIR) recursive to the user header search paths. After doing all this I am trying to use #import "Captuvo.h" in my ViewController.swift file and getting the 2 errors Expected identifier in import declaration, and Expected expression. I have tried different combinations of importing and none of them seem to make a difference so I am led to believe the issue is with my process of adding the library.
I am new to Xcode and have never used a third party library in an application before so I feel I may be making a simple mistake or just misinterpreting things. Any help is appreciated!
Okay so I managed to fix my issue! I had imported the static library properly but the real issue was the header file. I fixed my issue by creating a new file in my projects folder named Quick-Scan-Bridging-Header.h. Inside that file is where the #import "Captuvo.h" line belonged. Once that was done I opened the Quick Scan apps build settings and under Objective-C Bridging Header I added the path Quick Scan/Quick-Scan-Bridging-Header. I also added the Header Search Path $(BUILT_PRODUCTS_DIR)
After I did all this I am able to use the Captuvo classes in my ViewController.swift file.

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.

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.

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

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