On Apr 19, 2016, at 11:27 , Alex Zavatone <[email protected]> wrote:
> 
> Sorry this is going on so long, but all I'm looking for is to set up a simple 
> constants file that works in a framework (and only for my framework) just the 
> same manner they work within an iOS app.

You have the answer already, but you didn’t recognize it as it whizzed by.

There is a build setting for “Prefix Header”, which is a header file (like a 
normal .h file) that contains #import and #include statements (and possibly 
other source such as #if, #define, and even declarations). This header file is 
included at the start of every compilation for the target using these build 
settings. So, to get constants.h included in every compilation for the 
framework, add "#import constants.h” to your prefix header for the framework’s 
build settings.

The convention is that this header file has a “.pch” extension rather than 
“.h”, for historical reasons. But it’s just a source file, and you can filter 
your build settings with “prefix” to find it easily.

[Separately, it’s possible to *precompile* this into a “precompiled header 
file” — hence the “.pch” extension for the source, but this is an optimization 
detail, controlled by a different build setting. The (built) precompiled header 
files does *not* have extension “.pch”, and it’s not even in the derived data 
for the project, because it can be shared between projects. Again, the 
recompilation aspect is a different issue.]

Also, when you have a prefix header (.pch), it’s typical for this to be 
available in the list of files belonging to your project, in the project 
navigator on the left of the Xcode window. That makes it easy to bring up the 
file for editing. In the past, this was present when your target was created 
from an Xcode template, but if it’s not there in the framework target, you can 
add it yourself.

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to