Fahim
Fahim

Reputation: 1431

iOS Google Tag Manager Integration: How to add multiple containers per App environment?

I completed the integration of the latest Google Tag Manager (v5) for iOS together with Firebase (https://developers.google.com/tag-manager/ios/v5/). The big change here is that the default container file is not binary anymore, it is plain JSON.

The integration requires that you have a folder (not group!) with the name "container" inside your app workspace. Within this folder the container file should be located. This raises my issue: We have two different GTM Containers, one for the testing/development app and one for production.

Does anybody have an idea how this can be solved?

Thanks, Fahim

enter image description here

Upvotes: 5

Views: 2885

Answers (2)

Fahim
Fahim

Reputation: 1431

Sample Run Script (if somebody has the same issue):

rm -vf ${SRCROOT}/root_folder/container/*
cp "${SRCROOT}/root_folder/target/test/GTM-XXXXX.json" "${SRCROOT}/root_folder/container/"

It is important that this copy job is done at first within Build Phases, otherwise some other precompiling stuff of GTM does not recognize the container.

Upvotes: 5

Eric Burley
Eric Burley

Reputation: 576

You should be able to configure an XCode "run script" build step that clears the container directory and copies the correct container into place.

Upvotes: 5

Related Questions