Copy file to root of Xcode project when building

后端 未结 2 1600
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 23:41

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.p

2条回答
  •  时光说笑
    2020-12-12 00:05

    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:

    • Add this script to the end of your Build Phases
    • Change name CustomGoogleService-Info.plist to your own
    • Change pathToPlistHere to the correct path where CustomGoogleService-Info.plist is located (starting from your project directory)
    • You should not have GoogleService-Info.plist file in your project - the script will create it for you.
    • Grab a coffee while it is running

    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.

提交回复
热议问题