Reputation: 9590
I am trying to implement Google Analytics (GA) in my iOS apps. I have two different targets that have different tracking-ids for GA. GA requires a GoogleService-Info.plist
(cannot be renamed) file to be placed in the root of the app folder structure. This file contains the tracking-id. However, since I have two different targets I need to have two different tracking-ids.
I cannot have two file named to files with the same name with different targets.
So, is there a way to either copy another file into the root in the build process. Have tried this and similar but does not seem to work:
Any suggestions?
Upvotes: 3
Views: 3837
Reputation: 3783
The script:
PLIST_FILE="CustomGoogleService-Info.plist"
PLIST_PATH="${PROJECT_DIR}/path/To/Plist/Here/${PLIST_FILE}"
cp "${PLIST_PATH}" "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/GoogleService-Info.plist"
Instructions:
Build Phases
CustomGoogleService-Info.plist
to your ownpathToPlistHere
to the correct path where CustomGoogleService-Info.plist
is located (starting from your project directory)GoogleService-Info.plist
file in your project - the script will create it for you.You may be interested in reading Apple's Xcode Build Setting Reference
Alternatively:
You could have 2 files with the name GoogleService-Info.plist
, but keep each in separate directory. Then you could add each to the corresponding target. Without any script.
Upvotes: 11
Reputation: 9590
I did correctly all along, however Destination
should be set to Wrapper
and subpath empty. No need to have them in the target either.
This one explained the Destination options: xcode copy files build phase - what do the destination options mean exactly?
Upvotes: 1