8

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

3
  • Same problem now Commented Nov 20, 2018 at 18:22
  • Any solution on this ? Commented Jan 30, 2019 at 10:40
  • 1
    Hi David, you can check this tool as an alternative: github.com/gurhub/surmagic Best Commented Nov 20, 2020 at 6:17

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this comment. I want to tell @david-homes you can check this tutorial medium.com/@hassanahmedkhan/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.