The iOS SKAdNetwork ID auto updater is a tool for publishers to integrate into their build system and manage SKAdnetwork IDs into their Info.plist with each build job automatically. This will allow them to keep the Info.plist file up to date, even if some partners make changes to their IDs.
In the following there are instructions how to build the tool, deploy and integrate into XCode and Unity Editor.
Installing the Tool
The tool resides in the open source repository. For full instructions, refer to the READ.ME.md file.
There are several methods to install the tool:
Via Homebrew (Preferred)
Add our Tap
brew tap fyber-engineering/skad_updater
Install the Application
brew install skad_updater
Download the Release Tar File
You may want to download a specific version from here.
Select a release version and download the tar.gz file.
Extract the file content of the file to your folder of your choice:
tar -xzf skad_updater-.tar.gz -C [folder-name]
Now, you can use the executable inside the inner 'bin' folder.
You may want to put it in a path that’s supported by your own $PATH variable, in order to make 'skad_updater' work globally.
Compile from source.
Compiling the Source Code
All the commands must be run from the repository's base folder.
Prerequisites
- macOS 10.15
- curl
- omake 3.18
- python 3.8
- clang-format
Automatic
./clean
./build
Manual
./clean
cmake -S . -B build
cmake --build build --target format
cmake --build build --target fix-format
cmake --build build --target skad_updater
Running Tests
Prerequisites
- Ensure curl is installed
- Ensure you have python 3.8 installed
- Create a virtual env under tests/servermock and run pip install -r requirements.txt
Testing
cmake --build build --target tests_run
cd build/tests/
./tests_run
Package
Generate a tar.gz file in the build directory.
cmake --build build --target package
Utilizing the Tool
Synopsis
skad_updater ( (--help | -h) | (--show_networks) |
--plist_file_path [plist-file-path] (--network_list
[comma-separated-network-names] | --pod_file_path [pod-file-path])
[--dry_run] )
The list of required networks can be requested in several ways:
Explicit
- Requesting a list of supported ad network names with the --show_networks flag
- Passing the [--network_list <network-name-list>] parameter with a list of network names separated with a comma
Automatic
Automatically derives the requiring networks from a pod file by using the [--pod_file_path<pod-file-path>] parameter where <pod-file-path> is the path to the pod file.
Combination
Combing the automatically derived networks from the pod file and an explicit network list, by using both the [--pod_file_path<pod-file-path>] and the [--network_list<network-name-list>] parameters.
Parameters
Parameter | Value | Description |
---|---|---|
--plist_file_path | <plist-file-path> | The plist file path |
--network_list | <comma-separated-network-names> | Request for a specific list of networks to update. The argument is a comma separated list of network names. These network names can be used in combination with the networks found in the pod file. |
--pod_file_path | <pod-file-path> | Update all the networks found in the pod file. The argument is the path to the pod file. The network not mentioned in the pod file can still be updated if provided in the --network_list argument in addition. |
Optional Parameters
Parameter | Value | Description |
---|---|---|
--dry_run | - | Perform a dry run. Prints out the new plist file instead of overwriting. |
--show_networks | - | Show the list of supported network names. |
--help, -h | - | Provide a help message and exit |
Examples
skad_updater --help |
skad_updater --show_networks |
skad_updater --plist_file_path <Path to plist> --pod_file_path <Path to Pod File> --dry_run |
skad_updater --plist_file_path <Path to plist> --pod_file_path <Path to Pod File> |
skad_updater --plist_file_path <Path to plist> --network_list <CSV network list> --dry_run |
skad_updater --plist_file_path <Path to plist> --network_list <CSV network list> |
skad_updater --plist_file_path <Path to plist> --network_list <CSV network list> |
--pod_file_path <Path to Pod File> --dry_run |
skad_updater --plist_file_path <Path to plist> --network_list <CSV network list> --pod_file_path <Path to Pod File> |
Backups
Current/Previous info.plist is backed up to the info.plist.back.X in the same directory in cases where the plist is modified - X represents the number of the backup.
Reformatting the plist File
After new networks were added, the plist file will be formatted according to the standard XML indentation formatting. The xcode PList indentation formatting might differ from the standard XML's, but they work the same.
Making a modification to the plist inside xcode will reformat it back to the xcode standard, Which might result in weird pull-request diffs.
If this is an issue for you, you can run this after the skad_updater to reformat according to the xcode standard:
plutil -convert xml1 [path_to_plist_file]
Man Page
To read the usage instructions from the terminal, use the manpage:
$ man skad_updater
Integrating into a Build Environment with Cocoapods
iOS
- Open your Xcode project
- Select the project from the project navigator to open the project editor
- Click the Build Phases button at the top of the project editor.
You must to this to enable the build phase menu items
After clicking the Build Phases button at the top of the project editor you can add build phases by clicking the Add button in the project editor or choosing Editor -> Add Build Phase
Choose a Run Script Phase and add the following shell script:
echo "$INFOPLIST_FILE" | sed 's/ /\\ /g' | (read SANITIZED_PATH; skad_updater --plist_file_path "$SANITIZED_PATH" --network_list=FairBidSDK --pod_file_path ./Podfile; plutil -convert xml1 "$SANITIZED_PATH")
Now build your project and skad_updater updates your info.plist file.
Unity
Once you export the Xcode project from Unity, you can follow the steps above in order to add a Build Phase to Xcode, which will update the `Info.plist` file.
You can also take advantage of Unity's scripting APIs to add the Build Phase automatically to the generated Xcode project.
This can be achieved by adding a script file to Assets/Editor folder, as in the example below:
using UnityEditor;
using UnityEditor.iOS.Xcode;
using UnityEditor.Callbacks;
public static class SKAdNetworkUpdater
{
[PostProcessBuild(1)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget != BuildTarget.iOS)
{
return;
}
string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);
#if UNITY_2019_3_OR_NEWER
string targetGUID = pbxProject.GetUnityMainTargetGuid();
#else
string targetGUID = pbxProject.TargetGuidByName("Unity-iPhone");
#endif
string shellPath = "/bin/sh";
int index = 0;
string name = "Update SKAdNetwork ids";
string shellScript = @"echo ""$INFOPLIST_FILE"" | sed 's/ /\\ /g' | (read SANITIZED_PATH; skad_updater --plist_file_path ""$SANITIZED_PATH"" --network_list=FairBidSDK --pod_file_path ./Podfile; plutil -convert xml1 ""$SANITIZED_PATH"")";
pbxProject.InsertShellScriptBuildPhase(index, targetGUID, name, shellPath, shellScript);
pbxProject.WriteToFile(projectPath);
}
}
Integrating into a Build Environment without Cocoapods
If you're not using Cocoapods to manage dependencies, the steps to integrate the SKAdNetwork ID Auto Updater tool are the same as described above. The only difference is that instead of passing the pod_file_path parameter in the script, you use network_list to provide a comma separated list of network names.