0

I have looked at few of the solutions mentioned for earlier Xcode versions :

Running 1 of 2 custom shell script stuck for 2 minutes in Xcode
XCode 8 Stuck on Running 2 of 4 Custom Shell Script
Running 1 of 1 custom shell scripts freeze

But none of them seem to work.
Script :

exec > /tmp/${PROJECT_NAME}_archive.log 2>&1


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


if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"


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


echo "Building for iPhoneSimulator"
xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone XS' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build


# Step 1. Copy the framework structure (from iphoneos build) to the universal folder
echo "Copying to output folder"
cp -R "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${FULL_PRODUCT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/"


# Step 2. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule"
fi


# Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
echo "Combining executables"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${EXECUTABLE_PATH}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${EXECUTABLE_PATH}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${EXECUTABLE_PATH}"


# Step 4. Create universal binaries for embedded frameworks
# for SUB_FRAMEWORK in $( ls "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks" ); do
# BINARY_NAME="${SUB_FRAMEWORK%.*}"
# lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SUB_FRAMEWORK}/${BINARY_NAME}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}"
# done


# Step 5. Convenience step to copy the framework to the project's directory
echo "Copying to project dir"
yes | cp -Rf "${UNIVERSAL_OUTPUTFOLDER}/${FULL_PRODUCT_NAME}" "${PROJECT_DIR}"


open "${PROJECT_DIR}"


fi
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • 1
    It looks like you are running xcodebuild from inside a build script? You definitely shouldn't ever be doing that unless it's a different project that you are building. – Dale Myers Jan 11 '19 at 12:28
  • @DaleMyers : I couldn't find any script missing xcodebuild, anywhere. – Nitish Jan 11 '19 at 14:08
  • This script is calling `xcodebuild`. From your question, and the check for a recursive call, the implication is that this script is the script that you are calling as part of your build process. i.e. When you build your project in Xcode, it is calling this script, which is calling `xcodebuild` in turn. – Dale Myers Jan 11 '19 at 20:07
  • you would typically use a script like this to export a framework. @Dale Myers. This isn't meant for normal comiling and running. That being said I have had issues with generated files in my build scripts. It seems you need to specify the Output files now. I set them relative to my ${PROJECT_DIR} and it worked – Brooks DuBois Jan 17 '19 at 19:53
  • you can also try going to File> project settings... and using the legacy compiler. I had to do this for an older obj-c framework we use. – Brooks DuBois Jan 17 '19 at 19:54

0 Answers0