AutorÃa | Ultima modificación | Ver Log |
#!/bin/shset -eset -uset -o pipefailfunction on_error {echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"}trap 'on_error $LINENO' ERR# This protects against multiple targets copying the same framework dependency at the same time. The solution# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.htmlRSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")copy_dir(){local source="$1"local destination="$2"# Use filter instead of exclude so missing patterns don't throw errors.echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" \"${source}*\" \"${destination}\""rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}"/* "${destination}"}SELECT_SLICE_RETVAL=""select_slice() {local paths=("$@")# Locate the correct slice of the .xcframework for the current architectureslocal target_path=""# Split archs on space so we can find a slice that has all the needed archslocal target_archs=$(echo $ARCHS | tr " " "\n")local target_variant=""if [[ "$PLATFORM_NAME" == *"simulator" ]]; thentarget_variant="simulator"fiif [[ ! -z ${EFFECTIVE_PLATFORM_NAME+x} && "$EFFECTIVE_PLATFORM_NAME" == *"maccatalyst" ]]; thentarget_variant="maccatalyst"fifor i in ${!paths[@]}; dolocal matched_all_archs="1"for target_arch in $target_archsdoif ! [[ "${paths[$i]}" == *"$target_variant"* ]]; thenmatched_all_archs="0"breakfi# Verifies that the path contains the variant string (simulator or maccatalyst) if the variant is set.if [[ -z "$target_variant" && ("${paths[$i]}" == *"simulator"* || "${paths[$i]}" == *"maccatalyst"*) ]]; thenmatched_all_archs="0"breakfi# This regex matches all possible variants of the arch in the folder name:# Let's say the folder name is: ios-armv7_armv7s_arm64_arm64e/CoconutLib.framework# We match the following: -armv7_, _armv7s_, _arm64_ and _arm64e/.# If we have a specific variant: ios-i386_x86_64-simulator/CoconutLib.framework# We match the following: -i386_ and _x86_64-# When the .xcframework wraps a static library, the folder name does not include# any .framework. In that case, the folder name can be: ios-arm64_armv7# We also match _armv7$ to handle that case.local target_arch_regex="[_\-]${target_arch}([\/_\-]|$)"if ! [[ "${paths[$i]}" =~ $target_arch_regex ]]; thenmatched_all_archs="0"breakfidoneif [[ "$matched_all_archs" == "1" ]]; then# Found a matching sliceecho "Selected xcframework slice ${paths[$i]}"SELECT_SLICE_RETVAL=${paths[$i]}breakfidone}install_xcframework() {local basepath="$1"local name="$2"local package_type="$3"local paths=("${@:4}")# Locate the correct slice of the .xcframework for the current architecturesselect_slice "${paths[@]}"local target_path="$SELECT_SLICE_RETVAL"if [[ -z "$target_path" ]]; thenecho "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."returnfilocal source="$basepath/$target_path"local destination="${PODS_XCFRAMEWORKS_BUILD_DIR}/${name}"if [ ! -d "$destination" ]; thenmkdir -p "$destination"ficopy_dir "$source/" "$destination"echo "Copied $source to $destination"}install_xcframework "${PODS_ROOT}/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework" "FirebaseAnalytics/AdIdSupport" "framework" "ios-arm64_i386_x86_64-simulator" "ios-arm64_armv7" "ios-arm64_x86_64-maccatalyst"