diff --git a/.github/workflows/build_xcframework.yml b/.github/workflows/build_xcframework.yml index 92c7da2..1c99a5a 100644 --- a/.github/workflows/build_xcframework.yml +++ b/.github/workflows/build_xcframework.yml @@ -86,29 +86,26 @@ jobs: - name: Create fat libraries using lipo run: | mkdir -p "${OUTPUT_DIR}/fat" - # For macOS - lipo -create \ - "${OUTPUT_DIR}/build-macosx-arm64/macosx-arm64-MacOSX/lib/libopencore-amrnb.a" \ - "${OUTPUT_DIR}/build-macosx-x86_64/macosx-x86_64-MacOSX/lib/libopencore-amrnb.a" \ - -output "${OUTPUT_DIR}/fat/libopencore-amrnb-macos.a" - lipo -create \ - "${OUTPUT_DIR}/build-macosx-arm64/macosx-arm64-MacOSX/lib/libopencore-amrwb.a" \ - "${OUTPUT_DIR}/build-macosx-x86_64/macosx-x86_64-MacOSX/lib/libopencore-amrwb.a" \ - -output "${OUTPUT_DIR}/fat/libopencore-amrwb-macos.a" - - # For iOS device - cp "${OUTPUT_DIR}/build-iphoneos-arm64/iphoneos-arm64-iPhoneOS/lib/libopencore-amrnb.a" "${OUTPUT_DIR}/fat/libopencore-amrnb-iphoneos.a" - cp "${OUTPUT_DIR}/build-iphoneos-arm64/iphoneos-arm64-iPhoneOS/lib/libopencore-amrwb.a" "${OUTPUT_DIR}/fat/libopencore-amrwb-iphoneos.a" - - # For iOS simulator - lipo -create \ - "${OUTPUT_DIR}/build-iphonesimulator-x86_64/iphonesimulator-x86_64-iPhoneSimulator/lib/libopencore-amrnb.a" \ - "${OUTPUT_DIR}/build-iphonesimulator-arm64/iphonesimulator-arm64-iPhoneSimulator/lib/libopencore-amrnb.a" \ - -output "${OUTPUT_DIR}/fat/libopencore-amrnb-iphonesimulator.a" - lipo -create \ - "${OUTPUT_DIR}/build-iphonesimulator-x86_64/iphonesimulator-x86_64-iPhoneSimulator/lib/libopencore-amrwb.a" \ - "${OUTPUT_DIR}/build-iphonesimulator-arm64/iphonesimulator-arm64-iPhoneSimulator/lib/libopencore-amrwb.a" \ - -output "${OUTPUT_DIR}/fat/libopencore-amrwb-iphonesimulator.a" + declare -A ARCHITECTURES=( + ["macos"]="arm64 x86_64" + ["iphoneos"]="arm64" + ["iphonesimulator"]="x86_64 arm64" + ) + + LIBRARIES=("libopencore-amrnb" "libopencore-amrwb") + + for lib in "${LIBRARIES[@]}"; do + # For macOS + lipo -create $(for arch in ${ARCHITECTURES["macos"]}; do echo "${OUTPUT_DIR}/build-macosx-${arch}/macosx-${arch}-MacOSX/lib/${lib}.a"; done) \ + -output "${OUTPUT_DIR}/fat/${lib}-macos.a" + + # For iOS device + cp "${OUTPUT_DIR}/build-iphoneos-arm64/iphoneos-arm64-iPhoneOS/lib/${lib}.a" "${OUTPUT_DIR}/fat/${lib}-iphoneos.a" + + # For iOS simulator + lipo -create $(for arch in ${ARCHITECTURES["iphonesimulator"]}; do echo "${OUTPUT_DIR}/build-iphonesimulator-${arch}/iphonesimulator-${arch}-iPhoneSimulator/lib/${lib}.a"; done) \ + -output "${OUTPUT_DIR}/fat/${lib}-iphonesimulator.a" + done - name: Create XCFrameworks run: |