Skip to content

Commit 9a7c264

Browse files
committed
first attempt to generate tvOS podfiles
1 parent 5c6f23b commit 9a7c264

File tree

1 file changed

+52
-48
lines changed

1 file changed

+52
-48
lines changed

source/IOSResolver/src/IOSResolver.cs

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public string PodFilePodLine {
177177
/// reference.</param>
178178
public Pod(string name, string version, bool bitcodeEnabled, string minTargetSdk,
179179
bool addToAllTargets, IEnumerable<string> sources,
180-
Dictionary<string, string> propertiesByName) {
180+
Dictionary<string, string> propertiesByName), {
181181
this.name = name;
182182
this.version = version;
183183
if (propertiesByName != null) {
@@ -540,7 +540,11 @@ protected override bool Read(string filename, Logger logger) {
540540

541541
// Default iOS target SDK if the selected version is invalid.
542542
private const int DEFAULT_TARGET_SDK = 82;
543-
// Valid iOS target SDK version.
543+
544+
// Default tvOS target SDK if the selected version is invalid.
545+
private const string DEFAULT_TVOS_TARGET_SDK = "12.0"
546+
547+
// Valid iOS / tvOS target SDK version.
544548
private static Regex TARGET_SDK_REGEX = new Regex("^[0-9]+\\.[0-9]$");
545549

546550
// Current window being used for a long running shell command.
@@ -1426,7 +1430,7 @@ public static void UpdateTargetSdk(bool runningBuild) {
14261430
DialogWindow.Display(
14271431
"Unsupported Target SDK",
14281432
String.Format(
1429-
"Target SDK selected in the iOS Player Settings ({0}) is not supported by " +
1433+
"Target SDK selected in the iOS/tvOS Player Settings ({0}) is not supported by " +
14301434
"the Cocoapods included in this project. The build will very likely fail. " +
14311435
"The minimum supported version is \"{1}\" required by pods ({2})\n" +
14321436
"Would you like to update the target SDK version?",
@@ -1495,62 +1499,59 @@ public static string GetProjectPath(string relativeTo) {
14951499
}
14961500

14971501
/// <summary>
1498-
/// Get or set the Unity iOS target SDK version string (e.g "7.1")
1499-
/// build setting.
1502+
/// Get or set the Unity iOS or tvOS target SDK version string (e.g "7.1")
1503+
/// build setting dependeding on the current active build target.
15001504
/// </summary>
15011505
static string TargetSdk {
15021506
get {
15031507
string name = null;
1504-
var iosSettingsType = typeof(UnityEditor.PlayerSettings.iOS);
1505-
// Read the version (Unity 5.5 and above).
1506-
var osVersionProperty = iosSettingsType.GetProperty(
1508+
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.tvOS) {
1509+
var tvosSettingsType = typeof(UnityEditor.PlayerSettings.tvOs);
1510+
var osVersionProperty = iosSettingsType.GetProperty(
15071511
"targetOSVersionString");
1508-
if (osVersionProperty != null) {
1509-
name = (string)osVersionProperty.GetValue(null, null);
1510-
}
1511-
if (name == null) {
1512-
// Read the version (deprecated in Unity 5.5).
1513-
osVersionProperty = iosSettingsType.GetProperty(
1514-
"targetOSVersion");
15151512
if (osVersionProperty != null) {
1516-
var osVersionValue =
1517-
osVersionProperty.GetValue(null, null);
1518-
if (osVersionValue != null) {
1519-
name = Enum.GetName(osVersionValue.GetType(),
1520-
osVersionValue);
1521-
}
1513+
name = (string)osVersionProperty.GetValue(null, null);
15221514
}
1515+
if (String.IsNullOrEmpty(name)) {
1516+
return DEFAULT_TVOS_TARGET_SDK;
1517+
}
1518+
return name.Trim().Replace("tvOS_", "").Replace("_", ".");
1519+
} else {
1520+
var iosSettingsType = typeof(UnityEditor.PlayerSettings.iOS);
1521+
var osVersionProperty = iosSettingsType.GetProperty(
1522+
"targetOSVersionString");
1523+
if (osVersionProperty != null) {
1524+
name = (string)osVersionProperty.GetValue(null, null);
1525+
}
1526+
if (String.IsNullOrEmpty(name)) {
1527+
return TargetSdkVersionToString(DEFAULT_TARGET_SDK);
1528+
}
1529+
return name.Trim().Replace("iOS_", "").Replace("_", ".");
15231530
}
1524-
if (String.IsNullOrEmpty(name)) {
1525-
// Versions 8.2 and above do not have enum symbols
1526-
// The values in Unity 5.4.1f1:
1527-
// 8.2 == 32
1528-
// 8.3 == 34
1529-
// 8.4 == 36
1530-
// 9.0 == 38
1531-
// 9.1 == 40
1532-
// Since these are undocumented just report
1533-
// 8.2 as selected for the moment.
1534-
return TargetSdkVersionToString(DEFAULT_TARGET_SDK);
1535-
}
1536-
return name.Trim().Replace("iOS_", "").Replace("_", ".");
15371531
}
15381532

15391533
set {
1540-
var iosSettingsType = typeof(UnityEditor.PlayerSettings.iOS);
1541-
// Write the version (Unity 5.5 and above).
1542-
var osVersionProperty =
1543-
iosSettingsType.GetProperty("targetOSVersionString");
1544-
if (osVersionProperty != null) {
1534+
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.tvOS) {
1535+
var tvosSettingsType = typeof(UnityEditor.PlayerSettings.tvOS);
1536+
var osVersionProperty =
1537+
tvosSettingsType.GetProperty("targetOSVersionString");
15451538
osVersionProperty.SetValue(null, value, null);
15461539
} else {
1547-
osVersionProperty =
1548-
iosSettingsType.GetProperty("targetOSVersion");
1549-
osVersionProperty.SetValue(
1550-
null,
1551-
Enum.Parse(osVersionProperty.PropertyType,
1552-
"iOS_" + value.Replace(".", "_")),
1553-
null);
1540+
var iosSettingsType = typeof(UnityEditor.PlayerSettings.iOS);
1541+
// Write the version (Unity 5.5 and above).
1542+
var osVersionProperty =
1543+
iosSettingsType.GetProperty("targetOSVersionString");
1544+
if (osVersionProperty != null) {
1545+
osVersionProperty.SetValue(null, value, null);
1546+
} else {
1547+
osVersionProperty =
1548+
iosSettingsType.GetProperty("targetOSVersion");
1549+
osVersionProperty.SetValue(
1550+
null,
1551+
Enum.Parse(osVersionProperty.PropertyType,
1552+
"iOS_" + value.Replace(".", "_")),
1553+
null);
1554+
}
15541555
}
15551556
}
15561557
}
@@ -2202,8 +2203,11 @@ public static void GenPodfile(BuildTarget buildTarget,
22022203
verbose: true);
22032204

22042205
using (StreamWriter file = new StreamWriter(podfilePath)) {
2205-
file.WriteLine(GeneratePodfileSourcesSection() +
2206-
String.Format("platform :ios, '{0}'\n", TargetSdk));
2206+
file.WriteLine(GeneratePodfileSourcesSection());
2207+
String platform_name = (EditorUserBuildSettings.activeBuildTarget == BuildTarget.tvOS) ?
2208+
"tvos" : "ios";
2209+
file.WriteLine(String.Format("platform :{0}}, '{1}'\n", platform_name, TargetSdk));
2210+
22072211
foreach (var target in XcodeTargetNames) {
22082212
file.WriteLine(String.Format("target '{0}' do", target));
22092213
foreach(var pod in pods.Values) {

0 commit comments

Comments
 (0)