Facing lipo error when creating one bold file

I am trying to create one .a file that will contain 3 different .a files so that I can use only one .a file. This is the command I use

lipo -create -output ./libOutput.a ./libInput1.lib ./libInput2.lib ./libInput3.lib 

but I get this lipo error:

./libInput1.lib and. / libInput 2.lib have the same architecture (i386) and cannot be in the same fat output file

Any idea how to get rid of this?

+6
source share
5 answers

I just had the same error message, and this was due to the fact that I had my architecture set to "different" and typed in arm6. To fix the problem, I just changed the setting of my architecture to one of the default values, in my case I chose Standard (arm6 arm7). Architecture parameters can be found in the project build settings.

+4
source

The workaround that worked for me (because I couldn’t understand which part of the building process created an additional architecture goal for compilation): just remove the architecture from one of the two .a libraries.

First, you can list the architecture with a simple file command:

 $ file libwhatever.a libwhatever.a: Mach-O universal binary with 4 architectures libwhatever.a (for architecture armv7): current ar archive random library libwhatever.a (for architecture armv7s): current ar archive random library libwhatever.a (for architecture arm64): current ar archive random library libwhatever.a (for architecture i386): current ar archive random library $ file libfoo.a libfoo.a: Mach-O universal binary with 2 architectures libfoo.a (for architecture i386): current ar archive random library libfoo.a (for architecture x86_64): current ar archive random library 

Then this workaround is simply to remove the i386 arch from the first libwhatever.a (which in any case should have been only for arch * in my case).

 lipo -remove i386 libwhatever.a -output /tmp/libwhatever.a mv /tmp/libwhatever.a libwhatever.a 

and then you can create / merge .a files without warning.

+3
source

So this is the second time I have been here. The answer did not fix my problem. I found that this is actually a bug in Xcode. What happened at the same time is that I came and found this answer, and this is not my problem, and then I spend hours trying to figure out what is happening and the next thing I know about Xcode crashes. Open Xcode again and the magic, the problem is gone.

So, I am adding my answer to help me remember this next time.

+2
source

