Skip to content

Commit

Permalink
Prepare for eventual extension with tvOS and watchOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
tladesignz committed Oct 31, 2024
1 parent 6b590fa commit 88d8ec9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Pre-compiled libcurl framework for iOS and macOS applications! Automatically updated within 24-hours of a new release of curl.

Let me know if you need tvOS and/or watchOS too.
This project is prepared to provide these, but there's no point to waste space and time if nobody needs it.

## Using the pre-compiled framework

1. Download and extract curl.xcframework.zip from the latest release
Expand Down
79 changes: 58 additions & 21 deletions build-apple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ build() {
SDK=$3
SDKDIR=$(xcrun --sdk ${SDK} --show-sdk-path)
LOG="../${ARCH}-${SDK}_build.log"
echo "Building libcurl for ${ARCH}-${SDK}..."
echo "Building libcurl for ${ARCH}-${SDK}"

WORKDIR=curl_${ARCH}-${SDK}
mkdir "${WORKDIR}"
tar -xzf "../${ARCHIVE}" -C "${WORKDIR}" --strip-components 1
cd "${WORKDIR}"

for FILE in $(find ../../patches -name '*.patch' 2>/dev/null); do
patch -p1 < ${FILE}
patch -p1 < "${FILE}"
done

export CC=$(xcrun -find -sdk ${SDK} gcc)
Expand Down Expand Up @@ -77,36 +77,73 @@ build arm64 arm iphonesimulator
build x86_64 x86_64 iphonesimulator
build arm64 arm macosx
build x86_64 x86_64 macosx
#build arm64 arm appletvos
#build arm64 arm appletvsimulator
#build x86_64 x86_64 appletvsimulator
#build arm64 arm watchos
#build arm64 arm watchsimulator
#build x86_64 x86_64 watchsimulator

cd ../

###########
# PACKAGE #
###########

lipo \
-arch arm64 ${BUILDDIR}/curl_arm64-iphonesimulator/artifacts/lib/libcurl.a \
-arch x86_64 ${BUILDDIR}/curl_x86_64-iphonesimulator/artifacts/lib/libcurl.a \
-create -output ${BUILDDIR}/libcurl.iphonesimulator.a

lipo \
-arch arm64 ${BUILDDIR}/curl_arm64-macosx/artifacts/lib/libcurl.a \
-arch x86_64 ${BUILDDIR}/curl_x86_64-macosx/artifacts/lib/libcurl.a \
-create -output ${BUILDDIR}/libcurl.macosx.a

rm -rf ${BUILDDIR}/iphoneos/curl.framework ${BUILDDIR}/iphonesimulator/curl.framework ${BUILDDIR}/macosx/curl.framework
mkdir -p ${BUILDDIR}/iphoneos/curl.framework/Headers ${BUILDDIR}/iphonesimulator/curl.framework/Headers ${BUILDDIR}/macosx/curl.framework/Headers
libtool -no_warning_for_no_symbols -static -o ${BUILDDIR}/iphoneos/curl.framework/curl ${BUILDDIR}/curl_arm64-iphoneos/artifacts/lib/libcurl.a
cp -r ${BUILDDIR}/curl_arm64-iphoneos/artifacts/include/curl/*.h ${BUILDDIR}/iphoneos/curl.framework/Headers
libtool -no_warning_for_no_symbols -static -o ${BUILDDIR}/iphonesimulator/curl.framework/curl ${BUILDDIR}/libcurl.iphonesimulator.a
cp -r ${BUILDDIR}/curl_arm64-iphonesimulator/artifacts/include/curl/*.h ${BUILDDIR}/iphonesimulator/curl.framework/Headers
libtool -no_warning_for_no_symbols -static -o ${BUILDDIR}/macosx/curl.framework/curl ${BUILDDIR}/libcurl.macosx.a
cp -r ${BUILDDIR}/curl_arm64-macosx/artifacts/include/curl/*.h ${BUILDDIR}/macosx/curl.framework/Headers
fatten() {
SDK=$1

echo "Fatten ${SDK}"

lipo \
-arch arm64 "${BUILDDIR}/curl_arm64-${SDK}/artifacts/lib/libcurl.a" \
-arch x86_64 "${BUILDDIR}/curl_x86_64-${SDK}/artifacts/lib/libcurl.a" \
-create -output "${BUILDDIR}/libcurl.${SDK}.a"
}

fatten iphonesimulator
fatten macosx
#fatten appletvsimulator
#fatten watchsimulator

createlib() {
SDK=$1
IS_FAT=$2

rm -rf "${BUILDDIR:?}/${SDK}"
mkdir -p "${BUILDDIR}/${SDK}/curl.framework/Headers"

if [ -z "${IS_FAT}" ]; then
echo "Create lib for ${SDK}"

libtool -no_warning_for_no_symbols -static -o "${BUILDDIR}/${SDK}/curl.framework/curl" "${BUILDDIR}/curl_arm64-${SDK}/artifacts/lib/libcurl.a"
else
echo "Create lib for fat ${SDK}"

libtool -no_warning_for_no_symbols -static -o "${BUILDDIR}/${SDK}/curl.framework/curl" "${BUILDDIR}/libcurl.${SDK}.a"
fi

cp -r "${BUILDDIR}/curl_arm64-${SDK}/artifacts/include/curl"/*.h "${BUILDDIR}/${SDK}/curl.framework/Headers"
}

createlib iphoneos
createlib iphonesimulator fat
createlib macosx fat
#createlib appletvos
#createlib appletvsimulator fat
#createlib watchos
#createlib watchsimulator fat

rm -rf curl.xcframework
xcodebuild -create-xcframework \
-framework ${BUILDDIR}/iphoneos/curl.framework \
-framework ${BUILDDIR}/iphonesimulator/curl.framework \
-framework ${BUILDDIR}/macosx/curl.framework \
-output curl.xcframework
plutil -insert CFBundleVersion -string ${VERSION} curl.xcframework/Info.plist

# -framework ${BUILDDIR}/appletvos/curl.framework \
# -framework ${BUILDDIR}/appletvsimulator/curl.framework \
# -framework ${BUILDDIR}/watchos/curl.framework \
# -framework ${BUILDDIR}/watchsimulator/curl.framework \

plutil -insert CFBundleVersion -string "${VERSION}" curl.xcframework/Info.plist

0 comments on commit 88d8ec9

Please sign in to comment.