原文:http://db-in.com/blog/2011/07/universal-framework-iphone-ios-2-0/
原文废话太多啊,自己总结一下,因为我是在原有的静态库工程基础上建立的,所以新建一个target就好了。
1 新建target,macOS中的bundle:
2 接下来设置bundle的build setting:(直接复制了)
IMPORTANT: Since the Xcode 4.x the architectures armv6 has no longer support. So, to create a real Universal Framework we must make a small “hack”:
3 接下来在build phase 中添加各种资源,包括 Copy Bundle Resources,Compile Sources。要注意的是添加 Copy Headers,是区分开放和私有的。
Tip: To add many files at once, click on the “+” button and write the files’ extension on the search field. For example “.m”, “.c”, “.cpp”, “.h”, etc. This can save a lot of time. (搜索后缀,可以节省不少时间。。)
4 接下来建立target,用来生成通用的framework。
在aggregate的build phases中添加run script:
# Sets the target folders and the final framework product. FMK_NAME=FI FMK_VERSION=A # Install dir will be the final output to the framework. # The following line create it in the root folder of the current project. INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework # Working dir will be deleted after the framework creation. WRK_DIR=build DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework # Building both architectures. xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator # Cleaning the oldest. if [ -d "${INSTALL_DIR}" ] then rm -rf "${INSTALL_DIR}" fi # Creates and renews the final product folder. mkdir -p "${INSTALL_DIR}" mkdir -p "${INSTALL_DIR}/Versions" mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}" mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources" mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers" # Creates the internal links. # It MUST uses relative path, otherwise will not work when the folder is copied/moved. ln -s "${FMK_VERSION}" "${INSTALL_DIR}/Versions/Current" ln -s "Versions/Current/Headers" "${INSTALL_DIR}/Headers" ln -s "Versions/Current/Resources" "${INSTALL_DIR}/Resources" ln -s "Versions/Current/${FMK_NAME}" "${INSTALL_DIR}/${FMK_NAME}" # Copies the headers and resources files to the final product folder. cp -R "${DEVICE_DIR}/Headers/" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers/" cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/" # Removes the binary and header from the resources folder. rm -r "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/Headers" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/${FMK_NAME}" # Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product. lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}" rm -r "${WRK_DIR}"
最后,build这个aggregate的target就可以了!!!
#################################
遇到的问题:
新建的bundle找不到Apple LLVM compiler的选项了,简直就是我累个擦啊!最后在原文的评论中发现了:先编译一遍,那些选项就回出现了。。。设置好了,重新build就可以了。。