gregory
gregory

Reputation: 21

Import header in a static library iOS

I have a relatively simple question and I hope to get an answer on it.

Imagine I have a static library in iOS say MyLibrary.a

In this library say there is some .m file which calls: "#import SomeHeaderWhichDoesNotYetExist.h" -- however the thing is that, when the "#import SomeHeaderWhichDoesNotYetExist.h" is called, the SomeHeaderWhichDoesNotYetExist.h may not necessarily exist in the project (as suggested also by its title). e.g.,

#ifdef something
#import SomeHeaderWhichDoesNotYetExist.h
#endif

When someone uses the Mylibrary.a -- he/she may then, later implement the SomeHeaderWhichDoesNotYetExist.h, and we want the MyLibrary.a to be able to automatically use it as specified in the code above. Do you think this is possible?

Thank you.

Upvotes: 2

Views: 272

Answers (2)

Anoop Vaidya
Anoop Vaidya

Reputation: 46543

We often use similar kind as you can see

#ifdef TARGET_OS_IPHONE 
    // iOS
#elif defined TARGET_IPHONE_SIMULATOR
    // iOS Simulator
#elif defined TARGET_OS_MAC
    // Other kinds of Mac OS
#else
    // Unsupported platform
#endif

So I would say, yes you can!!!

But you need to define something.

Upvotes: 2

RonaldBarzell
RonaldBarzell

Reputation: 3830

No, it can't, at least not the way you showed.

The conditional compilation blocks you showed are for the pre-processor, and it is called before compilation. If you want to include anything new this way, you must rebuild.

Upvotes: 0

Related Questions