I've seen guides on CocoaPods that recommend importing a needed pod's library header like this:
#import <Library/Library.h>
Where Library
is the name of the library (e.g. #import <AFNetworking/AFNetworking.h>
).
I've also seen guides that recommend importing a needed pod's library header like this:
#import <Library.h>
(e.g. #import <AFNetworking.h>
)
Both methods compile and seem to work.
What's the difference and which should be used?
Either way works fine if the header being imported is unique. But if you have a header with the same name in two different third party libraries, it gets ambiguous, and you will need to specify which one you want.
Generally, it's best to specify the library name so that this case won't happen, but also because it's immediately apparent to somebody reading your code what library that header file is a part of, since it's not always apparent based on the header name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With