I am creating a library and even though it is working perfectly fine by packaging all my code and putting all the header files in a folder and then zipping the folder and the static library, I just can't figure out the purpose of the "Copy Headers" section under Build Phases.
I have read all this links:
Using open source static libraries
Creating static libraries for iOS
How to create universal static libraries
Stackoverflow: copy headers: public vs private vs project
But I still do not see the point of setting the copy headers, I realize you can set the private and public path under build settings > packaging, and that the header files will go to that folder after build. But what is the point in this?, is this any different than not setting a single copy header file, and simply grabbing the .a file grab all my header files and put them in a folder?. Also what is the purpose of setting copy project headers?, since they are not included in the target at all?.
Does the Copy Headers phase work now when producing an archive? Apple's documentation suggests that feature doesn't work and they suggested using a Copy Files build phase instead. Has this been fixed in recent releases of Xcode? https://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html
To my knowledge, adding the headers to the "Public" section of the "Copy Headers" phase is exactly the same as copying them in your release folder.
I use it as a convenience as I automate the library packaging process with a run script (thanks to this StackOverflow question which you should read if you want to provide universal libraries).
By doing this, I just need to add my new public headers to the "Public" section of the "Copy Headers" phase to have them automatically deployed in my release folder with this part of the script :
#########
#
# Added: StackOverflow suggestion to also copy "include" files
# (untested, but should work OK)
#
if [ -d "${CURRENTCONFIG_DEVICE_DIR}/usr/local/include" ]
then
mkdir -p "${CREATING_UNIVERSAL_DIR}/headers"
# * needs to be outside the double quotes?
cp "${CURRENTCONFIG_DEVICE_DIR}/usr/local/include/"* "${CREATING_UNIVERSAL_DIR}/headers"
fi
I've also noticed that those headers are copied in the package when archiving (Product -> Archive), so perhaps it's a first step from Apple to provide a clean way to build static libraries.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With