How to include a class from a subproject - ios

(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

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

Installing the Gracenote SDK (GNSDK) within XCode

I am attempting to get the GNSDK framework working within XCode but I'm having some issues. I dragged the framework file from the example project into my project and adding a bridging header (since the rest of my project is in Swift). The bridging header consists of:
#import <GnSDKObjC/Gn.h>
However, XCode returns that this header file cannot be found. This is what my "frameworks" look like:
Frameworks screenshot
Note that adding or removing the .plist and .pch files does nothing. Any help would be appreciated.
Do you see the framework in the "Link Binary With Libraries" dropdown? Click on your project name (1st item in your Project Navigator). You should be able to see them in the main window. You could try deleting it and adding from here.

Adding sub-project in swift

I have 2 projects in a workspaces, both are built using Swift.
I want to use one of the project as a sub-project of the other one and the classes, which are in the sub-project, in the parent project.
My sub-project is using bridging-header.
I have tried to add one project as a reference to another and imported the class, which is in sub-project, but it didn't work.
Showing me Error: "No such module "
Please help me achieving this?
Fixed the issue, thing i did was:
Removed bridging header file, which was bridging my objective-C and
swift code from my framework and deleted the bridging header file from Build Settings.
Created a file named "Framework-name.h" and copied all the header files, which were there in my bridging header file, into "Framework-name.h" file.
import "Framework-name.h" inside "Framework-name.h" file (this is vey important, it will keep the file at the root level of the framework).
Made "Framework-name.h" and files that were included in Framework-name.h" file public.
Created an aggregate target for my framework. https://medium.com/#syshen/create-an-ios-universal-framework-148eb130a46c
Built the framework.
Drag and drop the created framework into the root level of another sample project.
Test the framework, writing import Framework-name in swift class of the sample project.
Build the project.
Bingo!!!

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.

Linking one xcode project from another

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.

Resources