- Home /
Question by
Vortexboy · Jan 02, 2019 at 03:17 AM ·
iosxcodeautomationbuildsettings
How to automatically modify the settings in Xcode
How to automatically modify the "Launch Screen File" in Xcode to automatically specify the file.
[Serializable]
[LabelText("iOS")]
public class IosCommonSetting : PlatformCommonSetting
{
public string build;
[FilePath(AbsolutePath = true)]
public string plistPath;
[FilePath(AbsolutePath = true)]
public string xibPath;
public override void Apply()
{
base.Apply();
PlayerSettings.iOS.buildNumber = build;
if (!string.IsNullOrEmpty(plistPath))
{
AutoBuilder.current.onBuildSucceed -= ModifyPlist;
AutoBuilder.current.onBuildSucceed += ModifyPlist;
}
if (!string.IsNullOrEmpty(xibPath))
{
AutoBuilder.current.onBuildSucceed -= ModifyXib;
AutoBuilder.current.onBuildSucceed += ModifyXib;
}
}
private void ModifyPlist()
{
//Here I implemented the configuration of modifying the "plist"
#if UNITY_IOS
var plist = new UnityEditor.iOS.Xcode.PlistDocument();
plist.ReadFromFile(plistPath);
plist.root.SetString("CFBundleShortVersionString", version);
plist.root.SetString("CFBundleVersion", build);
plist.WriteToFile(string.Format("{0}/Info.plist", AutoBuilder.current.outputPath));
#endif
}
private void ModifyXib()
{
//I need to add an automatic modification to the file specified by "Launch Screen File" in Xcode.
#if UNITY_IOS
var path = File.ReadAllLines(xibPath);
File.WriteAllLines(string.Format("{0}/LaunchScreen-iPad.xib", AutoBuilder.current.outputPath), path);
#endif
}
}
Comment