一、選擇 Cocoa Touch Frameworkcanvas
二、添加靜態庫的代碼,讓編譯的 .m文件出如今Compile Sources , 須要暴露的頭文件 出現在 Public,若是沒有,把它拖移或新增到下圖這樣:xcode
三、以後再真機和模擬器的中Scheme 下,分別 Build 靜態庫: bash
四、在 Build 的時候,SDK 就默默產生了: iphone
在 Products 的 .framework 選中後show in finder就能夠看到 Debug-iphoneos 以及 Debug-iphonesimulator。ui
1. 在 xcode 中新建 Aggregate Target: spa
2. 添加 Run Script:3d
3. Script 中輸入以下內容: code
#這個是聲明生成的framework的名字,有些和工程名字同樣,看你建立時候怎麼寫orm
#FMK_NAME是個變量cdn
FMK_NAME="ParaseKit"
if [ "${ACTION}" = "build" ]
then
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${FMK_NAME}.framework
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
#ditto "${DEVICE_DIR}/Headers" "${INSTALL_DIR}/Headers"
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"
#這個是合併完成後打開對應的文件夾,你就能夠直接看到文件了
open "${SRCROOT}/Products"
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
# copy nibs 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}"
rm -r "${WORK_DIR}"
open "${INSTALL_DIR}"
https://www.jianshu.com/p/5c2c154cafae