106 lines
2.9 KiB
Bash
Executable File
106 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
ROOT=$(pwd)
|
|
|
|
#Create xcframework from fat framework for simply using in application
|
|
# $1 - directory where fat framework placed
|
|
# $2 - binary name
|
|
create_xcframework() {
|
|
|
|
local path=$1
|
|
local binary=$2
|
|
local framework=$path/$binary.framework
|
|
local xcframework=$path/$binary.xcframework
|
|
local origin=$path/$binary.origin
|
|
|
|
local framework_bak=$framework-bak
|
|
cp -r $framework $framework_bak
|
|
|
|
# Extract binary from framework and create template
|
|
cp $framework/$binary $origin
|
|
rm $framework/$binary
|
|
rm -rf $framework/Modules/$binary.swiftmodule
|
|
|
|
# Extract each architecture for Simulation and Device
|
|
local arch=i386
|
|
local simulator="$origin-simulator"
|
|
if $(lipo "$origin" -verify_arch "$arch") ; then
|
|
lipo -extract "$arch" "$origin" -o "$simulator"
|
|
lipo -output "$origin" -remove "$arch" "$origin"
|
|
fi
|
|
|
|
arch=x86_64
|
|
if $(lipo "$origin" -verify_arch "$arch") ; then
|
|
if test -f "$simulator"; then
|
|
lipo -extract "$arch" "$origin" -o "$origin-$arch"
|
|
lipo -create "$simulator" "$origin-$arch" -o "$simulator"
|
|
rm "$origin-$arch"
|
|
else
|
|
lipo -extract "$arch" "$origin" -o "$simulator"
|
|
fi
|
|
|
|
lipo -output "$origin" -remove "$arch" "$origin"
|
|
fi
|
|
|
|
local moduleDir=""
|
|
# Create new frameworks for Device
|
|
local fdevicePath=$path/device
|
|
local fdevice=$fdevicePath/$binary.framework
|
|
mkdir -p $fdevicePath
|
|
cp -r $framework $fdevice
|
|
cp $origin $fdevice/$binary
|
|
rm $origin
|
|
|
|
moduleDir=$fdevice/Modules/$binary.swiftmodule
|
|
if test -d "$moduleDir"; then
|
|
echo "REMOVE"
|
|
rm $moduleDir/i386-apple-ios-simulator.swiftdoc \
|
|
$moduleDir/i386-apple-ios-simulator.swiftmodule \
|
|
$moduleDir/i386.swiftdoc \
|
|
$moduleDir/i386.swiftmodule \
|
|
$moduleDir/x86_64-apple-ios-simulator.swiftdoc \
|
|
$moduleDir/x86_64-apple-ios-simulator.swiftmodule \
|
|
$moduleDir/x86_64.swiftdoc \
|
|
$moduleDir/x86_64.swiftmodule \
|
|
2> /dev/null
|
|
fi
|
|
|
|
# Create new frameworks for Simulation
|
|
local fsimulatorPath=$path/simulator
|
|
local fsimulator=$fsimulatorPath/$binary.framework
|
|
mkdir -p $path/simulator/
|
|
cp -r $framework $fsimulator
|
|
cp $simulator $fsimulator/$binary
|
|
rm $simulator
|
|
|
|
moduleDir=$fsimulator/Modules/$binary.swiftmodule
|
|
if test -d "$moduleDir"; then
|
|
echo "REMOVE"
|
|
rm $moduleDir/arm64-apple-ios.swiftdoc \
|
|
$moduleDir/arm64-apple-ios.swiftmodule \
|
|
$moduleDir/arm64.swiftdoc \
|
|
$moduleDir/arm64.swiftmodule \
|
|
$moduleDir/armv7-apple-ios.swiftdoc \
|
|
$moduleDir/armv7-apple-ios.swiftmodule \
|
|
$moduleDir/armv7.swiftdoc \
|
|
$moduleDir/armv7.swiftmodule \
|
|
2> /dev/null
|
|
fi
|
|
|
|
# Create xcframework to passed path
|
|
xcodebuild -create-xcframework \
|
|
-framework "$fdevice" \
|
|
-framework "$fsimulator" \
|
|
-output "$xcframework"
|
|
|
|
# Remove temporary frameworks
|
|
rm -rf $fsimulatorPath
|
|
rm -rf $fdevicePath
|
|
rm -rf $framework
|
|
mv $framework_bak $framework
|
|
}
|
|
|
|
create_xcframework ./Vendors/Realm/iOS RealmSwift
|
|
create_xcframework ./Vendors/Realm/iOS Realm
|
|
create_xcframework ./Vendors/Sentry/iOS Sentry
|
|
create_xcframework ./Vendors/openssl openssl |