New Obj-C Header File cannot import Frameworks

Hi,


I am in the middle of a building a Dropbox application and have already been set up the Framework and its working with the already created files.

I now decided to create a new header file and import to it the framework but it won't happen no matter what I try:


1) Auto-completion for importing does not work

2) when I manually import it, it cannot build because it does not find the framework


I have compared the new header file with the already created ones with no difference coming up. Can you help me, I m really stuck 😟

I'm having the same problem importing frameworks into xcode.

Any luck? Same issue.


In my case, I have a sub-project in Xcode, which builds to a framework. Then is linked.


I am unable to build using Xcode 6.4, was working in 6.3. All Obj-C.

What is the issue, exactly? What is the error message?


Note that if you add .m/.h file pair to the framework, and you want the .h file to be visible to the app that uses the framework, you must mark the .h file as "public" or "private", not "project".


— "project" means the .h file is local to the framework, and can't be seen by clients of the framework.


— "private" means the .h file is visible to clients of the framework, but the .h file is intended to be stripped out of the the final app bundle


— "public" means the .h file is visible to clients of the framework, but not stripped out of the app bundle


You choose this by displaying the Utilities pane at the right of the project window, and choosing the File inspector with the .h file select. In the Target Membership section, you'll see a popup menu.


Or, select the framework project item, choose the Build Phases tab of the main pane, then expand the Headers build phase. You can drag files .h in and out of the appropriate subsection to set their visibility.

I cannot for the life of me figure out how to access headers in the "private" folder. It appears I need the Umbrella header for my custom framework - fine - I have it defined. When I build the framework, I see that there is a "Headers" folder that the umbrella header is copied into, and I see a "Private" folder with the private headers copied into it.


However, from my umbrellla folder, I cannot reference a private header. I tried all combiantions of <foo/privateHeader.h>, then ../Private, etc.


What exactly is the magic string? :-)


Thanks!

Not sure exactly what's wrong in this case. You shouldn't need to treat private headers any differently.


It may be an issue of how how your headers are integrated into the project (is it a private, embedded framework), or you may need to set a frameworks search path. Alternatively, you can turn "use modules" on in the settings, in which case you just use "@import foo;" in source files that use the framework, rather than bothering with #import.

" Well, it won't find them with the normal "import <ModuleName/PrivateHeader.h> syntax. You said a "Framework search path", and no, I didn't set that - guess I could try that. Really, there is hardly any difference between public and private. Even if I have a XYZ.h file in Public, #import <ModuleName/XYZ.h> doesn't pull it in. I suspect the module map is only allowing the Umbrella header to be found.


For the life of me, I cannot get @import ModuleName; to work in Objective C files - amazingly Swift files can import the framework just fine. Is there magic needed to make this work? I hve modules enabled in both the framework and in the app itself. And things like @import UIKit; work just fine


David


PS: did you see my Custom iOS framework: how to force load when used? post in the LLVM forum?

Is the framework in the same project or a different project? That's going to make a difference.


I would suggest you try creating a new embedded, private framework (if that's what you want). All it needs in it is a dummy class that you can reference from your app. If the #import or @import works correctly, then you have a template for comparing build settings to find what's different.


Edit: No, I hadn't seen that post. I've almost completely moved on to Swift, and one of the benefits is not running into problems like this.

Different project. I created a few frameworks (each imported to an app as a Xcode project), and in no case can I get "@import MyModule;" to work in ObjectiveC - works every time in Swift classes!


Its not a big deal but puzzling.


Thanks!


David

Is the frameworks project in the main project workspace? Freestanding or subproject? These things might make a difference.


I have one app where there are several frameworks all in a second project. The second project is in the same directory as the main project (and a sibling of the main project in the workspace), but the source folders for each framework target are in separate subfolders named by framework. The app's frameworks search path setting is set to "$(SRCROOT)" but I don't name specific framework folders there. IIRC (from several years ago) I couldn't get the app to find the frameworks without this last step. At the time, there were no modules, so I was using #import everywhere. I see that the project has updated itself to Use Modules = YES, but I don't know whether that's relevant.


I can't honestly claim to understand why that worked, but it did.


The only other rational cause I can think of is that the Obj-C module name isn't what you think it is, while the Swift one is. There may be something going on with replacement of invalid characters (e.g. spaces by underscores) that produces different results in the two compilation environments.

New Obj-C Header File cannot import Frameworks
 
 
Q