dev
sh 160 lines 4.69 KB
Raw
1 #!/bin/sh
2 set -e
3
4 IOS_DIR="$(pwd)/../../ios"
5 monero_c_tag=$(cd $(pwd)/../../scripts/monero_c/; git describe --tags)
6 DYLIB_PATH="$(pwd)/../../scripts/monero_c/release/${monero_c_tag}/"
7 TMP_DIR="${IOS_DIR}/tmp"
8
9 rm -rf "${IOS_DIR:?}/MoneroWallet.xcframework" "${IOS_DIR:?}/WowneroWallet.xcframework" "${IOS_DIR:?}/ZanoWallet.xcframework"
10 rm -rf "${IOS_DIR:?}/MoneroWallet.framework" "${IOS_DIR:?}/WowneroWallet.framework" "${IOS_DIR:?}/ZanoWallet.framework"
11 rm -rf "$TMP_DIR"
12 mkdir -p "$TMP_DIR"
13
14 write_info_plist() {
15 framework_bundle="$1"
16 framework_name="$2"
17 target="$3"
18 plist_path="${framework_bundle}/Info.plist"
19
20 if [[ "x$target" = "xios-simulator" ]]; then
21 platform="iPhoneSimulator"
22 dtplatformname="iphonesimulator"
23 dtsdkname="iphonesimulator17.4"
24 else
25 platform="iPhoneOS"
26 dtplatformname="iphoneos"
27 dtsdkname="iphoneos17.4"
28 fi
29
30 cat > "$plist_path" <<EOF
31 <?xml version="1.0" encoding="UTF-8"?>
32 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33 <plist version="1.0">
34 <dict>
35 <key>BuildMachineOSBuild</key>
36 <string>23E224</string>
37 <key>CFBundleDevelopmentRegion</key>
38 <string>en</string>
39 <key>CFBundleExecutable</key>
40 <string>${framework_name}</string>
41 <key>CFBundleIdentifier</key>
42 <string>com.fotolockr.${framework_name}</string>
43 <key>CFBundleInfoDictionaryVersion</key>
44 <string>6.0</string>
45 <key>CFBundleName</key>
46 <string>${framework_name}</string>
47 <key>CFBundlePackageType</key>
48 <string>FMWK</string>
49 <key>CFBundleShortVersionString</key>
50 <string>1.0</string>
51 <key>CFBundleSignature</key>
52 <string>???</string>
53 <key>CFBundleSupportedPlatforms</key>
54 <array>
55 <string>${platform}</string>
56 </array>
57 <key>CFBundleVersion</key>
58 <string>1</string>
59 <key>DTCompiler</key>
60 <string>com.apple.compilers.llvm.clang.1_0</string>
61 <key>DTPlatformBuild</key>
62 <string>21E210</string>
63 <key>DTPlatformName</key>
64 <string>${dtplatformname}</string>
65 <key>DTPlatformVersion</key>
66 <string>17.4</string>
67 <key>DTSDKBuild</key>
68 <string>21E210</string>
69 <key>DTSDKName</key>
70 <string>${dtsdkname}</string>
71 <key>DTXcode</key>
72 <string>1530</string>
73 <key>DTXcodeBuild</key>
74 <string>15E204a</string>
75 <key>MinimumOSVersion</key>
76 <string>16.0</string>
77 <key>UIDeviceFamily</key>
78 <array>
79 <integer>1</integer>
80 <integer>2</integer>
81 </array>
82 <key>UIRequiredDeviceCapabilities</key>
83 <array>
84 <string>arm64</string>
85 </array>
86 </dict>
87 </plist>
88 EOF
89 plutil -convert binary1 "$plist_path"
90 }
91
92 create_framework() {
93 wallet="$1"
94 framework_name="$2"
95 target="$3"
96 out_dir="$4"
97
98 echo "Creating ${framework_name}.framework for target ${target} in ${out_dir}..."
99
100 framework_bundle="${out_dir}/${framework_name}.framework"
101
102 rm -rf "$framework_bundle"
103 mkdir -p "$framework_bundle"
104
105 input_dylib="${DYLIB_PATH}/aarch64-apple-${target}/lib${wallet}_wallet2_api_c.dylib"
106 if [[ ! -f "$input_dylib" ]]; then
107 echo "Error: Input dylib not found: $input_dylib"
108 exit 1
109 fi
110
111 lipo -create "$input_dylib" -output "${framework_bundle}/${framework_name}"
112 echo "Created binary: ${framework_bundle}/${framework_name}"
113
114 write_info_plist "$framework_bundle" "$framework_name" "$target"
115 }
116
117 create_xcframework() {
118 framework_name="$1"
119 device_framework="$2"
120 simulator_framework="$3"
121 xcframework_output="$4"
122
123 echo "Creating ${xcframework_output} by bundling:"
124 echo " Device framework: ${device_framework}"
125 echo " Simulator framework: ${simulator_framework}"
126
127 xcodebuild -create-xcframework \
128 -framework "$device_framework" \
129 -framework "$simulator_framework" \
130 -output "$xcframework_output"
131
132 echo "Created XCFramework: ${xcframework_output}"
133 }
134
135 wallets=("monero" "wownero" "zano")
136 framework_names=("MoneroWallet" "WowneroWallet" "ZanoWallet")
137
138 for i in "${!wallets[@]}"; do
139 wallet="${wallets[$i]}"
140 framework_name="${framework_names[$i]}"
141
142 device_out="${TMP_DIR}/${framework_name}_device"
143 simulator_out="${TMP_DIR}/${framework_name}_simulator"
144 rm -rf "$device_out" "$simulator_out"
145 mkdir -p "$device_out" "$simulator_out"
146
147 create_framework "$wallet" "$framework_name" "ios" "$device_out"
148 create_framework "$wallet" "$framework_name" "ios-simulator" "$simulator_out"
149
150 device_framework="${device_out}/${framework_name}.framework"
151 simulator_framework="${simulator_out}/${framework_name}.framework"
152 xcframework_output="${IOS_DIR}/${framework_name}.xcframework"
153 rm -rf "$xcframework_output"
154
155 create_xcframework "$framework_name" "$device_framework" "$simulator_framework" "$xcframework_output"
156 done
157
158 echo "All XCFrameworks created successfully."
159
160 rm -rf "$TMP_DIR"