# 使用 cocoapods 拉取源码,编译生成所需的.a、.h 和 资源文件并导出到指定目录 # $1 临时项目路径 # $2 .a、.h 及 资源文件导出路径 temp_proj_path=$1 export_path=$2 temp_proj_name=${temp_proj_path##*/} # cocoapods cd ${temp_proj_path} pod update --no-repo-update # 编译生成模拟器和真机的 .a 文件(Release) cd Pods xcodebuild -project "Pods.xcodeproj" -alltargets -sdk iphoneos -configuration Release TARGET_BUILD_DIR="../Products/iPhoneOS" ONLY_ACTIVE_ARCH=NO xcodebuild -project "Pods.xcodeproj" -alltargets -sdk iphonesimulator -configuration Release TARGET_BUILD_DIR="../Products/iPhoneSimulator" -arch x86_64 # 使用 lipo 指令合并模拟器和真机的 .a lib_files=`find ../Products/iPhoneOS -type f -name "*.a" | grep -v ../Products/iPhoneOS/libPods-${podsProject}` for file in ${lib_files} do lib_name=${file##*/} lipo= lipo -create ../Products/iPhoneOS/${lib_name} ../Products/iPhoneSimulator/${lib_name} -output ../Products/${lib_name} done # 合成 .a 后删除无用的目录,避免影响之后的拷贝 rm -rf ../Products/iPhoneOS rm -rf ../Products/iPhoneSimulator cd ../Products # 从 Pods 目录中拷贝出 .a find . -type f -name "*.a" | grep -v ./libPods-${temp_proj_name} | cpio -pdm ${export_path}/Libraries # 从 Pods 目录中拷贝出 Header cp -r ../Pods/Headers/Public ${export_path}/Headers