////////////////////////////////////////////////////////////////////////////////
//
// @module IOS Deploy
// @author Stanislav Osipov (Stan's Assets)
// @support support@stansassets.com
//
////////////////////////////////////////////////////////////////////////////////
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using SA.Foundation.Localization;
using StansAssets.Plugins;
namespace StansAssets.IOS.XCode
{
///
/// Xcode projects settings object.
/// Through it you can get access to all frameworks, libraries plist.list variables and others settings.
///
public class XCodeProjectSettings : PackageScriptableSettingsSingleton
{
///
/// Name of the package.
///
public override string PackageName => XCodePackage.PackageName;
protected override bool IsEditorOnly => true;
public const string DefaultEntitlementsFileName = "default.entitlements";
public const string CfLocalizationsPlistKey = "CFBundleLocalizations";
//Post Process Libs
///
/// Entry point for all frameworks in the xcode project.
///
public List Frameworks = new List();
///
/// List of all embedded frameworks in the xcode project.
///
public List EmbededFrameworks = new List();
///
/// List of all libraries in the xcode project.
///
public List Libraries = new List();
///
/// List of all flags in the xcode project.
///
public List Flags = new List();
///
/// List of info plist variables in the xcode project.
///
public List PlistVariables = new List();
///
/// List of plist id's variables in the xcode project.
///
public List VariableDictionary = new List();
///
/// List of all languages in the xcode project.
///
public List Languages = new List();
///
/// Entry point for all shell scripts in the xcode project.
///
public List ShellScripts = new List();
[SerializeField]
List m_BuildProperties = new List();
///
/// Is Post Process Enabled.
///
public static bool PostProcessEnabled
{
get
{
#if ISD_DISABLED
return false;
#endif
return true;
}
}
///
/// Capability Settings.
///
public XCodeCapabilitySettings Capability = new XCodeCapabilitySettings();
///
/// Xcode assets.
///
public List Files = new List();
public EntitlementsGenerationMode EntitlementsMode = EntitlementsGenerationMode.Automatic;
public Object EntitlementsFile = null;
//--------------------------------------
// Variables
//--------------------------------------
///
/// Method for adding new variable into VariableDictionary list.
///
/// Unique id key
/// Info plist key value
public void AddVariableToDictionary(string uniqueIdKey, InfoPlistKey var)
{
var newVar = new PlistKeyId();
newVar.uniqueIdKey = uniqueIdKey;
newVar.VariableValue = var;
VariableDictionary.Add(newVar);
}
///
/// Method that removes info plist key from VariableDictionary list.
///
/// Info plist key value.
///
public void RemoveVariable(InfoPlistKey v, IList listWithThisVariable)
{
if (Instance.PlistVariables.Contains(v))
Instance.PlistVariables.Remove(v);
else
foreach (var vid in VariableDictionary)
if (vid.VariableValue.Equals(v))
{
VariableDictionary.Remove(vid);
var id = vid.uniqueIdKey;
if (listWithThisVariable.Contains(id))
listWithThisVariable.Remove(vid.uniqueIdKey);
break;
}
//remove junk
var keysInUse = new List(VariableDictionary);
foreach (var id in VariableDictionary)
{
var isInUse = IsInUse(id.uniqueIdKey, PlistVariables);
if (!isInUse) keysInUse.Remove(id);
}
VariableDictionary = keysInUse;
}
///
/// Method that returns does list contains children with given key.
///
/// Id that we want to check for.
/// List of info plist in which we what to check.
///
bool IsInUse(string id, List list)
{
foreach (var key in list)
if (key.ChildrenIds.Contains(id))
{
return true;
}
else
{
var inUse = IsInUse(id, key.Children);
if (inUse) return true;
}
return false;
}
///
/// Method that returns info plist key by given key id.
///
/// Uniques id
/// InfoPlistKey or null if we couldn't find any.
public InfoPlistKey GetVariableById(string uniqueIdKey)
{
foreach (var vid in VariableDictionary)
if (vid.uniqueIdKey.Equals(uniqueIdKey))
return vid.VariableValue;
return null;
}
//--------------------------------------
// Build Properties
//--------------------------------------
///
/// List of project build properties.
///
public List BuildProperties
{
get
{
if (m_BuildProperties.Count == 0)
{
var property = new XCodeProjectProperty("ENABLE_BITCODE", "NO");
m_BuildProperties.Add(property);
property = new XCodeProjectProperty("ENABLE_TESTABILITY", "NO");
m_BuildProperties.Add(property);
property = new XCodeProjectProperty("GENERATE_PROFILING_CODE", "NO");
m_BuildProperties.Add(property);
}
return m_BuildProperties;
}
}
}
}