Skip to content

Instantly share code, notes, and snippets.

@minsOne
Created April 4, 2022 04:54
Show Gist options
  • Select an option

  • Save minsOne/59e722b77d49ca74ea6cba8e620a7420 to your computer and use it in GitHub Desktop.

Select an option

Save minsOne/59e722b77d49ca74ea6cba8e620a7420 to your computer and use it in GitHub Desktop.
Shell Function
#!/bin/bash
BUILD_DIRECTORY="Build"
function archive_project() {
project_name=$1
framework_name=$2
# Archive iOS project.
xcodebuild archive\
-project "../$project_name.xcodeproj"\
-scheme "$framework_name"\
-configuration "Release"\
-destination "generic/platform=iOS"\
-archivePath "$framework_name.framework-iphoneos.xcarchive"\
SKIP_INSTALL=NO\
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
# Archive iOS Simulator project.
xcodebuild archive\
-project "../$project_name.xcodeproj"\
-scheme "$framework_name"\
-configuration "Simulator Release"\
-destination "generic/platform=iOS Simulator"\
-archivePath "$framework_name.framework-iphonesimulator.xcarchive"\
SKIP_INSTALL=NO\
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
function create_xcframework() {
project_name=$1
framework_name=$2
# Archive Xcode project.
archive_project $project_name $framework_name
# Create XCFramework from the archived project.
xcodebuild -create-xcframework\
-framework "$framework_name.framework-iphoneos.xcarchive/Products/Library/Frameworks/$framework_name.framework"\
-framework "$framework_name.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/$framework_name.framework"\
-output "$framework_name.xcframework"
}
function cleanup() {
rm -r *.xcarchive
}
# Create Build directory if not existing.
if [ ! -d "$BUILD_DIRECTORY" ]; then
mkdir $BUILD_DIRECTORY
fi
cd $BUILD_DIRECTORY
create_xcframework "GoogleMaps" "GoogleMaps"
create_xcframework "GoogleMaps" "GoogleMapsBase"
create_xcframework "GoogleMaps" "GoogleMapsCore"
create_xcframework "GoogleMaps" "GoogleMapsM4B"
create_xcframework "GoogleMaps" "GooglePlaces"
cleanup
echo $'\n** XCFRAMEWORK CREATION FINISHED **\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment