I have some shared code I want to reuse in my Xcode projects. The easiest way is using a shared framework. I must make headers public in order to reuse the framework in my projects.
Now: since the framework must be copied inside final products, is there an automatic way to prevent public headers from being copied too? Of course I can do this manually, but an automated trick would be amazing 🙂
Thank you
IIRC, you can do all that with frameworks. Frameworks can be installed system-wide, or inside the application package. If you haven’t read it yet, it’s in the docs : Embedding a Private Framework in Your Application Bundle
Basically, you’re going to make two variants of your framework, one for developing client applications, one for embedding inside those applications. In Xcode you can :
PUBLIC_HEADERS_FOLDER_PATHbuild setting with different values in two build configurations. (Say, “Development” and “Deployment”). Your header files will end up in different locations this way.I haven’t done this for a long time, but I don’t have particularly good memories of embedded frameworks. What type of code are you reusing exactly? Is this common, all-purpose code? Or is it a whole, coherent project?
If you’re just trying to reuse generic code, you might be better off using a simple, old-school
.astatic library with a headers folder, or even better, a static framework. (Which is just a static library inside a framework bundle)