@@ -177,7 +177,7 @@ public string PodFilePodLine {
177
177
/// reference.</param>
178
178
public Pod ( string name , string version , bool bitcodeEnabled , string minTargetSdk ,
179
179
bool addToAllTargets , IEnumerable < string > sources ,
180
- Dictionary < string , string > propertiesByName ) {
180
+ Dictionary < string , string > propertiesByName ) , {
181
181
this . name = name ;
182
182
this . version = version ;
183
183
if ( propertiesByName != null ) {
@@ -540,7 +540,11 @@ protected override bool Read(string filename, Logger logger) {
540
540
541
541
// Default iOS target SDK if the selected version is invalid.
542
542
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.
544
548
private static Regex TARGET_SDK_REGEX = new Regex ( "^[0-9]+\\ .[0-9]$" ) ;
545
549
546
550
// Current window being used for a long running shell command.
@@ -1426,7 +1430,7 @@ public static void UpdateTargetSdk(bool runningBuild) {
1426
1430
DialogWindow . Display (
1427
1431
"Unsupported Target SDK" ,
1428
1432
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 " +
1430
1434
"the Cocoapods included in this project. The build will very likely fail. " +
1431
1435
"The minimum supported version is \" {1}\" required by pods ({2})\n " +
1432
1436
"Would you like to update the target SDK version?" ,
@@ -1495,62 +1499,59 @@ public static string GetProjectPath(string relativeTo) {
1495
1499
}
1496
1500
1497
1501
/// <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 .
1500
1504
/// </summary>
1501
1505
static string TargetSdk {
1502
1506
get {
1503
1507
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 (
1507
1511
"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" ) ;
1515
1512
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 ) ;
1522
1514
}
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 ( "_" , "." ) ;
1523
1530
}
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 ( "_" , "." ) ;
1537
1531
}
1538
1532
1539
1533
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" ) ;
1545
1538
osVersionProperty . SetValue ( null , value , null ) ;
1546
1539
} 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
+ }
1554
1555
}
1555
1556
}
1556
1557
}
@@ -2202,8 +2203,11 @@ public static void GenPodfile(BuildTarget buildTarget,
2202
2203
verbose : true ) ;
2203
2204
2204
2205
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
+
2207
2211
foreach ( var target in XcodeTargetNames ) {
2208
2212
file . WriteLine ( String . Format ( "target '{0}' do" , target ) ) ;
2209
2213
foreach ( var pod in pods . Values ) {
0 commit comments