|
34 | 34 | #
|
35 | 35 | # USAGE: ./check_firestore_symbols.sh <PATH_TO_FIREBASE_REPO> <PATH_TO_FIRESTORE_XCFRAMEWORK>
|
36 | 36 |
|
| 37 | +set -euo pipefail |
| 38 | + |
37 | 39 | if [[ $# -ne 2 ]]; then
|
38 | 40 | echo "Usage: ./check_firestore_symbols.sh <PATH_TO_FIREBASE_REPO> <PATH_TO_FIRESTORE_XCFRAMEWORK>"
|
39 | 41 | exit 1
|
@@ -123,35 +125,38 @@ cd "$TEST_PKG_ROOT"
|
123 | 125 | # Build the test package *without* the `-ObjC` linker flag, and dump the
|
124 | 126 | # resulting executable file's Objective-C symbols into a text file.
|
125 | 127 | echo "Building test package without -ObjC linker flag..."
|
126 |
| -# Invoke a subshell to avoid pipefail affecting the rest of the script. |
127 |
| -( |
128 |
| - set -eo pipefail && FIREBASECI_USE_LOCAL_FIRESTORE_ZIP=1 \ |
129 |
| - xcodebuild -scheme 'TestPkg' -destination 'generic/platform=macOS' \ |
130 |
| - -derivedDataPath "$HOME/Library/Developer/Xcode/DerivedData/TestPkg" \ |
131 |
| - | xcpretty |
132 |
| -) |
133 |
| - |
| 128 | +FIREBASECI_USE_LOCAL_FIRESTORE_ZIP=1 xcodebuild -scheme 'TestPkg' \ |
| 129 | + -destination 'generic/platform=macOS' \ |
| 130 | + -derivedDataPath "$HOME/Library/Developer/Xcode/DerivedData/TestPkg" \ |
| 131 | + | xcpretty |
134 | 132 |
|
135 | 133 | nm ~/Library/Developer/Xcode/DerivedData/TestPkg/Build/Products/Debug/TestPkg \
|
136 | 134 | | grep -o "[-+]\[.*\]" > objc_symbols_without_linker_flag.txt
|
137 | 135 |
|
138 | 136 | # Build the test package *with* the -ObjC linker flag, and dump the
|
139 | 137 | # resulting executable file's Objective-C symbols into a text file.
|
140 | 138 | echo "Building test package with -ObjC linker flag..."
|
141 |
| -# Invoke a subshell to avoid pipefail affecting the rest of the script. |
142 |
| -( |
143 |
| - set -eo pipefail && FIREBASECI_USE_LOCAL_FIRESTORE_ZIP=1 \ |
144 |
| - xcodebuild -scheme 'TestPkg' -destination 'generic/platform=macOS' \ |
145 |
| - -derivedDataPath "$HOME/Library/Developer/Xcode/DerivedData/TestPkg-ObjC" \ |
146 |
| - OTHER_LDFLAGS='-ObjC' \ |
147 |
| - | xcpretty |
148 |
| -) |
| 139 | +FIREBASECI_USE_LOCAL_FIRESTORE_ZIP=1 xcodebuild -scheme 'TestPkg' \ |
| 140 | + -destination 'generic/platform=macOS' \ |
| 141 | + -derivedDataPath "$HOME/Library/Developer/Xcode/DerivedData/TestPkg-ObjC" \ |
| 142 | + OTHER_LDFLAGS='-ObjC' \ |
| 143 | + | xcpretty |
149 | 144 |
|
150 | 145 | nm ~/Library/Developer/Xcode/DerivedData/TestPkg-ObjC/Build/Products/Debug/TestPkg \
|
151 | 146 | | grep -o "[-+]\[.*\]" > objc_symbols_with_linker_flag.txt
|
152 | 147 |
|
153 |
| -# Compare the two text files to see if the -ObjC linker flag has any effect. |
154 |
| -DIFF=$(diff objc_symbols_without_linker_flag.txt objc_symbols_with_linker_flag.txt) |
| 148 | +# Compare the two text files to see if the -ObjC linker flag caused additional |
| 149 | +# symbols to link. |
| 150 | +# |
| 151 | +# Note: In the case where the diff is non-empty, the diff command will |
| 152 | +# return exit code 1, which will cause the set pipefail to terminate execution. |
| 153 | +# To avoid this, `|| true` ensures the exit code always indicates success. |
| 154 | +DIFF=$( |
| 155 | + git diff --no-index \ |
| 156 | + objc_symbols_without_linker_flag.txt \ |
| 157 | + objc_symbols_with_linker_flag.txt \ |
| 158 | + || true |
| 159 | +) |
155 | 160 | if [[ -n "$DIFF" ]]; then
|
156 | 161 | echo "Failure: Unlinked Objective-C symbols have been detected:"
|
157 | 162 | echo "$DIFF"
|
|
0 commit comments