example
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
namespace Framework.SDK
{
public class PostprocessBuildForPhoto
{
[PostProcessBuild(500)]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if(target != BuildTarget.iOS) return;
// framework
string projPath = PBXProject.GetPBXProjectPath(path);
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
string targetGuid = proj.TargetGuidByName("Unity-iPhone");
//1、修改设置
//添加系统库
// GUID framework名 设置framework是require还是optional
// True if the framework is optional (i.e. weakly linked), false if the framework is required.
proj.AddFrameworkToProject(targetGuid,"AdSupport.framework", false);
proj.AddFrameworkToProject(targetGuid,"AppTrackingTransparency.framework", false);
File.WriteAllText(projPath, proj.WriteToString());
// 修改Info.plist文件
string plistPath = Path.Combine(path, "Info.plist");
PlistDocument plist = new PlistDocument();
plist.ReadFromFile(plistPath);
plist.root.SetString("NSPhotoLibraryAddUsageDescription", "");
plist.root.SetString("NSUserTrackingUsageDescription","");
plist.WriteToFile(plistPath);
}
}
}