Add a custom framework in a custom framework - objective-c

I am developing an iOS Real Framework with XCode. This Framework (A) needs an external framework (B) to compile. For example:
A FRAMEWORK
+Frameworks
-B FRAMEWORK
It is imported in A by using:
#import<BFRAMEWORK/bframework.h>
I create the A.framework to be linked in a project.
The problem is when I link this A Framework in a project. The project returns "BFRAMEWORK/bframework.h" not found.
I want to include B framework in A.framework so not to need to add B framework also in my project. For example:
MY PROJECT
+Frameworks
-A.Framework (with B Framework included inside).
Do you know how to do this? or another way to do this?
Thank you!

I was able to create this structure with iOS-Universal-Framework: https://github.com/kstenerud/iOS-Universal-Framework.
I created a Static iOS Framework 'FrameworkB' with 1 method, which is imported in a second Static iOS Framework 'Framework A' with 1 method that's calling FrameworkB's method. I then created an iPad app which imports FrameworkA and calls the method. Code runs fine and prints from FrameworkA (which fetches from FrameworkB) and of course FrameworkB is not imported. Please note that all frameworks have to be built for the same profile (i used iPad), otherwise you'll get linker errors.

Maybe you add BFramework in compile sources?
Or add headers in header search paths?
or set dependency in build settings.

I think you are looking for OTHER_LDFLAGS = -ObjC

Related

Adding Swift Class to Objective-C Project with Multiple Targets

I have an existing Obj-C project that houses many targets that all share the same AppDelegate. I want to bridge a swift class that is used by select targets. I can do this easily when I have one target.
When I add a swift file to the project, I select the desired targets and the necessary bridging-header.h files are generated, but when I try to import those -swift.h files, they are can't be found.
Are there steps I'm missing when it comes to projects that have multiple build targets?
EDIT - More Details
I wanted to add a little bit more detail on how my project is set up.
I have a Framework, we'll call it AppFactory, coded in Obj-C. I have multiple build targets that generate different versions of the Core app depending on information in that target's plist. I want a swift file to be utilized by these apps. In my build settings the Defines Module is marked to Yes, I have create this swift class:
#objec class SwiftClass: NSObject { }
And in doing that, Xcode generated the proper Briding-Header.h files.
According to Apple Guides when you have multiple build targets your import header should include the ProductName/ProductModuleName-Swift.h, which should be auto generated by Xcode.
When I look in to my derived data folder, the ProductModuleName-Swift.h does exist, with in each targets build folder, under the AppFactoryCore folder.
I found a solution to my problem.
Swift File Targets:
Instead of having SwiftClass.swift target both the framework and the selected targets (AppA, AppB & AppC), I backpedaled and solely targeted the framework, AppFactoryCore.
Build Settings (Packaging > Defines Module):
I reverted each app target's Defines Module property from YES to NO, and set this property to YES for the framework target.
Swift Class Declaration:
The guide states:
Because the generated header for a framework target is part of the framework’s public interface, only declarations marked with the public or open modifier appear in the generated header for a framework target.
So I added access control modifiers to my class and class functions
#objc open class SwiftClass: NSObject {
//Code
}
Import Header:
Since SwiftClass.swift is only targeting the framework target, and it is in fact a framework that is being used, the header import SwiftClass.swift into the universal AppDelegate was
#import <AppFactoryCore/AppFactoryCore-Swift.h>
Which finally became visible once all previously stated modifications were done.
Now that the file is global to all targets I added a custom attribute to identify if the target running was is one that should utilize SwiftClass.swift.
Hope this helps anyone else trying to accomplish a relatively similar task!

How to make a custom Class file part of Xcode? (I.E. importable from any new project without having to copy the class)

As the title says, I wanna be able to import a custom class of mine from any new project. So for example, if I have a class called LAView, I wanna be able to type #import "LAView.h" from any new project without actually having to copy LAView.h and LAView.m into the project itself. Is that possible? :)
Create a framework, copy the finished product into /Applications/Xcode.app/Contents/Developer/Library/Frameworks and /Library/Frameworks/
This way your framework will be visible and available in any Xcode project and you can access it like any other framework from the Xcode frameworks list.
NOTE: When you edit your framework you will have to copy the new version into both these locations again. You can automate this using BASH scripts run from the Terminal (if you do this be careful!).

