Does the target name have to match the directory name?

I'm trying to create 2 targets with the same underlying files:


LoggingSharedFramework - targets iOS

LoggingSharedWatchFramework - targets watchOS


The files are stored in $(PROJECT_DIR)/LoggingSharedFramework


I can get both of these to build independently, but when I include LoggingSharedWatchFramework into a watchOS project, there are problems finding headers. I've messed around with the umbrella header and had some incremental successes, for example, duplicating the umbrella header LoggingSharedFramework.h as LoggingSharedWatchFramework.h and including the watch-specific version in the watch project only, but there are still problems finding other headers.


My hunch is that the target name has to be the same as the directory name - is this correct? If not, is there some trick to using a framework in both iOS and watchOS other than duplicating the framework and changing the name?

Accepted Reply

The target name does not need to be the same as the directory name. In general, the target name isn't used for anything and can be freely changed.


If your goal is to be able to use the same "import" statement in files shared between the two targets, then you can do it by having two different targets, and manually setting the same product name in the settings for each target. (Normally, the product name is based on the target name via a macro, but you can replace it with an explicit name.)


It's not clear what's causing your header file problems. If you're using modules, then the header files are found from the module. If you're not using modules yet, things may be a bit messier.

Replies

The target name does not need to be the same as the directory name. In general, the target name isn't used for anything and can be freely changed.


If your goal is to be able to use the same "import" statement in files shared between the two targets, then you can do it by having two different targets, and manually setting the same product name in the settings for each target. (Normally, the product name is based on the target name via a macro, but you can replace it with an explicit name.)


It's not clear what's causing your header file problems. If you're using modules, then the header files are found from the module. If you're not using modules yet, things may be a bit messier.

Thanks for the answer.


There was an issue with which headers were being included as project vs public and in the umbrella header. I've ironed that out.


The product name hint was really helpful, too. Thank you.