Last active
October 29, 2021 11:40
-
-
Save auycro/c671c5ae830588e89f70 to your computer and use it in GitHub Desktop.
Unity update info.plist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Copyright (c) 2015 Gumpanat Keardkeawfa | |
//Licensed under the MIT license | |
using System.IO; | |
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.Callbacks; | |
using UnityEditor.iOS.Xcode; | |
public static class XCodePostProcess | |
{ | |
[PostProcessBuild(100)] | |
public static void OnPostprocessBuild(BuildTarget target, string pathToBuildProject) { | |
if (target.ToString() == "iOS" || target.ToString() == "iPhone") { | |
UpdateInfoPlist(pathToBuildProject); | |
} | |
} | |
private static void UpdateInfoPlist(string path) { | |
//Get Plist | |
string plistPath = Path.Combine(path, "Info.plist"); | |
PlistDocument plist = new PlistDocument(); | |
plist.ReadFromString (File.ReadAllText (plistPath)); | |
//Get Root | |
PlistElementDict rootDict = plist.root; | |
//Add Necessary Things | |
PlistElementArray LSApplicationQueriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes"); | |
LSApplicationQueriesSchemes.AddString ("fb"); | |
LSApplicationQueriesSchemes.AddString ("instagram"); | |
LSApplicationQueriesSchemes.AddString ("tumblr"); | |
LSApplicationQueriesSchemes.AddString ("twitter"); | |
LSApplicationQueriesSchemes.AddString ("twitter"); | |
LSApplicationQueriesSchemes.AddString ("fbapi"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20130410"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20130702"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20131010"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20131219"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20140410"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20140116"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20150313"); | |
LSApplicationQueriesSchemes.AddString ("fbapi20150629"); | |
LSApplicationQueriesSchemes.AddString ("fbauth"); | |
LSApplicationQueriesSchemes.AddString ("fbauth2"); | |
LSApplicationQueriesSchemes.AddString ("fb-messenger-api20140430"); | |
PlistElementDict NSAppTransportSecurity = rootDict.CreateDict("NSAppTransportSecurity"); | |
NSAppTransportSecurity.SetBoolean("NSAllowsArbitraryLoads",true); | |
PlistElementDict NSExceptionDomains = NSAppTransportSecurity.CreateDict("NSExceptionDomains"); | |
PlistElementDict url1 = NSExceptionDomains.CreateDict ("akamaihd.net"); | |
url1.SetBoolean ("NSIncludesSubdomains",true); | |
url1.SetBoolean ("NSThirdPartyExceptionRequiresForwardSecrecy", false); | |
PlistElementDict url2 = NSExceptionDomains.CreateDict ("facebook.com"); | |
url2.SetBoolean ("NSIncludesSubdomains",true); | |
url2.SetBoolean ("NSThirdPartyExceptionRequiresForwardSecrecy", false); | |
PlistElementDict url3 = NSExceptionDomains.CreateDict ("fbcdn.net"); | |
url3.SetBoolean ("NSIncludesSubdomains",true); | |
url3.SetBoolean ("NSThirdPartyExceptionRequiresForwardSecrecy", false); | |
PlistElementDict url4 = NSExceptionDomains.CreateDict ("localhost"); | |
url4.SetBoolean ("NSExceptionAllowsInsecureHTTPLoads",true); | |
//WriteFile | |
File.WriteAllText (plistPath, plist.WriteToString ()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment