Apple 的官方文档中明确提到了不建议自己去创建 umbrellaframework,Apple 的 Guidelins for Creating Frameworks 的官方说明:
Don’t Create Umbrella Frameworks
While it is possible to create umbrella frameworks using Xcode, doing so is unnecessary for most developers and is not recommended. Apple uses umbrella frameworks to mask some of the interdependencies between libraries in the operating system. In nearly all cases, you should be able to include your code in a single, standard framework bundle. Alternatively,if your code was sufficiently modular, you could create multiple frameworks, but in that case, the dependencies between modules would be minimal or nonexistent and should not warrant the creation of an umbrella for them
#Sets the target folders and the final framework product.
FRAMEWORK_NAME=LibraryName
FRAMEWORK_VERSION=1.0
FRAMEWORK_CONFIG=Release
#Install dir will be the final output to the framework.#The following line create it in the root folder of the current project.
INSTALL_PATH=${PROJECT_DIR}/Products/
INSTALL_DIR=${INSTALL_PATH}/${FRAMEWORK_NAME}.framework
#Working dir will be deleted after the framework creation.
WORK_DIR=build
DEVICE_DIR=${WORK_DIR}/${FRAMEWORK_CONFIG}-iphoneos/${FRAMEWORK_NAME}.framework
SIMULATOR_DIR=${WORK_DIR}/${FRAMEWORK_CONFIG}-iphonesimulator/${FRAMEWORK_NAME}.framework
xcodebuild -configuration "${FRAMEWORK_CONFIG}"-target "${FRAMEWORK_NAME}"-sdk iphoneos
echo "Build simulator"
xcodebuild -configuration "${FRAMEWORK_CONFIG}"-target "${FRAMEWORK_NAME}"-sdk iphonesimulator
#Creates install directory if it not exits.if[!-d "${INSTALL_DIR}"]
then
mkdir -p "${INSTALL_DIR}"
fi
#Creates headers directory if it not exits.if[!-d "${INSTALL_DIR}/Headers"]
then
mkdir -p "${INSTALL_DIR}/Headers"
fi
#Remove all files in the headers diectory.for file in `ls "${INSTALL_DIR}/Headers"`
do
rm "${INSTALL_DIR}/Headers/${file}"
done
#Remove binary library file.
rm -f ${INSTALL_DIR}/${FRAMEWORK_NAME}#Copies the headers files to the final product folder.if[-d "${DEVICE_DIR}/Headers"]
then
for file in `ls "${DEVICE_DIR}/Headers"`
do
cp "${DEVICE_DIR}/Headers/${file}""${INSTALL_DIR}/Headers/${file}"
done
fi
#copynibs to bundle,then copy bundle to final folder
BUNDLE_DIR=${DEVICE_DIR}/${FRAMEWORK_NAME}.bundle
if[-d "${BUNDLE_DIR}"];then
if ls ${DEVICE_DIR}/*.nib >/dev/null 2>&1;then
rm -rf ${BUNDLE_DIR}/*.nib
cp -rf ${DEVICE_DIR}/*.nib ${BUNDLE_DIR}
fi
rm -rf "${INSTALL_DIR}/${FRAMEWORK_NAME}.bundle"
cp -R "${BUNDLE_DIR}" "${INSTALL_DIR}/${FRAMEWORK_NAME}.bundle"
fi
echo "Merge with simulator"
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FRAMEWORK_NAME}" "${SIMULATOR_DIR}/${FRAMEWORK_NAME}" -output "${INSTALL_DIR}/${FRAMEWORK_NAME}"
open "${INSTALL_PATH}"
# rm -r "${WORK_DIR}"
Umbrella frameworks add minor refinements to the standard framework structure, such as the ability to encompass other frameworks
The structure of an umbrella framework is similar to that of a standard framework, and applications do not distinguish between umbrella frameworks and standard frameworks when linking to them. However, two factors distinguish umbrella frameworks from other frameworks. The first is the manner in which they include header files. The second is the fact that they encapsulate subframeworks.
Physically, umbrella frameworks have a similar structure to standard frameworks. One significant difference is the addition of a Frameworks directory to contain the subframeworks that make up the umbrella framework.
For most frameworks, you can include header files other than the master header file. You can include any specific header file you want as long as it is available in the framework’s Headers directory. However, if you are including an umbrella framework, you must include the master header file. Umbrella frameworks do not allow you to include the headers of their constituent subframeworks directly. See Restrictions on Subframework Linking for more information.