@@ -14,14 +14,23 @@ mkdir -p "${workdir}/Logs"
14
14
grdb_dir=" ${workdir} /GRDB-source"
15
15
sqlcipher_dir=" ${workdir} /sqlcipher-source"
16
16
17
+ # For debug uncomment selectively
18
+ # workdir="/var/folders/d5/vbxjsy7967g9x3twy08jyggm0000gn/T/tmp.wlUxvocA0c"
19
+ # new_version="3.0.6"
20
+ # grdb_tag="v7.0.0-beta.6"
21
+ # sqlcipher_tag="v4.6.1"
22
+ # xcframework_zip="${workdir}/GRDB.xcframework.zip"
23
+
24
+ export new_version upstream_version=" ${grdb_tag# v} " sqlcipher_version=" ${sqlcipher_tag# v} "
25
+
17
26
print_usage_and_exit () {
18
- cat << - EOF
19
- Usage:
20
- $ $( basename " $0 " ) [-v] [-h] [<grdb_tag>]
27
+ cat << -EOF
28
+ Usage:
29
+ $ $( basename " $0 " ) [-v] [-h] [<grdb_tag>]
21
30
22
- Options:
23
- -h Show this message
24
- -v Verbose output
31
+ Options:
32
+ -h Show this message
33
+ -v Verbose output
25
34
EOF
26
35
27
36
exit 1
@@ -30,18 +39,17 @@ print_usage_and_exit() {
30
39
read_command_line_arguments () {
31
40
while getopts ' hv' OPTION; do
32
41
case " ${OPTION} " in
33
- h)
34
- print_usage_and_exit
35
- ;;
36
- v)
37
- mute=
38
- ;;
39
- * )
40
- ;;
42
+ h)
43
+ print_usage_and_exit
44
+ ;;
45
+ v)
46
+ mute=
47
+ ;;
48
+ * ) ;;
41
49
esac
42
50
done
43
51
44
- shift $(( OPTIND- 1 ))
52
+ shift $(( OPTIND - 1 ))
45
53
46
54
grdb_tag=" $1 "
47
55
if [[ -n " $grdb_tag " ]]; then
@@ -84,26 +92,26 @@ update_readme() {
84
92
85
93
export new_version upstream_version=" ${grdb_tag# v} " sqlcipher_version=" ${sqlcipher_tag# v} "
86
94
87
- # Check if versions are the same as before to skip release
88
- if [[ " ${current_upstream_version} " == " ${upstream_version} " ]] && \
89
- [[ " ${current_sqlcipher_version} " == " ${sqlcipher_version} " ]] && \
95
+ # Check if versions are the same as before to skip release
96
+ if [[ " ${current_upstream_version} " == " ${upstream_version} " ]] &&
97
+ [[ " ${current_sqlcipher_version} " == " ${sqlcipher_version} " ]] &&
90
98
[[ -z " $force_release " ]]; then
91
99
echo " GRDB.swift (${upstream_version} ) and SQLCipher (${sqlcipher_version} ) versions did not change. Skipping release."
92
100
exit 1
93
101
fi
94
102
95
- cat << - EOF
103
+ cat << -EOF
96
104
97
- Inline GRDB.swift current version: ${current_version}
98
- Upstream GRDB.swift version: ${current_upstream_version} -> ${upstream_version}
99
- SQLCipher version: ${current_sqlcipher_version} -> ${sqlcipher_version}
105
+ Inline GRDB.swift current version: ${current_version}
106
+ Upstream GRDB.swift version: ${current_upstream_version} -> ${upstream_version}
107
+ SQLCipher version: ${current_sqlcipher_version} -> ${sqlcipher_version}
100
108
EOF
101
109
102
110
while ! [[ " ${new_version} " =~ [0-9]\. [0-9]\. [0-9] ]]; do
103
- read -rp " Input Inline GRDB.swift desired version number (x.y.z): " new_version < /dev/tty
111
+ read -rp " Input Inline GRDB.swift desired version number (x.y.z): " new_version < /dev/tty
104
112
done
105
113
106
- envsubst < " ${cwd} /assets/README.md.in" > README.md
114
+ envsubst < " ${cwd} /assets/README.md.in" > README.md
107
115
108
116
echo " Updated README.md ✅"
109
117
echo " "
@@ -114,7 +122,10 @@ build_sqlcipher() {
114
122
local header_path=" ${sqlcipher_destdir} /sqlite3.h"
115
123
local impl_path=" ${sqlcipher_destdir} /sqlite3.c"
116
124
117
- eval pushd " $sqlcipher_dir " " $mute " || { echo " pushd failed" ; exit 1; }
125
+ eval pushd " $sqlcipher_dir " " $mute " || {
126
+ echo " pushd failed"
127
+ exit 1
128
+ }
118
129
119
130
printf ' %s' " Configuring SQLCipher ... "
120
131
eval ./configure --with-crypto-lib=none " $mute "
@@ -125,7 +136,10 @@ build_sqlcipher() {
125
136
eval make -j" ${ncpu} " sqlite3.c " $mute "
126
137
echo " ✅"
127
138
128
- eval popd " $mute " || { echo " popd failed" ; exit 1; }
139
+ eval popd " $mute " || {
140
+ echo " popd failed"
141
+ exit 1
142
+ }
129
143
130
144
printf ' %s' " Moving SQLCipher artifacts into place ... "
131
145
rm -f " $header_path " " $impl_path "
@@ -134,8 +148,8 @@ build_sqlcipher() {
134
148
135
149
# Including param.h unconditionally removes compile time
136
150
# warnings about ambiguous MIN and MAX macros.
137
- echo " #include <sys/param.h>" > " $impl_path "
138
- cat " ${sqlcipher_dir} /sqlite3.c" >> " ${impl_path} "
151
+ echo " #include <sys/param.h>" > " $impl_path "
152
+ cat " ${sqlcipher_dir} /sqlite3.c" >> " ${impl_path} "
139
153
echo " ✅"
140
154
}
141
155
@@ -144,26 +158,26 @@ patch_grdb() {
144
158
local grdb_xcodeproj_file=" ${grdb_dir} /GRDB.xcodeproj"
145
159
146
160
printf ' %s' " Patching GRDB ... "
147
- : > " ${grdb_dir} /GRDB/Export.swift"
161
+ : > " ${grdb_dir} /GRDB/Export.swift"
148
162
# echo '#import "sqlite3.h"' > "${grdb_dir}/Support/GRDB-Bridging.h"
149
- echo " #include \" ${grdb_dir} /SQLCipher.xcconfig\" " >> " ${grdb_dir} /Support/GRDBDeploymentTarget.xcconfig"
163
+ echo " #include \" ${grdb_dir} /SQLCipher.xcconfig\" " >> " ${grdb_dir} /Support/GRDBDeploymentTarget.xcconfig"
150
164
# sed -i -E 's/<sqlite3.h>/"sqlite3.h"/' "${grdb_dir}/Support/grdb_config.h"
151
165
152
- # Remove SQLCipher import statements
166
+ # Remove SQLCipher import statements
153
167
find " ${grdb_dir} " -name " *.swift" -type f -exec sed -i ' ' ' s/import SQLCipher/\/\/import SQLCipher/g' {} +
154
168
155
- if patch -s -p1 -f -d " $grdb_dir " < " $patch_file " ; then
169
+ if patch -s -p1 -f -d " $grdb_dir " < " $patch_file " ; then
156
170
echo " ✅"
157
171
else
158
172
echo " ❌"
159
173
cat << -EOF
160
- Failed to automatically patch GRDB.swift Xcode project file. Please follow instructions for manual patching:
161
- 1. After you confirm reading instructions, two windows will open:
162
- * Xcode, with GRDB.swift project
163
- * Finder, with GRDB source code directory (look for sqlite3.h and sqlite3.c files)
164
- 2. Drag sqlite3.h and sqlite3.c to the Xcode project under GRDB directory. Add both files to GRDB target.
165
- 3. Select sqlite3.h in Xcode, open right hand side panel and adjust Target Membership by marking the header file as Public.
166
- 4. Close Xcode project, go back to terminal and press Ctrl+C to continue.
174
+ Failed to automatically patch GRDB.swift Xcode project file. Please follow instructions for manual patching:
175
+ 1. After you confirm reading instructions, two windows will open:
176
+ * Xcode, with GRDB.swift project
177
+ * Finder, with GRDB source code directory (look for sqlite3.h and sqlite3.c files)
178
+ 2. Drag sqlite3.h and sqlite3.c to the Xcode project under GRDB directory. Add both files to GRDB target.
179
+ 3. Select sqlite3.h in Xcode, open right hand side panel and adjust Target Membership by marking the header file as Public.
180
+ 4. Close Xcode project, go back to terminal and press Ctrl+C to continue.
167
181
EOF
168
182
169
183
read -n 1 -srp " Press any key to continue"
@@ -178,15 +192,15 @@ patch_grdb() {
178
192
local diff
179
193
diff=$( git diff " GRDB.xcodeproj/project.pbxproj" )
180
194
popd > /dev/null 2>&1
181
- echo " $diff " > " ${patch_file} "
195
+ echo " $diff " > " ${patch_file} "
182
196
echo " Updated Xcode project patch file ✅"
183
197
fi
184
198
}
185
199
186
200
setup_log_formatter () {
187
- if command -v xcbeautify & > /dev/null; then
201
+ if command -v xcbeautify & > /dev/null; then
188
202
log_formatter=' xcbeautify'
189
- elif command -v xcpretty & > /dev/null; then
203
+ elif command -v xcpretty & > /dev/null; then
190
204
log_formatter=' xcpretty'
191
205
else
192
206
echo
@@ -224,15 +238,15 @@ build_and_test_release() {
224
238
-project " ${grdb_dir} /GRDB.xcodeproj" \
225
239
-scheme " GRDB" \
226
240
-derivedDataPath " $derived_data_dir " \
227
- -skip-testing:GRDBTests/EncryptionTests/testSQLCipher3Compatibility \
228
- | tee -a " $log_file " | $log_formatter 2>&1 ; then
241
+ -skip-testing:GRDBTests/EncryptionTests/testSQLCipher3Compatibility |
242
+ tee -a " $log_file " | $log_formatter 2>&1 ; then
229
243
230
244
echo " Unit tests succeeded ✅"
231
245
else
232
246
cat << -EOF
233
- Unit tests failed ❌
234
- See log file at ${log_file} for more info.
235
- Rerun with -f to skip testing.
247
+ Unit tests failed ❌
248
+ See log file at ${log_file} for more info.
249
+ Rerun with -f to skip testing.
236
250
EOF
237
251
exit 1
238
252
fi
@@ -262,44 +276,87 @@ build_archive() {
262
276
}
263
277
264
278
build_xcframework () {
279
+ # Add these at the start
280
+ export COPYFILE_DISABLE=1
281
+ export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
282
+
265
283
local derived_data=" ${workdir} /DerivedData"
266
284
local xcframework=" ${workdir} /GRDB.xcframework"
267
285
xcframework_zip=" ${workdir} /GRDB.xcframework.zip"
268
286
local archives_dir=" archives"
269
287
local archives_path=" ${workdir} /${archives_dir} "
270
288
271
- build_opts=(" BUILD_LIBRARY_FOR_DISTRIBUTION=YES" " SKIP_INSTALL=NO" " ONLY_ACTIVE_ARCH=NO" )
289
+ build_opts=(
290
+ " BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
291
+ " SKIP_INSTALL=NO"
292
+ " ONLY_ACTIVE_ARCH=NO"
293
+ )
272
294
273
295
echo " "
274
296
echo " Building XCFramework ⚙️"
275
297
276
298
rm -rf " ${derived_data} " " ${archives_path} " " ${xcframework} "
277
299
300
+ # More aggressive cleanup of resource forks and metadata
301
+ clean_metadata () {
302
+ local dir=" $1 "
303
+ # Remove resource fork files
304
+ find " $dir " -name " ._*" -delete
305
+ # Remove .DS_Store files
306
+ find " $dir " -name " .DS_Store" -delete
307
+ # Remove extended attributes recursively
308
+ xattr -cr " $dir " 2> /dev/null || true
309
+ }
310
+
311
+ # Clean before building
312
+ clean_metadata " ${workdir} "
313
+
314
+ build_archive " macOS" " $archives_path "
278
315
build_archive " iOS" " $archives_path "
279
316
build_archive " iOS Simulator" " $archives_path "
280
- build_archive " macOS" " $archives_path "
317
+
318
+ # Remove any ._ files before creating xcframework
319
+ find " ${archives_path} " -name " ._*" -delete
281
320
282
321
printf ' %s' " Creating XCFramework ... "
283
322
pushd " $workdir " > /dev/null 2>&1
323
+
284
324
xcodebuild -create-xcframework \
285
- -archive " ${archives_dir} /GRDB-iOS.xcarchive" -framework GRDB.framework \
286
- -archive " ${archives_dir} /GRDB-iOS Simulator.xcarchive" -framework GRDB.framework \
287
325
-archive " ${archives_dir} /GRDB-macOS.xcarchive" -framework GRDB.framework \
326
+ -archive " ${archives_dir} /GRDB-iOS.xcarchive" -framework GRDB.framework \
327
+ -archive " ${archives_dir} /GRDB-iOS Simulator.xcarchive" -framework GRDB.framework \
288
328
-output " ${xcframework} " > /dev/null 2>&1
289
329
popd > /dev/null 2>&1
290
330
echo " ✅"
291
-
331
+
332
+ # Clean xcframework after creation
333
+ clean_metadata " ${xcframework} "
334
+
335
+ # Compress using ditto with strict options
292
336
printf ' %s' " Compressing XCFramework ... "
293
337
rm -rf " $xcframework_zip "
294
- ditto -c -k --keepParent " $xcframework " " $xcframework_zip "
338
+ if ! ditto -c -k --keepParent --noextattr --norsrc " $xcframework " " $xcframework_zip " ; then
339
+ echo " ❌"
340
+ echo " Failed to compress XCFramework"
341
+ exit 1
342
+ fi
343
+ echo " ✅"
344
+
345
+ # Final verification
346
+ printf ' %s' " Verifying compressed framework ... "
347
+ if ! unzip -t " $xcframework_zip " > /dev/null 2>&1 ; then
348
+ echo " ❌"
349
+ echo " Compressed framework verification failed"
350
+ exit 1
351
+ fi
295
352
echo " ✅"
296
353
}
297
354
298
355
update_swift_package () {
299
356
printf ' %s' " Updating Package.swift ... "
300
357
export checksum
301
358
checksum=$( swift package compute-checksum " $xcframework_zip " )
302
- envsubst < " ${cwd} /assets/Package.swift.in" > " ${cwd} /Package.swift"
359
+ envsubst < " ${cwd} /assets/Package.swift.in" > " ${cwd} /Package.swift"
303
360
echo " ✅"
304
361
}
305
362
@@ -316,9 +373,9 @@ make_release() {
316
373
317
374
gh release create " $new_version " --generate-notes " ${xcframework_zip} " --repo inlinehq/GRDB.swift
318
375
319
- cat << - EOF
376
+ cat << -EOF
320
377
321
- 🎉 Release is ready at https://github.com/inlinehq/GRDB.swift/releases/tag/${new_version}
378
+ 🎉 Release is ready at https://github.com/inlinehq/GRDB.swift/releases/tag/${new_version}
322
379
EOF
323
380
}
324
381
0 commit comments