Xcode 4 'QuartzCore/CIColor.h' file not found

I'm running Xcode 4 and trying to follow the steps in Apple's Image Kit Programming Guide (which is written for Xcode 3) on how to work with an Image View and the IKImageView class. I just imported the Quartz and Quartz Core frameworks (from /System/Frameworks directory) to my blank Cocoa Application project using File > Add Files to... menu, but when I try to Run my application I get this error:
Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found
Does anyone know what could be a reason?
Peter Hosey replied:
You're not supposed to import specific headers directly, and especially not from sub-frameworks (such as Core Image, sub-framework of QuartzCore). Only import a framework's overall header, which usually has the same name as the framework.
I didn't import any specific headers directly, I just choose File>Add Files to... then choose /system/Frameworks and choose two folders which contain those frameworks, after that they appeared in my project navigator view as they should, but the code wouldn't compile any more. It shows me NSColor.h file which is found in the AppKit framework, points at this line: #import and says Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found. I have no clue why it wouldn't compile. CI stands for Core Image. I'm now reading a guide on Core Image, maybe this will help. I'd like to post a screenshot but I can't (not enough rights yet).
I just imported the Quartz and Quartz Core frameworks (from /System/Frameworks directory) to my blank Cocoa Application project using File > Add Files to... menu, …
That's not importing; that's just adding it to the project (and hopefully the target). Importing is what you do with the #import directive.
… but when I try to Run my application I get this error: Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found
You're not supposed to import specific headers directly, and especially not from sub-frameworks (such as Core Image, sub-framework of QuartzCore). Only import a framework's overall header, which usually has the same name as the framework.
The problem was that the Guide I used was written for Xcode 3 so when I tried to import/add some frameworks to my project using "File>Add files" menu as described, it did add those frameworks and I could see them in the project navigator, but something went wrong. In Xcode 4 you should use a different way to add/import Frameworks by using the Project Editor> Summary tab> Linked Frameworks and Libraries> Click "+" and then choose the Frameworks you need. That fixed the issue.

xCode 4 import Framework doesn't work

I have added the objection Framework to my project via linked binaries.
Now I am trying to import a file form this framework
#import <Objection/Objection.h>
But the compiler says: Objection/Objection.h not found!
I tried everything,
other linker flags are set to -ObjC and -all_load
Framework search Paths are set to the correct directory
The Library is linked within the project
So what else could be the problem?
Thanks for your help in advance!
When the Objection framework is built for iOS the framework is called 'Objection-iOS.framework'. Ergo the import would look something like this:
#import <Objection-iOS/Objection.h>
Did you add your framework like so ?
In the project navigator, select
your project
Select your target
Select the 'Build Phases' tab
Open 'Link Binaries With Libraries'
expander
Click the '+' button
Select your framework
(optional) Drag and drop the added
framework to the 'Frameworks' group
See Apple's documentation on this
If you have done exactly what I said above then I'm not sure if this is going to work, but I use another method to add frameworks, which is go to your project (The one with the xcodeproj icon), then click on your target. There, you can add the frameworks you want.
If that doesn't work, then try go to /Library/Frameworks to see if your framework you want is still there. If it's there and it's still getting that error, try manually adding the framework which is the add other button when you add a framework.

How do I add the library to link the OpenGL framework in iPhone SDK?

I am trying to study OpenGL and I have the framework added, but I am getting linker errors. I believe the issue is adding the library to the project for linking and EVERY time I try to add a library, I hunt around for the configuration setting forever. Someone, please give me the simple click-n-go answer!
The linker cannot find the CAEAGLLayer framework to link against.
Add the QuartzCore.framework and the linker will be able to find the missing framework.
To do this right-click on the Frameworks the choose:
Add > Existing Frameworks > QuartzCore.framework.
alt text http://img19.imageshack.us/img19/223/screenshot20091206at544.png