Been researching this for the past day without success, hopefully someone can provide a few pointers on this.
I have inherited an old objC static library project which I'm trying to convert to a dynamic, universal framework.
Created a new target for the framework, compiles w/o issue (after a few build setting tweaks) Created a new aggregate, added a Run Script Phase:
######################
# 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
When I try to produce the framework I get the error:
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)
The .framework IS created, and importing it into a client project allows to compile for device, but simulator throws "Framework not found error"
I have done these frameworks in the past but only w/swift code, Any help/pointers would be appreciated
You can't lipo the framework, you need to lipo the inside, should be "MyUniversalFramework.framework/MyUniversalFramework"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With