I'm working with an iOS project that produces a Framework directory at the root of the project when I execute Product -> Build For -> Running in Xcode. I need to be able to automate this process on the command line presumably using xcodebuild. However, I can't seem to determine the correct set of parameters to make this happen. Any insight into how to run this same scenario without the GUI? Do I have to look at using lipo?
This is the generic script I created. It creates a framework with combined device and simulator binaries.
#!/bin/bash
while getopts s:w: flag
do
case "${flag}" in
s) scheme=${OPTARG};;
w) workspace="-workspace ${OPTARG}.xcworkspace";;
esac
done
if [ -z "$scheme" ]
then
echo "$(basename $BASH_SOURCE) -- build XCFramework"
echo ""
echo "$(basename $BASH_SOURCE) -s scheme-name [ -w workspace0-name ]"
echo ""
echo "Run this script from the top-level directory of your framework."
echo "The build result will be here: archives/<scheme-name>.xcframework"
exit
fi
rm -rf archives/$scheme.xcframework
xcodebuild archive \
$workspace \
-scheme $scheme \
-destination "generic/platform=iOS Simulator" \
-archivePath "archives/$scheme-Simulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
$workspace \
-scheme $scheme \
-destination "generic/platform=iOS" \
-archivePath "archives/$scheme" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
cp -r archives/$scheme-Simulator.xcarchive/Products/Library/Frameworks/. archives/simulator
cp -r archives/$scheme.xcarchive/Products/Library/Frameworks/. archives/ios
function GetUUID() {
local arch=$1
local binary=$2
local dwarfdump_result=$(dwarfdump -u ${binary})
local regex="UUID: (.*) \((.*)\)"
if [[ $dwarfdump_result =~ $regex ]]; then
local result_uuid="${BASH_REMATCH[1]}"
local result_arch="${BASH_REMATCH[2]}"
if [ "$result_arch" == "$arch" ]; then
echo $result_uuid
fi
fi
}
BCSYMBOLMAP_UUID=$(GetUUID "arm64" "archives/$scheme.xcarchive/Products/Library/Frameworks/$scheme.framework/$scheme")
xcodebuild -create-xcframework \
-framework archives/ios/$scheme.framework \
-debug-symbols ${PWD}/archives/$scheme.xcarchive/dSYMs/$scheme.framework.dSYM \
-debug-symbols "${PWD}/archives/$scheme.xcarchive/BCSymbolMaps/${BCSYMBOLMAP_UUID}.bcsymbolmap" \
-framework archives/simulator/$scheme.framework \
-debug-symbols ${PWD}/archives/$scheme-Simulator.xcarchive/dSYMs/$scheme.framework.dSYM \
-output archives/$scheme.xcframework
cd archives
rm -rf $scheme-Simulator.xcarchive $scheme.xcarchive ios simulator
Related
I try create binary universal framework, with next steps
mkdir build
xcodebuild clean build \
-project Target/TestTarget.xcodeproj \
-scheme TestTarget \
-configuration Release \
-sdk iphonesimulator \
-derivedDataPath derived_data
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
mkdir build/simulator
cp -r derived_data/Build/Products/Release-iphonesimulator/TestTarget.framework build/simulator
xcodebuild clean build \
-project Target/TestTarget.xcodeproj \
-scheme TestTarget \
-configuration Release \
-sdk iphoneos \
-derivedDataPath derived_data
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
mkdir build/devices
cp -r derived_data/Build/Products/Release-iphoneos/TestTarget.framework build/devices
mkdir build/universal
cp -r build/devices/TestTarget.framework build/universal/
lipo -create \
build/simulator/TestTarget.framework/TestTarget \
build/devices/TestTarget.framework/TestTarget \
-output build/universal/TestTarget.framework/TestTarget
cp build/simulator/TestTarget.framework/Modules/TestTarget.swiftmodule/* build/universal/TestTarget.framework/Modules/TestTarget.swiftmodule
but have ERROR
..../TestTarget have the same architectures (arm64) and can't be in the same fat output file
As Apple support described here
Scripts like that -- anything that tries to manipulate the output with commands like lipo -- still produces an unsupported configuration in the binary.
And the way to go is distribute the framework as a xcframework. Here you have Apple docs how to do that.
xcodebuild -create-xcframework -framework <path> [-framework <path>...] -output <path>
xcodebuild -create-xcframework -library <path> [-headers <path>] [-library <path> [-headers <path>]...] -output <path>
I Xcode 9.x, I was using the below script which worked fine :
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=false
FRAMEWORK_NAME="${PROJECT_NAME}"
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 "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}"
ONLY_ACTIVE_ARCH=NO -configuration "${CONFIGURATION}" -sdk iphonesimulator
BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}"
CONFIGURATION_BUILD_DIR="${IPHONE_SIMULATOR_BUILD_DIR}" SYMROOT="${SYMROOT}"
ARCHS="i386 x86_64" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" $ACTION 2>&1
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}"
ONLY_ACTIVE_ARCH=NO -configuration "${CONFIGURATION}" -sdk iphoneos
BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}"
CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}" SYMROOT="${SYMROOT}"
ARCHS="armv7 armv7s arm64" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" $ACTION 2>&1
######################
# Create directory for universal
######################
rm -rf "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
######################
# Copy files Framework
######################
cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
######################
# Make an universal binary
######################
lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo
# For Swift framework, Swiftmodule needs to be copied in the universal framework
if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
fi
if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f ${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
fi
######################
# 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
This didn't for Xcode 10. Later I saw that there was some modification required in the script. So I followed this answer to set the script. But after setting this script, when I try to build the Universal framework, Xcode hangs on Building script 1 of 1.
I have been trying to look for the right solution but failing each time.
What is the correct run script for a universal framework (covering all architectures) on Xcode 10 ?
Adding -UseModernBuildSystem=NO to xcodebuild command should work.
xcodebuild -workspace ${PROJECT_NAME}.xcworkspace -scheme ${PROJECT_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} -UseModernBuildSystem=NO clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator 2>&1
xcodebuild -workspace ${PROJECT_NAME}.xcworkspace -scheme ${PROJECT_NAME} -sdk iphoneos -configuration ${CONFIGURATION} -UseModernBuildSystem=NO clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos 2>&1
It should fix your problem.
This is the entire script I'm currently using and which successfully builds universal framework with Xcode 10. Link to gist
Currently, working to make use of latest build system to build universal framework. Shall update the answer soon.
echo "project"
#open "${PROJECT_DIR}"
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-iosuniversal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
echo "iphone"
xcodebuild -target "${TARGET_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
echo "iphonesim"
xcodebuild -target "${TARGET_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
echo "universal"
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
echo "iphone simulator path"
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
echo "lipo create"
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}"
echo "end"
fi
First Generate the Separate build for both simulator and device
while opening your Products folder you will Find the separate build for both
And then use this Run script in your project
After Generating the Script you Find the Folder IOS-Universal in Same product Folder
For me Working fine.
The screenshots below image
Open Terminal, navigate root directory of project and Replace YourUniversalFramework with your project Name and Scheme name(if Required), run the command after successful, It will generate universal folder inside build.
Framework from universal folder is now ready to be consumed by devices and simulators!
Note: Paste whole script on Terminal after changes and Run
Command/Script For .xcodeproj Project
mkdir build
;
xcodebuild clean build \
-project YourUniversalFramework.xcodeproj \
-scheme YourUniversalFramework \
-configuration Release \
-sdk iphoneos \
-derivedDataPath derived_data \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
;
mkdir build/devices
;
cp -r derived_data/Build/Products/Release-iphoneos/YourUniversalFramework.framework build/devices
;
xcodebuild clean build \
-project YourUniversalFramework.xcodeproj \
-scheme YourUniversalFramework \
-configuration Release \
-sdk iphonesimulator \
-derivedDataPath derived_data \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
;
mkdir build/simulator
;
cp -r derived_data/Build/Products/Release-iphonesimulator/ build/simulator/
;
mkdir build/universal
;
cp -r build/devices/YourUniversalFramework.framework build/universal/
;
lipo -create \
build/simulator/YourUniversalFramework.framework/YourUniversalFramework \
build/devices/YourUniversalFramework.framework/YourUniversalFramework \
-output build/universal/YourUniversalFramework.framework/YourUniversalFramework
;
cp -r \
build/simulator/YourUniversalFramework.framework/Modules/YourUniversalFramework.swiftmodule/* \
build/universal/YourUniversalFramework.framework/Modules/YourUniversalFramework.swiftmodule/YourUniversalFramework
Command/Script For .xcworkspace Project
mkdir build
;
xcodebuild clean build \
-workspace YourUniversalFramework.xcworkspace \
-scheme YourUniversalFramework \
-configuration Release \
-sdk iphoneos \
-derivedDataPath derived_data \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
;
mkdir build/devices
;
cp -r derived_data/Build/Products/Release-iphoneos/YourUniversalFramework.framework build/devices
;
xcodebuild clean build \
-workspace YourUniversalFramework.xcworkspace \
-scheme YourUniversalFramework \
-configuration Release \
-sdk iphonesimulator \
-derivedDataPath derived_data \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
;
mkdir build/simulator
;
cp -r derived_data/Build/Products/Release-iphonesimulator/ build/simulator/
;
mkdir build/universal
;
cp -r build/devices/YourUniversalFramework.framework build/universal/
;
lipo -create \
build/simulator/YourUniversalFramework.framework/YourUniversalFramework \
build/devices/YourUniversalFramework.framework/YourUniversalFramework \
-output build/universal/YourUniversalFramework.framework/YourUniversalFramework
;
cp -r \
build/simulator/YourUniversalFramework.framework/Modules/YourUniversalFramework.swiftmodule/* \
build/universal/YourUniversalFramework.framework/Modules/YourUniversalFramework.swiftmodule/YourUniversalFramework
I'm trying to get OCLint working with a iOS project. I've installed OCLint using Brew and it has installed correctly (I can check in terminal by running the oclint command).
I've attempted to integrate it by creating a separate target (tutorial here) and creating a new run script. When I build the new target it generates a report.html file but it has no files scanned, Total Files = 0 :/
How can I get it to scan my project? Many thanks.
My script is below:
OCLINT_HOME=/Users/johndoe/Documents/Programs/oclint-0.8.1
export PATH=$OCLINT_HOME/bin:$PATH
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
cd ${TARGET_TEMP_DIR}
if [ ! -f compile_commands.json ]; then
echo "[*] compile_commands.json not found, possibly clean was performed"
echo "[*] starting xcodebuild to rebuild the project.."
# clean previous output
if [ -f xcodebuild.log ]; then
rm xcodebuild.log
fi
cd ${SRCROOT}
xcodebuild clean
#build xcodebuild.log
xcodebuild | tee ${TARGET_TEMP_DIR}/xcodebuild.log
#xcodebuild <options>| tee ${TARGET_TEMP_DIR}/xcodebuild.log
echo "[*] transforming xcodebuild.log into compile_commands.json..."
cd ${TARGET_TEMP_DIR}
#transform it into compile_commands.json
oclint-xcodebuild
fi
echo "[*] starting analyzing"
cd ${TARGET_TEMP_DIR}
oclint-json-compilation-database -v oclint_args "-report-type html -o $OCLINT_HOME/report.html"
Try this from your terminal.
echo "Opening workspace for OCLint detection"
open -a "/Applications/Xcode.app" PATH_TO_YOUR_WORKSPACE
sleep 20
echo "Starting OCLint Check......"
rm -Rf $(pwd)/compile_commands.json
rm -Rf $(pwd)/xcodebuild.log
xcodebuild -target TARGET -configuration Release -scheme OCLint -sdk iphonesimulator
xcodebuild -sdk iphonesimulator | tee xcodebuild.log
oclint-xcodebuild xcodebuild.log
oclint-json-compilation-database -- -o=report.html
oclint-json-compilation-database -v oclint_args "-report-type html -o report.html -rc=LONG_LINE=120" open compile_commands.json open report.html
echo "Finished executing OCLint..."
echo "Closing Xcode"
killall Xcode
exit 0
Open and close Xcode only if your scheme is not getting detected.
Please try this commands your terminal. In your path directory
xcodebuild -project DemoCustomOCLint.xcodeproj -arch i386 -sdk
iphonesimulator11.0 | xcpretty -r json-compilation-database -o compile_commands.json
oclint-json-compilation-database -v -- -report-type html -o report777.html
oclint-json-compilation-database
Environment: Mac OS X 10.9.2, Xcode 5.1. Build shell scripts as below:
#!/bin/sh
set -xe
VERSION="1.3.1"
DESTDIR="libogg-built"
#ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DESTDIR
mkdir $DESTDIR
if [ ! -e "libogg-$VERSION.zip" ]; then
curl -LO http://downloads.xiph.org/releases/ogg/libogg-$VERSION.zip
fi
unzip -oq libogg-$VERSION.zip
cd libogg-$VERSION
./configure
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
IOSMV="-miphoneos-version-min=4.3"
case $ARCH in
arm*)
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
SDK=`xcodebuild -version -sdk iphoneos Path` \
CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
LDFLAGS="-Wl,-syslibroot,$SDK" \
./configure \
#--host=arm-apple-darwin \
--prefix=../$DESTDIR/$ARCH
;;
*)
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
#SDK=`xcodebuild -version -sdk iphonesimulator Path` \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
#--host=x86_64-apple-darwin \
--prefix=../$DESTDIR/$ARCH
;;
esac
make
make install
make clean
done
cd ..
mkdir -p ${DESTDIR}/universal/lib
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/libogg.a"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a
But terminal logs that:
+ VERSION=1.3.1
+ DESTDIR=libogg-built
+ ARCHS=i386
+ rm -rf libogg-built
+ mkdir libogg-built
+ '[' '!' -e libogg-1.3.1.zip ']'
+ unzip -oq libogg-1.3.1.zip
+ cd libogg-1.3.1
+ ./configure
+ for ARCH in '$ARCHS'
+ mkdir -p ../libogg-built/i386
+ IOSMV=-miphoneos-version-min=4.3
+ case $ARCH in
++ xcodebuild -version -sdk iphonesimulator PlatformPath
+ PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/opt/local/bin:/opt/local/sbin:/Users/Smeegol/.rbenv/shims:/Users/Smeegol/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
+ CC='xcrun --sdk iphonesimulator clang -arch i386 -miphoneos-version-min=4.3'
+ CXX='xcrun --sdk iphonesimulator clang++ -arch i386 -miphoneos-version-min=4.3'
+ ./configure
+ --prefix=../libogg-built/i386
./build-libogg2.sh: line 55: --prefix=../libogg-built/i386: No such file or directory
Why "--prefix=../libogg-built/i386: No such file or directory"? It already have been created.
Updated: New and correct shell script as below:
#!/bin/sh
set -xe
VERSION="1.3.1"
DESTDIR="libogg-built"
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DESTDIR
mkdir $DESTDIR
if [ ! -e "libogg-$VERSION.zip" ]; then
curl -LO http://downloads.xiph.org/releases/ogg/libogg-$VERSION.zip
fi
unzip -oq libogg-$VERSION.zip
cd libogg-$VERSION
./configure
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
IOSMV="-miphoneos-version-min=4.3"
case $ARCH in
arm*)
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
SDK=`xcodebuild -version -sdk iphoneos Path` \
CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
LDFLAGS="-Wl,-syslibroot,$SDK" \
./configure \
--host=arm-apple-darwin \
--prefix=../$DESTDIR/$ARCH
;;
*)
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=../$DESTDIR/$ARCH
;;
esac
make
make install
make clean
done
cd ..
mkdir -p $DESTDIR/universal/lib
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/libogg.a"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a
--prefix=../$DESTDIR/$ARCH
You are likely having an issue with the relative path. It's generally better (if not easier) to use the full path to your install root.
One thing you can try, if this is the issue, is to expand the path and try again ... for e.g.
export INSTALL_ROOT=$(cd ../libogg-built/i386; pwd)
./configure ...
...
--prefix="${INSTALL_ROOT}"
Let us know if that helps! Configure scripts can be very finicky.
Update: Nevermind, it's much more simpler in this case I just realized after hitting submit the first time:
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
#--host=x86_64-apple-darwin \
--prefix=../$DESTDIR/$ARCH
;;
... you cannot have an #-to-end-of-line comment when you are continuing a command onto multiple lines. Just remove #--host=x86_64-apple-darwin \ and you should be set.
You can refer to
https://github.com/firstfan/libspeex-iOS
It compiles OK with latest SDK and latest speex code
See also: Compile libogg for iOS using Xcode5.1 error
Environment: Mac OS X 10.9.2, Xcode 5.1.
There are two shell scripts to build libogg and libspeex, where locates in the same directory. The libogg build scripts is as below:
#!/bin/sh
set -xe
VERSION="1.3.1"
BUILDDIR=`pwd`
DESTDIR="libogg-built"
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DESTDIR
mkdir $DESTDIR
if [ ! -e "libogg-$VERSION.zip" ]; then
curl -LO http://downloads.xiph.org/releases/ogg/libogg-$VERSION.zip
fi
unzip -oq libogg-$VERSION.zip
cd libogg-$VERSION
./configure
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
make distclean
IOSMV="-miphoneos-version-min=4.3"
case $ARCH in
arm*)
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
SDK=`xcodebuild -version -sdk iphoneos Path` \
CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
LDFLAGS="-Wl,-syslibroot,$SDK" \
./configure \
--host=arm-apple-darwin \
--prefix=$BUILDDIR/$DESTDIR/$ARCH
;;
*)
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=$BUILDDIR/$DESTDIR/$ARCH
;;
esac
make
make install
done
make distclean
cd ..
mkdir -p $DESTDIR/universal/lib
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/libogg.a"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a
Run scripts in the terminal, and libogg was successfully compiled. Then Run the libspeex scripts as below:
#!/bin/sh
set -xe
VERSION="1.2rc1"
BUILDDIR=`pwd`
OGGDIR="libogg-built"
DESTDIR="libspeex-built"
LIBS="libspeex.a libspeexdsp.a"
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DESTDIR
mkdir $DESTDIR
if [ ! -e "speex-$VERSION.tar.gz" ]; then
curl -LO http://downloads.xiph.org/releases/speex/speex-$VERSION.tar.gz
fi
tar zxf speex-$VERSION.tar.gz
cd speex-$VERSION
./configure
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
make distclean
IOSMV="-miphoneos-version-min=4.3"
case $ARCH in
arm*)
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
SDK=`xcodebuild -version -sdk iphoneos Path` \
CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
LDFLAGS="-Wl,-syslibroot,$SDK" \
./configure \
--host=arm-apple-darwin \
--prefix=$BUILDDIR/$DESTDIR/$ARCH \
--with-ogg=$BUILDDIR/$OGGDIR/$ARCH
;;
*)
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=$BUILDDIR/$DESTDIR/$ARCH \
--with-ogg=$BUILDDIR/$OGGDIR/$ARCH
;;
esac
make
make install
done
make distclean
cd ..
mkdir -p $DESTDIR/universal/lib
for LIB in $LIBS;
do
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/$LIB"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/$LIB
done
It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!
It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!
It references /Users/Smeegol/Desktop/Speex/libogg-built/i386, and yet in the previous step ...
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a
... I see universal in the path name, for one.
Your output directory for the libogg install should look something like this:
${OGGDIR}/lib/libogg.a
${OGGDIR}/include/<include files here>
And finally, you have a similar error to your other question:
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=$BUILDDIR/$DESTDIR/$ARCH
--with-ogg=$BUILDDIR/$OGGDIR/$ARCH
... you are missing a "\" after the --prefix line.
You can refer to https://github.com/firstfan/libspeex-iOS
It compiles OK with latest SDK and latest speex code
It works out-of-box.