Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .agents/skills/firebase-cpp-builder/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ For iOS, you can use the convenience script from the repository root:

_(Run `./build_scripts/ios/build.sh -h` for more options.)_

Alternatively, you can use CMake's native Xcode generator manually. Ensure you
have CocoaPods installed if building products that depend on iOS SDK Pods.
Alternatively, you can use CMake's native Xcode generator manually.

```bash
mkdir ios_build
Expand Down
100 changes: 40 additions & 60 deletions .github/workflows/update-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,84 +80,64 @@
python scripts/update_android_ios_dependencies.py --skip_android --logfile=${UPDATE_LOGFILE}
echo "CHOSEN_DEPS=iOS" >> $GITHUB_ENV
fi
# iOS: Update Firestore external version to match Firestore Cocoapod version.
firestore_version=$(grep "pod 'Firebase/Firestore'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/")
echo "Setting Firestore external version to ${firestore_version}"
sed -i~ "s/^set(version [^)]*)/set(version CocoaPods-${firestore_version})/i" cmake/external/firestore.cmake
# iOS: Update Analytics header files, used for generating constants.
analytics_version=$(grep "pod 'Firebase/Analytics'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/")
if [[ "$(uname)" == "Darwin"* ]]; then
echo "Updating Analytics iOS headers from version ${analytics_version}"
# Unfortunately we can't just download these headers from GitHub, as
# Analytics is closed-source. If it becomes open-source, we could just
# download the header files from the iOS SDK's release branch. So instead,
# download the Firebase Analytics cocoapod (via a stub project) and get the
# header from there. This will only work on macOS.
podtmp="$(mktemp -d)"
cd "${podtmp}"
# Generate a Podfile for Firebase/Analytics. Use the Specs.git
# source to avoid any propagation delays due to CocoaPods mirror.
echo "source 'https://github.com/CocoaPods/Specs.git'" > Podfile
echo "platform :ios, '15.0'" >> Podfile
echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile
pod repo update
pod install || true # ignore error since there is no Xcode project
declare -a header_dirs
# Get all of the framework header directories from the xcframework.
header_dirs=(Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/*/FirebaseAnalytics.framework/Headers)
# Just use the first directory found, the headers should be the same across
# all of the frameworks.
header_dir="${header_dirs[0]}"
cd -
cd analytics/ios_headers
for ios_header in *.h; do
# Each file in this directory matches a file in the Analytics iOS SDK.
cp -vf "${podtmp}/${header_dir}/${ios_header}" .
# If the file doesn't have a Google copyright, add one.
if ! grep -q "^// Copyright [0-9]* Google LLC" "${ios_header}"; then
copyright_line="// Copyright $(date +%Y) Google LLC\n"
else
copyright_line=
fi
# Add a note to each file about its source.
sed -i~ "s|^/// @file|${copyright_line}\n// Copied from Firebase Analytics iOS SDK ${analytics_version}.\n\n/// @file|" "${ios_header}"
rm -f "${ios_header}~" # remove backup file that sed generated
python ../../scripts/format_code.py --f "${ios_header}"
done
cd -
rm -rf "${podtmp}"
fi
# iOS: Update Firestore external version to match Firebase iOS SDK version.
firebase_ios_version=$(grep "firebase-ios-sdk.git" ios_spm/Package.swift | sed 's/.*exact: "\([^"]*\)".*/\1/')
echo "Setting Firestore external version to ${firebase_ios_version}"
sed -i~ "s/^set(version [^)]*)/set(version ${firebase_ios_version})/i" cmake/external/firestore.cmake

# Download the zip distribution and get the Swift header files.
core_version=$(grep "pod 'Firebase/Core'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/")
echo "Getting Swift header files from Firebase iOS SDK ${core_version} zip distribution"
# Download the Firebase iOS prebuilt zip distribution for Analytics and Swift headers.
echo "Downloading Firebase iOS SDK ${firebase_ios_version} prebuilt zip distribution"
ziptmp="$(mktemp -d)"
# The version might be named vX.Y.Z or simply X.Y.Z, check which exists.
declare -a zip_urls
zip_urls=("https://github.com/firebase/firebase-ios-sdk/releases/download/v${core_version}/Firebase.zip" "https://github.com/firebase/firebase-ios-sdk/releases/download/${core_version}/Firebase.zip")
zip_urls=("https://github.com/firebase/firebase-ios-sdk/releases/download/v${firebase_ios_version}/Firebase.zip" "https://github.com/firebase/firebase-ios-sdk/releases/download/${firebase_ios_version}/Firebase.zip")
for try_url in ${zip_urls[@]} error; do
curl -H 'Authorization: token ${{ github.token }}' -L -f "${try_url}" -o "${ziptmp}/Firebase.zip" 2> /dev/null && break
done
if [[ "${try_url}" == "error" ]]; then
echo "::error ::Could not download Firebase iOS prebuilt zip file, skipping Swift headers."
echo "::error ::Could not download Firebase iOS prebuilt zip file, skipping iOS headers update."
else
cd "${ziptmp}"
echo "Unzipping..."
unzip -q Firebase.zip '*-Swift.h'
unzip -q Firebase.zip
cd -
# Copy all *-Swift.h header files into ios_pod/swift_headers/
echo "Copying headers..."
find "${ziptmp}" -name '*-Swift.h' -path '*ios*arm64*x86_64*simulator*' -print0 | xargs -0 -n 1 -J REPLACETEXT cp -f REPLACETEXT ios_pod/swift_headers/

# iOS: Update Analytics header files, used for generating constants.
echo "Updating Analytics iOS headers from version ${firebase_ios_version}"
declare -a header_dirs
header_dirs=("${ziptmp}"/FirebaseAnalytics/FirebaseAnalytics.xcframework/*/FirebaseAnalytics.framework/Headers)
if [[ -d "${header_dirs[0]}" ]]; then
header_dir="${header_dirs[0]}"
cd analytics/ios_headers
for ios_header in *.h; do
if [[ -f "${header_dir}/${ios_header}" ]]; then
cp -vf "${header_dir}/${ios_header}" .
if ! grep -q "^// Copyright [0-9]* Google LLC" "${ios_header}"; then
copyright_line="// Copyright $(date +%Y) Google LLC\n"
else
copyright_line=
fi
sed -i~ "s|^/// @file|${copyright_line}\n// Copied from Firebase Analytics iOS SDK ${firebase_ios_version}.\n\n/// @file|" "${ios_header}"
rm -f "${ios_header}~"
python ../../scripts/format_code.py --f "${ios_header}"
fi
done
cd -
fi

# Copy all *-Swift.h header files into ios_spm/swift_headers/
echo "Copying Swift bridging headers..."
mkdir -p ios_spm/swift_headers
find "${ziptmp}" -name '*-Swift.h' -path '*ios*arm64*x86_64*simulator*' -print0 | xargs -0 -n 1 -J REPLACETEXT cp -f REPLACETEXT ios_spm/swift_headers/
copyright_line="// Copyright $(date +%Y) Google LLC"
# Add a note to each file about its source.
for ios_header in ios_pod/swift_headers/*.h; do
for ios_header in ios_spm/swift_headers/*.h; do
if ! grep -q "^// Copied from Firebase iOS SDK" "${ios_header}"; then
sed -i~ "s|^// Generated by Apple Swift|${copyright_line}\n// Copied from Firebase iOS SDK ${core_version}.\n\n// Generated by Apple Swift|" "${ios_header}"
sed -i~ "s|^// Generated by Apple Swift|${copyright_line}\n// Copied from Firebase iOS SDK ${firebase_ios_version}.\n\n// Generated by Apple Swift|" "${ios_header}"
fi
python3 scripts/format_code.py --f "${ios_header}"
done
fi
rm -rf ${ziptmp}
rm -rf "${ziptmp}"
elif [[ ${GITHUB_EVENT_INPUTS_UPDATEANDROID} -eq 1 ]]; then
# Update Android only
echo "Updating Android dependencies only"
Expand Down Expand Up @@ -229,7 +209,7 @@
GITHUB_EVENT_INPUTS_BASEBRANCH: ${{ github.event.inputs.baseBranch }}

- name: Set test trigger label.
uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # ratchet:actions-ecosystem/action-add-labels@v1

Check notice on line 212 in .github/workflows/update-dependencies.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

superfluous-actions

update-dependencies.yml:212: action functionality is already included by the runner: use `gh issue edit --add-label` or `gh pr edit --add-label` in a script step
if: ${{ github.event.inputs.triggerTests == 1 && steps.push-branch.outputs.branch_pushed == 1 }}
with:
github_token: ${{ steps.generate-token.outputs.token }}
Expand Down
1 change: 0 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ instructions for your specific platform.
recommended) is also needed.
* **(Windows Only) Strings**: From Microsoft Sysinternals, required for
Android builds on Windows.
* **Cocoapods**: Required for building iOS or tvOS libraries.

To build for Desktop, you can install prerequisites by running the following
script in the root of the repository: `scripts/gha/install_prereqs_desktop.py`
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ if(MSVC)
add_definitions(-DNOMINMAX)
endif()

add_subdirectory(ios_pod)
add_subdirectory(ios_spm)

# If we're building tests, we need to include the 'testing' folder before any
# of the tests actually get built.
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ Note that we include the Gradle wrapper, which if used will acquire the
necessary version of Gradle for you.

### Prerequisites for iOS/tvOS
The following prerequisites are required when building the libraries for iOS or tvOS.
- [Cocoapods](https://cocoapods.org/)

</details>

Expand Down Expand Up @@ -192,7 +190,7 @@ that work for both iOS and tvOS. This is helpful as we can use the same
deliverable for both iOS and tvOS targets in the same XCode project.

``` bash
# Install prereqs (like cocoapods)
# Install prereqs
./build_scripts/tvos/install_prereqs.sh
python3 scripts/gha/build_ios_tvos.py -s . -b ios_tvos_build
```
Expand Down
23 changes: 12 additions & 11 deletions analytics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,7 @@ elseif(IOS)
target_include_directories(firebase_analytics PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
endif()

# Swift needs to find the FirebaseAnalytics module from CocoaPods
set(pods_dir "${FIREBASE_POD_DIR}/Pods")

# Point to the base directories containing the .xcframework folders.
# Xcode natively handles XCFrameworks and will pick the right slice automatically.
# Determine the xcframework architecture slice based on the target platform
# and if it is running on simulator or device.
# Swift needs to find the FirebaseAnalytics module from SwiftPM artifacts
string(TOLOWER "${CMAKE_OSX_SYSROOT}" sysroot_lower)
if(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
if(sysroot_lower MATCHES "simulator")
Expand All @@ -171,9 +165,15 @@ elseif(IOS)
endif()
endif()

set(analytics_framework_dir "${pods_dir}/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/${analytics_slice}")
set(measurement_framework_dir "${pods_dir}/GoogleAppMeasurement/Frameworks/GoogleAppMeasurement.xcframework/${analytics_slice}")
set(analytics_framework_dir "${FIREBASE_SPM_ARTIFACTS_DIR}/firebase-ios-sdk/FirebaseAnalytics/FirebaseAnalytics.xcframework/${analytics_slice}")
set(measurement_framework_dir "${FIREBASE_SPM_ARTIFACTS_DIR}/googleappmeasurement/GoogleAppMeasurement/GoogleAppMeasurement.xcframework/${analytics_slice}")

target_include_directories(firebase_analytics
PUBLIC
"${analytics_framework_dir}/FirebaseAnalytics.framework/Headers"
"${measurement_framework_dir}/GoogleAppMeasurement.framework/Headers"
)

target_compile_options(firebase_analytics
PRIVATE
$<$<COMPILE_LANGUAGE:Swift>:-F${analytics_framework_dir}>
Expand All @@ -191,11 +191,12 @@ elseif(IOS)
XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "YES"
)

setup_pod_headers(
setup_spm_headers(
firebase_analytics
POD_NAMES
MODULES
FirebaseCore
FirebaseAnalytics
GoogleAppMeasurement
)

if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks")
Expand Down
15 changes: 6 additions & 9 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,10 @@ elseif(IOS)
# Xcode 14 and is completely unsupported by modern Swift toolchains.
target_compile_options(firebase_app
PUBLIC $<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fobjc-arc>)
# Add empty include path to get root include folder '.'
setup_pod_headers(
setup_spm_headers(
firebase_app
POD_NAMES
.
MODULES
FirebaseCore
FirebaseInstanceID
)
else()
target_link_libraries(firebase_app
Expand Down Expand Up @@ -469,10 +466,10 @@ if (IOS)
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/transaction.h
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/transaction_options.h
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/write_batch.h
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/core/include/firebase/firestore/firestore_errors.h
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/core/include/firebase/firestore/firestore_version.h
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/core/include/firebase/firestore/geo_point.h
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/core/include/firebase/firestore/timestamp.h)
${FIREBASE_SPM_CHECKOUTS_DIR}/firebase-ios-sdk/Firestore/core/include/firebase/firestore/firestore_errors.h
${FIREBASE_SPM_CHECKOUTS_DIR}/firebase-ios-sdk/Firestore/core/include/firebase/firestore/firestore_version.h
${FIREBASE_SPM_CHECKOUTS_DIR}/firebase-ios-sdk/Firestore/core/include/firebase/firestore/geo_point.h
${FIREBASE_SPM_CHECKOUTS_DIR}/firebase-ios-sdk/Firestore/core/include/firebase/firestore/timestamp.h)
set(functions_HDRS
${FIREBASE_SOURCE_DIR}/functions/src/include/firebase/functions.h
${FIREBASE_SOURCE_DIR}/functions/src/include/firebase/functions/callable_reference.h
Expand Down
10 changes: 5 additions & 5 deletions app_check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ target_include_directories(firebase_app_check
${CMAKE_CURRENT_LIST_DIR}/src/include
PRIVATE
${FIREBASE_CPP_SDK_ROOT_DIR}
${FIREBASE_CPP_SDK_ROOT_DIR}/ios_pod/swift_headers
${FIREBASE_SPM_SWIFT_HEADERS_DIR}
)
target_compile_definitions(firebase_app_check
PRIVATE
Expand All @@ -171,13 +171,13 @@ elseif(IOS)
target_link_libraries(firebase_app_check
PUBLIC "-fembed-bitcode")

setup_pod_headers(
setup_spm_headers(
firebase_app_check
POD_NAMES
INCLUDE_PRIVATE_HEADERS
MODULES
FirebaseCore
FirebaseAppCheck
FirebaseAppCheckInterop/FirebaseAppCheck/Interop
INCLUDE_PRIVATE_HEADERS
FirebaseAppCheckInterop
)

if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks")
Expand Down
8 changes: 4 additions & 4 deletions auth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ target_include_directories(firebase_auth
${CMAKE_CURRENT_LIST_DIR}/src/include
PRIVATE
${FIREBASE_CPP_SDK_ROOT_DIR}
${FIREBASE_CPP_SDK_ROOT_DIR}/ios_pod/swift_headers
${FIREBASE_SPM_SWIFT_HEADERS_DIR}
${additional_include_DIR}
)
target_compile_definitions(firebase_auth
Expand All @@ -191,12 +191,12 @@ elseif(IOS)
target_link_libraries(firebase_auth
PUBLIC "-fembed-bitcode")

setup_pod_headers(
setup_spm_headers(
firebase_auth
POD_NAMES
MODULES
FirebaseCore
FirebaseAuth
FirebaseAuthInterop/FirebaseAuth/Interop
FirebaseAuthInterop
)
if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks")
set_target_properties(firebase_auth PROPERTIES
Expand Down
9 changes: 3 additions & 6 deletions build_scripts/ios/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ if [[ -z $(xcode-select -p) || ! -d $(xcode-select -p) ]]; then
exit 1
fi

if [[ -z $(which pod) ]]; then
echo "Cocoapods not detected, installing..."
sudo gem install cocoapods
if [[ -z $(which swift) ]]; then
echo "Error, swift compiler not installed or not in PATH."
exit 1
fi

echo "Updating Cocoapods repo..."
pod repo update

9 changes: 3 additions & 6 deletions build_scripts/tvos/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ if [[ -z $(xcode-select -p) || ! -d $(xcode-select -p) ]]; then
exit 1
fi

if [[ -z $(which pod) ]]; then
echo "Cocoapods not detected, installing..."
sudo gem install cocoapods
if [[ -z $(which swift) ]]; then
echo "Error, swift compiler not installed or not in PATH."
exit 1
fi

echo "Updating Cocoapods repo..."
pod repo update

3 changes: 1 addition & 2 deletions cmake/external/firestore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ endif()

# If the format of the line below changes, then be sure to update
# https://github.com/firebase/firebase-cpp-sdk/blob/fd054fa016/.github/workflows/update-dependencies.yml#L81
#set(version CocoaPods-11.8.1)
set(version CocoaPods-12.19.0)
set(version 12.19.0)

function(GetReleasedDep)
message("Getting released firebase-ios-sdk @ ${version}")
Expand Down
4 changes: 2 additions & 2 deletions database/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ elseif(IOS)
target_link_libraries(firebase_database
PUBLIC "-fembed-bitcode")

setup_pod_headers(
setup_spm_headers(
firebase_database
POD_NAMES
MODULES
FirebaseCore
FirebaseDatabase
)
Expand Down
Loading
Loading