@@ -64,20 +64,23 @@ internal class XcodeProjectPatcher : AssetPostprocessor {
64
64
private static bool Enabled {
65
65
get {
66
66
return ( EditorUserBuildSettings . activeBuildTarget ==
67
- BuildTarget . iOS ) && Google . IOSResolver . Enabled ;
67
+ BuildTarget . iOS ||
68
+ EditorUserBuildSettings . activeBuildTarget ==
69
+ BuildTarget . tvOS ) && Google . IOSResolver . Enabled ;
68
70
}
69
71
}
70
72
71
73
static XcodeProjectPatcher ( ) {
72
- // Delay initialization until the build target is iOS and the editor is not in play
73
- // mode.
74
+ // Delay initialization until the build target is iOS+ and the
75
+ // editor is not in play mode.
74
76
EditorInitializer . InitializeOnMainThread (
75
77
condition : ( ) => {
76
- return EditorUserBuildSettings . activeBuildTarget == BuildTarget . iOS &&
78
+ return ( EditorUserBuildSettings . activeBuildTarget == BuildTarget . iOS ||
79
+ EditorUserBuildSettings . activeBuildTarget == BuildTarget . tvOS ) &&
77
80
! EditorApplication . isPlayingOrWillChangePlaymode ;
78
81
} , initializer : ( ) => {
79
82
// We attempt to read the config even when the target platform isn't
80
- // iOS as the project settings are surfaced in the settings window.
83
+ // iOS+ as the project settings are surfaced in the settings window.
81
84
Google . IOSResolver . RemapXcodeExtension ( ) ;
82
85
ReadConfigOnUpdate ( ) ;
83
86
PlayServicesResolver . BundleIdChanged -= OnBundleIdChanged ;
@@ -96,15 +99,19 @@ internal static void ReadConfigOnUpdate() {
96
99
ReadConfig ( errorOnNoConfig : false ) ;
97
100
}
98
101
99
- // Get the iOS bundle / application ID.
100
- private static string GetIOSApplicationId ( ) {
101
- return UnityCompat . GetApplicationId ( BuildTarget . iOS ) ;
102
+ // Get the iOS+ bundle / application ID.
103
+ private static string GetIosPlusApplicationId ( ) {
104
+ if ( EditorUserBuildSettings . activeBuildTarget == BuildTarget . tvOS ) {
105
+ return UnityCompat . GetApplicationId ( BuildTarget . tvOS ) ;
106
+ } else {
107
+ return UnityCompat . GetApplicationId ( BuildTarget . iOS ) ;
108
+ }
102
109
}
103
110
104
111
// Check the editor environment on the first update after loading this
105
112
// module.
106
113
private static void CheckConfiguration ( ) {
107
- CheckBundleId ( GetIOSApplicationId ( ) ) ;
114
+ CheckBundleId ( GetIosPlusApplicationId ( ) ) ;
108
115
CheckBuildEnvironment ( ) ;
109
116
}
110
117
@@ -115,9 +122,9 @@ internal static void ReadConfig(bool errorOnNoConfig = true, string filename = n
115
122
ReadConfigInternal ( errorOnNoConfig , filename : filename ) ;
116
123
} catch ( Exception exception ) {
117
124
// FileNotFoundException and TypeInitializationException can be
118
- // thrown *before* ReadConfigInternal is entered if the iOS Xcode
125
+ // thrown *before* ReadConfigInternal is entered if the iOS+ Xcode
119
126
// assembly can't be loaded so we catch them here and only report
120
- // a warning if this module is enabled and iOS is the selected
127
+ // a warning if this module is enabled and iOS+ is the selected
121
128
// platform.
122
129
if ( exception is FileNotFoundException ||
123
130
exception is TypeInitializationException ) {
@@ -158,11 +165,13 @@ internal static Dictionary<string, string> GetConfig() {
158
165
return configValues ;
159
166
}
160
167
161
- // Verify that the build environment *really* supports iOS.
168
+ // Verify that the build environment *really* supports iOS+ .
162
169
private static void CheckBuildEnvironment ( ) {
163
- // If iOS is the selected build target but we're not on a OSX machine
164
- // report an error as pod installation will fail among other things.
165
- if ( EditorUserBuildSettings . activeBuildTarget == BuildTarget . iOS &&
170
+ // If iOS+ is the selected build target but we're not on a OSX
171
+ // machine report an error as pod installation will fail among other
172
+ // things.
173
+ BuildTarget buildTarget = EditorUserBuildSettings . activeBuildTarget ;
174
+ if ( ( buildTarget == BuildTarget . iOS || buildTarget == BuildTarget . tvOS ) &&
166
175
Application . platform == RuntimePlatform . WindowsEditor ) {
167
176
Debug . LogError ( DocRef . IOSNotSupportedOnWindows ) ;
168
177
}
@@ -173,7 +182,7 @@ private static void OnBundleIdChanged(
173
182
object sender ,
174
183
PlayServicesResolver . BundleIdChangedEventArgs args ) {
175
184
ReadConfig ( errorOnNoConfig : false ) ;
176
- CheckBundleId ( GetIOSApplicationId ( ) ) ;
185
+ CheckBundleId ( GetIosPlusApplicationId ( ) ) ;
177
186
}
178
187
179
188
// Check the bundle ID
@@ -213,10 +222,16 @@ private static string CheckBundleId(string bundleId,
213
222
"Cancel" ,
214
223
selectedBundleId => {
215
224
if ( ! String . IsNullOrEmpty ( selectedBundleId ) ) {
216
- // If we have a valid value, the user hit apply.
217
- UnityCompat . SetApplicationId ( BuildTarget . iOS , selectedBundleId ) ;
218
- Measurement . ReportWithBuildTarget ( "bundleidmismatch/apply" , null ,
219
- "Mismatched Bundle ID: Apply" ) ;
225
+ switch ( EditorUserBuildSettings . activeBuildTarget ) {
226
+ case BuildTarget . iOS :
227
+ UnityCompat . SetApplicationId ( BuildTarget . iOS , selectedBundleId ) ;
228
+ break ;
229
+ case BuildTarget . tvOS :
230
+ UnityCompat . SetApplicationId ( BuildTarget . tvOS , selectedBundleId ) ;
231
+ break ;
232
+ default :
233
+ throw new Exception ( "unsupported iOS+ version" ) ;
234
+ }
220
235
} else {
221
236
Measurement . ReportWithBuildTarget ( "bundleidmismatch/cancel" , null ,
222
237
"Mismatched Bundle ID: Cancel" ) ;
@@ -238,7 +253,7 @@ private static string CheckBundleId(string bundleId,
238
253
private static void OnPostprocessAllAssets (
239
254
string [ ] importedAssets , string [ ] deletedAssets ,
240
255
string [ ] movedAssets , string [ ] movedFromPath ) {
241
- // We track the config file state even when the target isn't iOS
256
+ // We track the config file state even when the target isn't iOS+
242
257
// as the project settings are surfaced in the settings window.
243
258
if ( ! Enabled ) return ;
244
259
bool configFilePresent = false ;
@@ -251,7 +266,7 @@ private static void OnPostprocessAllAssets(
251
266
if ( configFilePresent ) {
252
267
spamguard = false ; // Reset our spamguard to show a dialog.
253
268
ReadConfig ( errorOnNoConfig : false ) ;
254
- CheckBundleId ( GetIOSApplicationId ( ) ) ;
269
+ CheckBundleId ( GetIosPlusApplicationId ( ) ) ;
255
270
}
256
271
}
257
272
@@ -283,7 +298,7 @@ internal static string FindConfig(bool errorOnNoConfig = true) {
283
298
GOOGLE_SERVICES_INFO_PLIST_FILE , Link . IOSAddApp ) ) ;
284
299
}
285
300
} else if ( files . Length > 1 ) {
286
- var bundleId = GetIOSApplicationId ( ) ;
301
+ var bundleId = GetIosPlusApplicationId ( ) ;
287
302
string selectedBundleId = null ;
288
303
// Search files for the first file matching the project's bundle identifier.
289
304
foreach ( var filename in files ) {
@@ -314,7 +329,9 @@ internal static string FindConfig(bool errorOnNoConfig = true) {
314
329
internal static void OnPostProcessAddGoogleServicePlist (
315
330
BuildTarget buildTarget , string pathToBuiltProject ) {
316
331
if ( ! Enabled ) return ;
317
- Measurement . analytics . Report ( "ios/xcodepatch" , "iOS Xcode Project Patcher: Start" ) ;
332
+ string platform = ( buildTarget == BuildTarget . iOS ) ? "iOS" : "tvOS" ;
333
+ Measurement . analytics . Report ( "ios/xcodepatch" ,
334
+ platform + " Xcode Project Patcher: Start" ) ;
318
335
AddGoogleServicePlist ( buildTarget , pathToBuiltProject ) ;
319
336
}
320
337
@@ -331,7 +348,7 @@ internal static void AddGoogleServicePlist(
331
348
return ;
332
349
}
333
350
334
- CheckBundleId ( GetIOSApplicationId ( ) , promptUpdate : false ) ;
351
+ CheckBundleId ( GetIosPlusApplicationId ( ) , promptUpdate : false ) ;
335
352
336
353
// Copy the config file to the Xcode project folder.
337
354
string configFileBasename = Path . GetFileName ( configFile ) ;
0 commit comments