Forked from sanukin39/XcodeSettingsPostProcesser.cs
Created
February 25, 2021 02:39
-
-
Save moto2002/b5a575a30931cb2411dbf5ce91c7ebc9 to your computer and use it in GitHub Desktop.
Revisions
-
sanukin39 revised this gist
Jun 19, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -56,10 +56,10 @@ public static void OnPostprocessBuild (BuildTarget buildTarget, string pathToBui // Add URL Scheme var array = plist.root.CreateArray ("CFBundleURLTypes"); var urlDict = array.AddDict (); urlDict.SetString ("CFBundleURLName", "hogehogeName"); var urlInnerArray = urlDict.CreateArray ("CFBundleURLSchemes"); urlInnerArray.AddString ("hogehogeValue"); // Apply editing settings to Info.plist plist.WriteToFile (plistPath); -
sanukin39 created this gist
Jun 19, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ using System.IO; using UnityEngine; using UnityEditor; using UnityEditor.iOS.Xcode; using UnityEditor.Callbacks; using System.Collections; public class XcodeSettingsPostProcesser { [PostProcessBuildAttribute (0)] public static void OnPostprocessBuild (BuildTarget buildTarget, string pathToBuiltProject) { // Stop processing if targe is NOT iOS if (buildTarget != BuildTarget.iOS) return; // Initialize PbxProject var projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject pbxProject = new PBXProject (); pbxProject.ReadFromFile (projectPath); string targetGuid = pbxProject.TargetGuidByName ("Unity-iPhone"); // Sample of adding build property pbxProject.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-all_load"); // Sample of setting build property pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO"); // Sample of update build property pbxProject.UpdateBuildProperty(targetGuid, "OTHER_LDFLAGS", new string[]{"-ObjC"}, new string[]{"-weak_framework"}); // Sample of adding REQUIRED framwrok pbxProject.AddFrameworkToProject(targetGuid, "Security.framework", false); // Sample of adding OPTIONAL framework pbxProject.AddFrameworkToProject(targetGuid, "SafariServices.framework", true); // Sample of setting compile flags var guid = pbxProject.FindFileGuidByProjectPath("Classes/UI/Keyboard.mm"); var flags = pbxProject.GetCompileFlagsForFile(targetGuid, guid); flags.Add("-fno-objc-arc"); pbxProject.SetCompileFlagsForFile(targetGuid, guid, flags); // Apply settings File.WriteAllText (projectPath, pbxProject.WriteToString ()); // Samlpe of editing Info.plist var plistPath = Path.Combine (pathToBuiltProject, "Info.plist"); var plist = new PlistDocument (); plist.ReadFromFile (plistPath); // Add string setting plist.root.SetString ("hogehogeId", "dummyid"); // Add URL Scheme var array = plist.root.CreateArray ("CFBundleURLTypes"); var dmgDict = array.AddDict (); dmgDict.SetString ("CFBundleURLName", "hogehogeName"); var dmgInnerArray = dmgDict.CreateArray ("CFBundleURLSchemes"); dmgInnerArray.AddString ("hogehogeValue"); // Apply editing settings to Info.plist plist.WriteToFile (plistPath); } }