Reputation: 628
I'm writing a framework written in Objective-C and I've just encountered an issue after trying to link the framework target to another project. When I compile this last project, Xcode shows the error 'AFHTTPClient.h' file not found
.
My project is structured in this way : the headers I wrote by myself are public and the headers from the libraries I'm using are in a project visibility, thus the developer isn't polluted with unnecessary files.
The JPImgurKit.h
file imports the file JPImgurClient.h
(and other ones) which imports the AFHTTPClient.h
file and fails for it... When I put this last file in the public section it works (until another private file is imported) but I would like to avoid this, is it possible?
Upvotes: 3
Views: 2059
Reputation: 299265
Public headers must not import private headers. There should be nothing in your public header that relies on private data structures. If the caller has to know about the private data structure, then it's not private. If the caller doesn't need to know about the private data structure, there's no reason to include it in the public header. You'd have to give more details about your particular header (what parts of AFHTTPClient
are in JPImgrClient
?)
That said, you should not privately include a common library like AFNetworking. There may be other frameworks that require it (including the main program). If you include it privately then there will be collisions which will be very challenging for the end developer to resolve. You need to let your users know that they need to include AFNetworking along with your package. You cannot easily hide this implementation detail without causing your users a lot of headaches.
Upvotes: 6