iPhone - Static libraries, purpose of "Copy Headers"?
Asked Answered
P

2

6

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?.

Plank answered 27/3, 2012 at 12:29 Comment(0)
S
1

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

Sachet answered 27/3, 2012 at 15:14 Comment(0)
C
1

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

Communard answered 15/7, 2013 at 9:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.