Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between #import <Library/Library.h> and #import <Library.h> using CocoaPods?

Tags:

ios

cocoapods

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?

like image 866
JRG-Developer Avatar asked Feb 13 '14 19:02

JRG-Developer


1 Answers

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.

like image 81
Gavin Avatar answered Oct 03 '22 19:10

Gavin