#!/bin/sh set -e IOS_DIR="$(pwd)/../../ios" DYLIB_PATH="$(pwd)/../../scripts/monero_c/release" TMP_DIR="${IOS_DIR}/tmp" rm -rf "${IOS_DIR:?}/MoneroWallet.xcframework" "${IOS_DIR:?}/WowneroWallet.xcframework" "${IOS_DIR:?}/ZanoWallet.xcframework" rm -rf "${IOS_DIR:?}/MoneroWallet.framework" "${IOS_DIR:?}/WowneroWallet.framework" "${IOS_DIR:?}/ZanoWallet.framework" rm -rf "$TMP_DIR" mkdir -p "$TMP_DIR" write_info_plist() { framework_bundle="$1" framework_name="$2" target="$3" plist_path="${framework_bundle}/Info.plist" if [[ "x$target" = "xiossimulator" ]]; then platform="iPhoneSimulator" dtplatformname="iphonesimulator" dtsdkname="iphonesimulator17.4" else platform="iPhoneOS" dtplatformname="iphoneos" dtsdkname="iphoneos17.4" fi cat > "$plist_path" < BuildMachineOSBuild 23E224 CFBundleDevelopmentRegion en CFBundleExecutable ${framework_name} CFBundleIdentifier com.fotolockr.${framework_name} CFBundleInfoDictionaryVersion 6.0 CFBundleName ${framework_name} CFBundlePackageType FMWK CFBundleShortVersionString 1.0 CFBundleSignature ??? CFBundleSupportedPlatforms ${platform} CFBundleVersion 1 DTCompiler com.apple.compilers.llvm.clang.1_0 DTPlatformBuild 21E210 DTPlatformName ${dtplatformname} DTPlatformVersion 17.4 DTSDKBuild 21E210 DTSDKName ${dtsdkname} DTXcode 1530 DTXcodeBuild 15E204a MinimumOSVersion 16.0 UIDeviceFamily 1 2 UIRequiredDeviceCapabilities arm64 EOF plutil -convert binary1 "$plist_path" } create_framework() { wallet="$1" framework_name="$2" target="$3" out_dir="$4" echo "Creating ${framework_name}.framework for target ${target} in ${out_dir}..." framework_bundle="${out_dir}/${framework_name}.framework" rm -rf "$framework_bundle" mkdir -p "$framework_bundle" input_dylib="${DYLIB_PATH}/${wallet}/aarch64-apple-${target}_libwallet2_api_c.dylib" if [[ ! -f "$input_dylib" ]]; then echo "Error: Input dylib not found: $input_dylib" exit 1 fi lipo -create "$input_dylib" -output "${framework_bundle}/${framework_name}" echo "Created binary: ${framework_bundle}/${framework_name}" write_info_plist "$framework_bundle" "$framework_name" "$target" } create_xcframework() { framework_name="$1" device_framework="$2" simulator_framework="$3" xcframework_output="$4" echo "Creating ${xcframework_output} by bundling:" echo " Device framework: ${device_framework}" echo " Simulator framework: ${simulator_framework}" xcodebuild -create-xcframework \ -framework "$device_framework" \ -framework "$simulator_framework" \ -output "$xcframework_output" echo "Created XCFramework: ${xcframework_output}" } wallets=("monero" "wownero" "zano") framework_names=("MoneroWallet" "WowneroWallet" "ZanoWallet") for i in "${!wallets[@]}"; do wallet="${wallets[$i]}" framework_name="${framework_names[$i]}" device_out="${TMP_DIR}/${framework_name}_device" simulator_out="${TMP_DIR}/${framework_name}_simulator" rm -rf "$device_out" "$simulator_out" mkdir -p "$device_out" "$simulator_out" create_framework "$wallet" "$framework_name" "ios" "$device_out" create_framework "$wallet" "$framework_name" "iossimulator" "$simulator_out" device_framework="${device_out}/${framework_name}.framework" simulator_framework="${simulator_out}/${framework_name}.framework" xcframework_output="${IOS_DIR}/${framework_name}.xcframework" rm -rf "$xcframework_output" create_xcframework "$framework_name" "$device_framework" "$simulator_framework" "$xcframework_output" done echo "All XCFrameworks created successfully." rm -rf "$TMP_DIR"