赞
踩
var pbxProject = new PBXProject();
var projectPath = PBXProject.GetPBXProjectPath(iosProjectPath);
pbxProject.ReadFromFile(projectPath);
- GetUnityMainTargetGuid是获取XCode工程中"Unity-iPhone"对应的target,GetUnityFrameworkTargetGuid则对应"UnityFramework"
-
- var mainTargetGuid = pbxProject.GetUnityMainTargetGuid();//
-
- //这个对应target中的Unity-iPhone
- var frameworkTargetGuid = pbxProject.GetUnityFrameworkTargetGuid();//
-
- //这个对应target中UnityFramework
- pbxProject.AddBuildProperty(mainTargetGuid, "OTHER_LDFLAGS", "-ObjC");
- pbxProject.AddBuildProperty(frameworkTargetGuid, "OTHER_LDFLAGS", "-ObjC");
-
- pbxProject.SetTeamId(mainTargetGuid, "");
- pbxProject.SetTeamId(frameworkTargetGuid, "");
- pbxProject.SetBuildProperty(mainTargetGuid, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
- pbxProject.SetBuildProperty(frameworkTargetGuid, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
-
- pbxProject.SetBuildProperty(mainTargetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");
- pbxProject.SetBuildProperty(frameworkTargetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");
-
- pbxProject.SetBuildProperty(mainTargetGuid, "GCC_C_LANGUAGE_STANDARD", "gnu11");
- pbxProject.SetBuildProperty(frameworkTargetGuid, "GCC_C_LANGUAGE_STANDARD", "gnu11");
-
- pbxProject.AddFrameworkToProject(frameworkTargetGuid, "Photos.framework", false);
-
- // info.plist 设置
- var plistPath = Path.Combine(iosProjectPath, "Info.plist");
- var plist = new PlistDocument();
- plist.ReadFromString(File.ReadAllText(plistPath, Encoding.ASCII));
- plist.root.values.Add("NSPhotoLibraryUsageDescription", new PlistElementString("We will use this permission if the child sends lessons and feedback through the album."));
- plist.root.values.Add("ITSAppUsesNonExemptEncryption", new PlistElementBoolean(false));
- AddPlistElementDict(plist,"NSAppTransportSecurity","NSAllowsArbitraryLoads",new PlistElementBoolean(true));
File.WriteAllText(plistPath, plist.WriteToString());
- string pbxProjectPath = PBXProject.GetPBXProjectPath(path);
- pbxProject = new PBXProject();
- pbxProject.ReadFromString(File.ReadAllText(pbxProjectPath));
- mainTarget = pbxProject.GetUnityMainTargetGuid();//这个对应target中的Unity-iPhone
- frameworkTarget = pbxProject.GetUnityFrameworkTargetGuid();//这个对应target中UnityFramework
- //...
- //你的操作
- //...
- pbxProject.WriteToFile(pbxProjectPath); //操作完后要写回文件,否则无效
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。