Skip to content

Commit 1faa9c5

Browse files
committed
Change where the iOS header files are found, to support newer versions of Cocoapods
Newer versions of Cocoapods do not copy header files from Pods that use frameworks. In order to reference those header files, change the logic for those to reference the headers in the framework, or for AdMob, set up a symlink because the headers are expected to be in a subfolder (that older versions of Cocoapods do set up) PiperOrigin-RevId: 273823051
1 parent 444f084 commit 1faa9c5

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

admob/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ if(IOS)
129129
PRIVATE
130130
${base_header_dir}/Google-Mobile-Ads-SDK
131131
)
132+
string(CONCAT google_mobile_ads_framework_path
133+
"${pods_dir}/Pods/Google-Mobile-Ads-SDK/"
134+
"Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.framework")
135+
# AdMob expects the header files to be in a subfolder, so set up a symlink to
136+
# accomplish that.
137+
symlink_framework_headers(firebase_admob ${pod_target_name}
138+
${google_mobile_ads_framework_path} GoogleMobileAds
139+
)
132140

133141
# Add a dependency to downloading the headers onto admob.
134142
add_dependencies(firebase_admob ${pod_target_name})

analytics/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,12 @@ if(IOS)
139139

140140
# Add the Cocoapod headers to the include directories
141141
set(base_header_dir "${pods_dir}/Pods/Headers/Public")
142+
set(analytics_framework_path
143+
"${pods_dir}/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework")
142144
target_include_directories(firebase_analytics
143145
PRIVATE
144146
${base_header_dir}/FirebaseCore
145-
${base_header_dir}/FirebaseAnalytics/FirebaseAnalytics
147+
${analytics_framework_path}/Headers
146148
)
147149

148150
# Add a dependency to downloading the headers onto analytics.

cmake/download_pod_headers.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,33 @@ function(setup_pod_headers_target TARGET_NAME POD_DIR POD_LIST)
7777
)
7878

7979
endfunction()
80+
81+
# Creates a symlink to the header files of the given framework. Used when
82+
# include paths are expecting the header files to be in a subdirectory, when
83+
# accessing the header files directly does not have them in the same structure.
84+
#
85+
# Args:
86+
# LIBRARY_TARGET: The library to add the include directory to.
87+
# DOWNLOAD_POD_TARGET: The target that downloads the pod files which will
88+
# contain the framework. From the above function.
89+
# FRAMEWORK_PATH: The full path to the framework.
90+
# SYMLINK_NAME: The name of the symlink to use. Usually the framework name.
91+
function(symlink_framework_headers LIBRARY_TARGET DOWNLOAD_POD_TARGET
92+
FRAMEWORK_PATH SYMLINK_NAME)
93+
# Guarantee the directory exists
94+
set(HEADER_DIR "${PROJECT_BINARY_DIR}/FrameworkHeaders")
95+
file(MAKE_DIRECTORY "${HEADER_DIR}")
96+
97+
# Create a symlink to the headers
98+
add_custom_command(TARGET ${DOWNLOAD_POD_TARGET}
99+
POST_BUILD
100+
COMMAND ln -sf ${FRAMEWORK_PATH}/Headers ${HEADER_DIR}/${SYMLINK_NAME}
101+
COMMENT "Setting up the framework header directory for ${SYMLINK_NAME}."
102+
)
103+
104+
# Add the symlink directory to the list of includes
105+
target_include_directories(${LIBRARY_TARGET}
106+
PRIVATE
107+
${HEADER_DIR}
108+
)
109+
endfunction()

remote_config/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ if(IOS)
140140
target_include_directories(firebase_remote_config
141141
PRIVATE
142142
${base_header_dir}/FirebaseCore
143-
${base_header_dir}/FirebaseRemoteConfig/FirebaseRemoteConfig
143+
${base_header_dir}/FirebaseRemoteConfig
144144
)
145145

146146
# Add a dependency to downloading the headers onto remote_config.

0 commit comments

Comments
 (0)