Skip to content

Commit 041aca2

Browse files
authored
Add Analytics header update to iOS SDK update. (#775)
* Add Analytics header update to iOS SDK update.
1 parent eaf697e commit 041aca2

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

.github/workflows/update-dependencies.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
jobs:
2626
update_dependencies:
2727
name: update-deps
28-
runs-on: ubuntu-latest
28+
runs-on: macos-latest
2929
steps:
3030
- name: Get token for firebase-workflow-trigger
3131
uses: tibdex/github-app-token@v1
@@ -77,7 +77,45 @@ jobs:
7777
fi
7878
# iOS: Update Firestore external version to match Firestore Cocoapod version.
7979
firestore_version=$(grep "pod 'Firebase/Firestore'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/")
80+
echo "Setting Firestore external version to ${firestore_version}"
8081
sed -i~ "s/^set(version [^)]*)/set(version CocoaPods-${firestore_version})/i" cmake/external/firestore.cmake
82+
# iOS: Update Analytics header files, used for generating constants.
83+
analytics_version=$(grep "pod 'Firebase/Analytics'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/")
84+
if [[ "$(uname)" == "Darwin"* ]]; then
85+
echo "Updating Analytics iOS headers from version ${analytics_version}"
86+
# Unfortunately we can't just download these headers from GitHub, as
87+
# Analytics is closed-source. If it becomes open-source, we could just
88+
# download the header files from the iOS SDK's release branch. So instead,
89+
# download the Firebase Analytics cocoapod (via a stub project) and get the
90+
# header from there. This will only work on macOS.
91+
podtmp="$(mktemp -d)"
92+
cd "${podtmp}"
93+
# Generate a Podfile for Firebase/Analytics. Use the Specs.git
94+
# source to avoid any propagation delays due to CocoaPods mirror.
95+
echo "source 'https://github.com/CocoaPods/Specs.git'" > Podfile
96+
echo "platform :ios, '14.0'" >> Podfile
97+
echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile
98+
pod repo update
99+
pod install || true # ignore error since there is no Xcode project
100+
declare -a header_dirs
101+
# Get all of the framework header directories from the xcframework.
102+
header_dirs=(Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/*/FirebaseAnalytics.framework/Headers)
103+
# Just use the first directory found, the headers should be the same across
104+
# all of the frameworks.
105+
header_dir="${header_dirs[0]}"
106+
cd -
107+
cd analytics/ios_headers
108+
for ios_header in *.h; do
109+
# Each file in this directory matches a file in the Analytics iOS SDK.
110+
cp -vf "${podtmp}/${header_dir}/${ios_header}" .
111+
# Add a note to each file about its source.
112+
sed -i~ 's|^/// @file|// Copied from Firebase Analytics iOS SDK '"${analytics_version}"'.\n\n/// @file|' "${ios_header}"
113+
rm -f "${ios_header}~" # remove backup file that sed generated
114+
python ../../scripts/format_code.py --f "${ios_header}"
115+
done
116+
cd -
117+
rm -rf "${podtmp}"
118+
fi
81119
elif [[ ${{ github.event.inputs.updateAndroid }} -eq 1 ]]; then
82120
# Update Android only
83121
echo "Updating Android dependencies only"

0 commit comments

Comments
 (0)