过去一天一直在研究这个问题,但没有成功,希望有人可以提供一些指示。
我继承了一个旧的 objC 静态库项目,我正在尝试将其转换为动态的通用框架。
为框架创建了一个新目标,编译没有问题(经过一些构建设置调整)创建了一个新聚合,添加了一个运行脚本阶段:
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=true
FRAMEWORK_NAME="MyUniversalFramework"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
######################
# Build Frameworks
######################
xcodebuild -project ${FRAMEWORK_NAME}.xcodeproj -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -project ${FRAMEWORK_NAME}.xcodeproj -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
######################
# Create directory for universal
######################
rm -rf "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
######################
# Copy files Framework
######################
cp -R "${SIMULATOR_LIBRARY_PATH}" "${FRAMEWORK}"
cp -R "${DEVICE_LIBRARY_PATH}" "${FRAMEWORK}"
######################
# Make an universal binary
######################
lipo -create "${SIMULATOR_LIBRARY_PATH}" "${DEVICE_LIBRARY_PATH}" -output "${FRAMEWORK}" | echo
######################
# On Release, copy the result to release directory
######################
OUTPUT_DIR="${PROJECT_DIR}/Output/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"
cp -r "${FRAMEWORK}" "$OUTPUT_DIR"
if [ ${REVEAL_ARCHIVE_IN_FINDER} = true ]; then
open "${OUTPUT_DIR}/"
fi
当我尝试生成框架时,出现错误:
Showing Recent Messages
fatal error: lipo: can't map input file: /Users/dhomes/Library/Developer/Xcode/DerivedData/MyUniversalFramework-dzrstgkuullfwqdlupoeqbqzapxz/Build/Products/Debug-iphonesimulator/MyUniversalFramework.framework (Invalid argument)
.framework 已创建,并将其导入客户端项目允许为设备编译,但模拟器抛出“未找到框架错误”
我过去做过这些框架,但只有 w/swift 代码,任何帮助/指针将不胜感激