mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
// ---------------------------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2024, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
#if UNITY_EDITOR_OSX && UNITY_IOS
|
|
|
|
namespace Build.Editor
|
|
{
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEditor.Callbacks;
|
|
using UnityEditor.iOS.Xcode;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Enable iOS UIFileSharing in XCode project settings (Info.plist)
|
|
/// </summary>
|
|
public static class EnableFileSharingPostBuildProcessor
|
|
{
|
|
[PostProcessBuild]
|
|
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
|
|
{
|
|
if (buildTarget != BuildTarget.iOS) return; // Only for iOS
|
|
|
|
// Get plist
|
|
string plistPath = pathToBuiltProject + "/Info.plist";
|
|
PlistDocument plist = new PlistDocument();
|
|
plist.ReadFromString(File.ReadAllText(plistPath));
|
|
|
|
// Get root
|
|
PlistElementDict rootDict = plist.root;
|
|
|
|
rootDict.SetBoolean("UIFileSharingEnabled", true);
|
|
|
|
// Write to file
|
|
File.WriteAllText(plistPath, plist.WriteToString());
|
|
|
|
Debug.Log("UIFileSharingEnabled set to YES.");
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |