Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Universal Objective-C framework, LIPO can't map input file

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

like image 416
David Homes Avatar asked Jul 30 '18 18:07

David Homes


1 Answers

You can't lipo the framework, you need to lipo the inside, should be "MyUniversalFramework.framework/MyUniversalFramework"

like image 79
SeikoTheWiz Avatar answered Nov 08 '22 11:11

SeikoTheWiz