Creating Universal Fat Framework lipo: can't create temporary output file
Asked Answered
Z

1

6

On creating Fat framework from aggregate target, I am following the build phase script from this gist link with minor changes on my script link.

On target build, Xcode is showing fetal error: lipo: can't create temporary output file: /${PROJECT_NAME}.framework/${PROJECT_NAME}.lipo (No such file or directory)

See image below for reference

build error

Updated the final working Script

Zosema answered 13/2, 2018 at 12:57 Comment(0)
T
10

Follow below steps:

  1. Quit Xcode.
  2. Delete derived data folder.
  3. Open Xcode and clean.
  4. Build again.

Simply copying below script in Run Script, your workspace returns fat binary for me.

#!/bin/sh

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"

# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"

# Step 3. Copy Swift modules (from iphonesimulator build) to the copied framework directory
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/." "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"

# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"

# Step 5. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"

# Step 6. Convenience step to open the project's directory in Finder
open "${PROJECT_DIR}"

This worked for me so far.

Thirza answered 14/2, 2018 at 4:5 Comment(5)
trying to build aggregate target from git framework project github.com/kaushlendrapal/SwiftyLayouts, getting same error.Zosema
Thanks! only removing swift module if condition working fine. How could i confirm that steps 3 passed.Zosema
THANK YOU!!!!!! AFTER HOURS OF HAIR PULLING ITS YOU WHO SAVED MY NIGHT!Frawley
Did you try it in xcode 10.2 ? This builds for forever.Townsfolk
Same issue here, it doesn't finish building at x-1 of x tasks :(Virgule

© 2022 - 2024 — McMap. All rights reserved.