Copy file to root of Xcode project when building

后端 未结 2 1598
隐瞒了意图╮
隐瞒了意图╮ 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-11 23:52

    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?

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题