过去一整天都在研究此事,但没有成功,希望有人能对此提供一些指导。
我继承了一个旧的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代码,任何帮助/指针将不胜感激
答案 0 :(得分:1)
您不能对框架进行脂质处理,需要对内部进行脂质处理,应为“ MyUniversalFramework.framework / MyUniversalFramework”