@@ -14,14 +14,23 @@ mkdir -p "${workdir}/Logs"
1414grdb_dir=" ${workdir} /GRDB-source"
1515sqlcipher_dir=" ${workdir} /sqlcipher-source"
1616
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+
1726print_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>]
2130
22- Options:
23- -h Show this message
24- -v Verbose output
31+ Options:
32+ -h Show this message
33+ -v Verbose output
2534 EOF
2635
2736 exit 1
@@ -30,18 +39,17 @@ print_usage_and_exit() {
3039read_command_line_arguments () {
3140 while getopts ' hv' OPTION; do
3241 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+ * ) ;;
4149 esac
4250 done
4351
44- shift $(( OPTIND- 1 ))
52+ shift $(( OPTIND - 1 ))
4553
4654 grdb_tag=" $1 "
4755 if [[ -n " $grdb_tag " ]]; then
@@ -84,26 +92,26 @@ update_readme() {
8492
8593 export new_version upstream_version=" ${grdb_tag# v} " sqlcipher_version=" ${sqlcipher_tag# v} "
8694
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} " ]] &&
9098 [[ -z " $force_release " ]]; then
9199 echo " GRDB.swift (${upstream_version} ) and SQLCipher (${sqlcipher_version} ) versions did not change. Skipping release."
92100 exit 1
93101 fi
94102
95- cat << - EOF
103+ cat << -EOF
96104
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}
100108 EOF
101109
102110 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
104112 done
105113
106- envsubst < " ${cwd} /assets/README.md.in" > README.md
114+ envsubst < " ${cwd} /assets/README.md.in" > README.md
107115
108116 echo " Updated README.md ✅"
109117 echo " "
@@ -114,7 +122,10 @@ build_sqlcipher() {
114122 local header_path=" ${sqlcipher_destdir} /sqlite3.h"
115123 local impl_path=" ${sqlcipher_destdir} /sqlite3.c"
116124
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+ }
118129
119130 printf ' %s' " Configuring SQLCipher ... "
120131 eval ./configure --with-crypto-lib=none " $mute "
@@ -125,7 +136,10 @@ build_sqlcipher() {
125136 eval make -j" ${ncpu} " sqlite3.c " $mute "
126137 echo " ✅"
127138
128- eval popd " $mute " || { echo " popd failed" ; exit 1; }
139+ eval popd " $mute " || {
140+ echo " popd failed"
141+ exit 1
142+ }
129143
130144 printf ' %s' " Moving SQLCipher artifacts into place ... "
131145 rm -f " $header_path " " $impl_path "
@@ -134,8 +148,8 @@ build_sqlcipher() {
134148
135149 # Including param.h unconditionally removes compile time
136150 # 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} "
139153 echo " ✅"
140154}
141155
@@ -144,26 +158,26 @@ patch_grdb() {
144158 local grdb_xcodeproj_file=" ${grdb_dir} /GRDB.xcodeproj"
145159
146160 printf ' %s' " Patching GRDB ... "
147- : > " ${grdb_dir} /GRDB/Export.swift"
161+ : > " ${grdb_dir} /GRDB/Export.swift"
148162 # 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"
150164 # sed -i -E 's/<sqlite3.h>/"sqlite3.h"/' "${grdb_dir}/Support/grdb_config.h"
151165
152- # Remove SQLCipher import statements
166+ # Remove SQLCipher import statements
153167 find " ${grdb_dir} " -name " *.swift" -type f -exec sed -i ' ' ' s/import SQLCipher/\/\/import SQLCipher/g' {} +
154168
155- if patch -s -p1 -f -d " $grdb_dir " < " $patch_file " ; then
169+ if patch -s -p1 -f -d " $grdb_dir " < " $patch_file " ; then
156170 echo " ✅"
157171 else
158172 echo " ❌"
159173 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.
167181 EOF
168182
169183 read -n 1 -srp " Press any key to continue"
@@ -178,15 +192,15 @@ patch_grdb() {
178192 local diff
179193 diff=$( git diff " GRDB.xcodeproj/project.pbxproj" )
180194 popd > /dev/null 2>&1
181- echo " $diff " > " ${patch_file} "
195+ echo " $diff " > " ${patch_file} "
182196 echo " Updated Xcode project patch file ✅"
183197 fi
184198}
185199
186200setup_log_formatter () {
187- if command -v xcbeautify & > /dev/null; then
201+ if command -v xcbeautify & > /dev/null; then
188202 log_formatter=' xcbeautify'
189- elif command -v xcpretty & > /dev/null; then
203+ elif command -v xcpretty & > /dev/null; then
190204 log_formatter=' xcpretty'
191205 else
192206 echo
@@ -224,15 +238,15 @@ build_and_test_release() {
224238 -project " ${grdb_dir} /GRDB.xcodeproj" \
225239 -scheme " GRDB" \
226240 -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
229243
230244 echo " Unit tests succeeded ✅"
231245 else
232246 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.
236250 EOF
237251 exit 1
238252 fi
@@ -262,44 +276,87 @@ build_archive() {
262276}
263277
264278build_xcframework () {
279+ # Add these at the start
280+ export COPYFILE_DISABLE=1
281+ export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
282+
265283 local derived_data=" ${workdir} /DerivedData"
266284 local xcframework=" ${workdir} /GRDB.xcframework"
267285 xcframework_zip=" ${workdir} /GRDB.xcframework.zip"
268286 local archives_dir=" archives"
269287 local archives_path=" ${workdir} /${archives_dir} "
270288
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+ )
272294
273295 echo " "
274296 echo " Building XCFramework ⚙️"
275297
276298 rm -rf " ${derived_data} " " ${archives_path} " " ${xcframework} "
277299
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 "
278315 build_archive " iOS" " $archives_path "
279316 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
281320
282321 printf ' %s' " Creating XCFramework ... "
283322 pushd " $workdir " > /dev/null 2>&1
323+
284324 xcodebuild -create-xcframework \
285- -archive " ${archives_dir} /GRDB-iOS.xcarchive" -framework GRDB.framework \
286- -archive " ${archives_dir} /GRDB-iOS Simulator.xcarchive" -framework GRDB.framework \
287325 -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 \
288328 -output " ${xcframework} " > /dev/null 2>&1
289329 popd > /dev/null 2>&1
290330 echo " ✅"
291-
331+
332+ # Clean xcframework after creation
333+ clean_metadata " ${xcframework} "
334+
335+ # Compress using ditto with strict options
292336 printf ' %s' " Compressing XCFramework ... "
293337 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
295352 echo " ✅"
296353}
297354
298355update_swift_package () {
299356 printf ' %s' " Updating Package.swift ... "
300357 export checksum
301358 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"
303360 echo " ✅"
304361}
305362
@@ -316,9 +373,9 @@ make_release() {
316373
317374 gh release create " $new_version " --generate-notes " ${xcframework_zip} " --repo inlinehq/GRDB.swift
318375
319- cat << - EOF
376+ cat << -EOF
320377
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}
322379 EOF
323380}
324381
0 commit comments