Ok, I started to work. Here is my (whole) version of the run script

 # Taken from Ray Wenderlich tutorial: http://www.raywenderlich.com/65964/create-a-framework-for-ios set -e # If we're already inside this script then die if [ -n "$RW_MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then exit 0 fi export RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1 RW_FRAMEWORK_NAME=${PROJECT_NAME} RW_INPUT_STATIC_LIB="lib${PROJECT_NAME}.a" RW_FRAMEWORK_LOCATION="${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}.framework" OUTPUT_LOCATION="${HOME}/Desktop" if [ ! -w ${OUTPUT_LOCATION} ] ; then OUTPUT_LOCATION="${XCS_OUTPUT_DIR}" ; fi if [ ! -w ${OUTPUT_LOCATION} ] ; then OUTPUT_LOCATION="/tmp" ; fi if [ ! -w ${OUTPUT_LOCATION} ] ; then echo "Couldn't find anywhere to write! Dying."; exit 1 ; fi function build_static_library { # Will rebuild the static library as specified # build_static_library sdk xcrun xcodebuild -project "${PROJECT_FILE_PATH}" \ -target "${TARGET_NAME}" \ -configuration "${CONFIGURATION}" \ -sdk "${1}" \ ONLY_ACTIVE_ARCH=NO \ BUILD_DIR="${BUILD_DIR}" \ OBJROOT="${OBJROOT}" \ BUILD_ROOT="${BUILD_ROOT}" \ SYMROOT="${SYMROOT}" $ACTION } function make_fat_library { # Will smash 2 static libs together # make_fat_library in1 in2 out xcrun lipo -create "${1}" "${2}" -output "${3}" } # 1 - Extract the platform (iphoneos/iphonesimulator) from the SDK name if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]; then RW_SDK_PLATFORM=${BASH_REMATCH[1]} else echo "Could not find platform name from SDK_NAME: $SDK_NAME" exit 1 fi echo "RW_SDK_PLATFORM is ${RW_SDK_PLATFORM}" # 2 - Extract the version from the SDK if [[ "$SDK_NAME" =~ ([0-9]+.*$) ]]; then RW_SDK_VERSION=${BASH_REMATCH[1]} else echo "Could not find sdk version from SDK_NAME: $SDK_NAME" exit 1 fi echo "RW_SDK_VERSION is ${RW_SDK_VERSION}" # 3 - Determine the other platform if [ "$RW_SDK_PLATFORM" == "iphoneos" ]; then RW_OTHER_PLATFORM=iphonesimulator else RW_OTHER_PLATFORM=iphoneos fi echo "RW_OTHER_PLATFORM is ${RW_OTHER_PLATFORM}" # 4 - Find the build directory if [[ "$BUILT_PRODUCTS_DIR" =~ (.*)$RW_SDK_PLATFORM$ ]]; then RW_OTHER_BUILT_PRODUCTS_DIR="${BASH_REMATCH[1]}${RW_OTHER_PLATFORM}" else echo "Could not find other platform build directory." exit 1 fi echo "BUILT_PRODUCTS_DIR is ${BUILT_PRODUCTS_DIR}" echo "RW_OTHER_BUILT_PRODUCTS_DIR is ${RW_OTHER_BUILT_PRODUCTS_DIR}" # remove alias and copy, if it archive UNINSTALLED_PRODUCTS_DIRECTORY="${BUILT_PRODUCTS_DIR}/../../IntermediateBuildFilesPath/UninstalledProducts" if [ -d "$UNINSTALLED_PRODUCTS_DIRECTORY" ]; then echo "Looks like we're archiving, fixing aliases..." rm "${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" cp "${UNINSTALLED_PRODUCTS_DIRECTORY}/${RW_INPUT_STATIC_LIB}" "${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" fi # Build the other platform. build_static_library "${RW_OTHER_PLATFORM}${RW_SDK_VERSION}" if [ -d "$UNINSTALLED_PRODUCTS_DIRECTORY" ]; then echo "Looks like we're archiving, fixing aliases..." rm "${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" cp "${UNINSTALLED_PRODUCTS_DIRECTORY}/${RW_INPUT_STATIC_LIB}" "${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" fi # If we're currently building for iphonesimulator, then need to rebuild # to ensure that we get both i386 and x86_64 if [ "$RW_SDK_PLATFORM" == "iphonesimulator" ]; then build_static_library "${SDK_NAME}" fi # Join the 2 static libs into 1 and push into the .framework make_fat_library "${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \ "${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}" \ "${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}" # Ensure that the framework is present in both platform build directories cp -a "${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}" \ "${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}.framework/Versions/A/${RW_FRAMEWORK_NAME}" # Copy the framework ditto "${RW_FRAMEWORK_LOCATION}" "${OUTPUT_LOCATION}/${RW_FRAMEWORK_NAME}.framework" # Copy the resources bundle ditto "${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}.bundle" \ "${OUTPUT_LOCATION}/${RW_FRAMEWORK_NAME}.bundle" echo "DONE. ***** FINAL FRAMEWORK AND BUNDLE WERE COPIED HERE: ${OUTPUT_LOCATION} *****" 
+2
source

Go to YourLibUniversal / Build Phases / Run script landing page

Then look if the script mentions SIMULATOR_DIR_32 and SIMULATOR_DIR_64. If so, delete the link theses and just set one SIMULATOR_DIR link

I have had:

 SIMULATOR_DIR_32=${SYMROOT}/${CONFIGURATION}-iphonesimulator-i386 SIMULATOR_DIR_64=${SYMROOT}/${CONFIGURATION}-iphonesimulator-x86_64 ... lipo -create "${DEVICE_DIR}/lib${LIB_NAME}.a" "${SIMULATOR_DIR_32}/lib${LIB_NAME}.a" "${SIMULATOR_DIR_64}/lib${LIB_NAME}.a" -output "${INSTALL_DIR}/lib${LIB_NAME}Universal.a" 

I changed it to this:

 SIMULATOR_DIR=${SYMROOT}/${CONFIGURATION}-iphonesimulator-x86_64 ... lipo -create "${DEVICE_DIR}/lib${LIB_NAME}.a" "${SIMULATOR_DIR}/lib${LIB_NAME}.a" -output "${INSTALL_DIR}/lib${LIB_NAME}Universal.a" 
0
source

Source: https://habr.com/ru/post/886849/


All Articles