+ Add PostBuild tool for iOS PrivacyInfo.
parent
30c33f8ec9
commit
913dcf7495
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c29eec7a52a4f8a9e8638eaa0985442
|
||||
timeCreated: 1715317220
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
#if UNITY_IOS
|
||||
|
||||
namespace Guru.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public class IOSPostProcessBuild_PrivacyInfo
|
||||
{
|
||||
private const string XCPrivacyInfo = "PrivacyInfo.xcprivacy";
|
||||
private const string DefaultWorkdir = "Guru/BuildTools/Editor/IOS_POST_PRIVACYINFO";
|
||||
private const string SourceFileName = "PrivacyInfo.plist";
|
||||
private static string IosPrivacyInfoPath => $"{Application.dataPath}/Plugins/iOS/{SourceFileName}";
|
||||
|
||||
[PostProcessBuild(200)]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string buildPath)
|
||||
{
|
||||
if (target == BuildTarget.iOS)
|
||||
{
|
||||
AddPrivacyInfo(buildPath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向 XCode 添加隐私清单文件
|
||||
/// </summary>
|
||||
/// <param name="buildPath"></param>
|
||||
private static void AddPrivacyInfo(string buildPath)
|
||||
{
|
||||
if (CheckEvn())
|
||||
{
|
||||
var xcprojPath = PBXProject.GetPBXProjectPath(buildPath);
|
||||
var xcproj = new PBXProject();
|
||||
xcproj.ReadFromFile(xcprojPath);
|
||||
|
||||
var dest = $"{buildPath}/{XCPrivacyInfo}";
|
||||
FileUtil.ReplaceFile(IosPrivacyInfoPath, dest);
|
||||
|
||||
var mainTarget = xcproj.GetUnityMainTargetGuid();
|
||||
var guid = xcproj.AddFile(dest,$"{XCPrivacyInfo}", PBXSourceTree.Source);
|
||||
|
||||
xcproj.AddFileToBuild(mainTarget, guid);
|
||||
xcproj.WriteToFile(xcprojPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Inject iOS PrivacyInfo failed!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工作目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetWorkdir()
|
||||
{
|
||||
var guids = AssetDatabase.FindAssets($"{nameof(IOSPostProcessBuild_PrivacyInfo)}");
|
||||
if (guids.Length > 0)
|
||||
{
|
||||
var path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
var dir = Directory.GetParent(path).FullName;
|
||||
if (Directory.Exists(dir)) return dir;
|
||||
}
|
||||
return DefaultWorkdir;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查环境
|
||||
/// </summary>
|
||||
private static bool CheckEvn()
|
||||
{
|
||||
if (File.Exists(IosPrivacyInfoPath)) return true;
|
||||
|
||||
var workdir = GetWorkdir();
|
||||
var source = $"{workdir}/{SourceFileName}";
|
||||
if (File.Exists(source))
|
||||
{
|
||||
FileUtil.ReplaceFile(source, IosPrivacyInfoPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
Debug.LogError($"--- PrivacyInfo.plist not found,Check file path:{source}");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3405624b18974efa8564223e50bf0c55
|
||||
timeCreated: 1713372443
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<true/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array>
|
||||
<string>https://consent.adjust.com</string>
|
||||
<string>https://consent.adjust.net.in</string>
|
||||
<string>https://consent.adjust.world</string>
|
||||
<string>https://consent.adjust.cn</string>
|
||||
<string>https://consent.eu.adjust.com</string>
|
||||
<string>https://consent.tr.adjust.com</string>
|
||||
<string>https://consent.us.adjust.com</string>
|
||||
</array>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>CA92.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>C617.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeDeviceID</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<true/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeAdvertisingData</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<true/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<true/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeProductInteraction</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<true/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeOtherDataTypes</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeCrashData</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeOtherUsageData</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeAdvertisingData</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeDeviceID</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<true/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<true/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyCollectedDataType</key>
|
||||
<string>NSPrivacyCollectedDataTypeUserID</string>
|
||||
<key>NSPrivacyCollectedDataTypeLinked</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypeTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyCollectedDataTypePurposes</key>
|
||||
<array>
|
||||
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
|
||||
<string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f04c7fe558ae4a1bbb278ed19c5be0f2
|
||||
timeCreated: 1715315327
|
||||
Loading…
Reference in New Issue