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设置frameworkrequire还是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);
        }
    }
}

原文地址:https://blog.csdn.net/baidu_38392815/article/details/123089226

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_41636.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注