com.puzzlescapegames.services 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#if (UNITY_IPHONE || UNITY_IOS) && ENABLED_XCODE_INFO_PLIST
|
|
2
2
|
using System.IO;
|
|
3
|
+
using System.Linq;
|
|
3
4
|
using UnityEditor;
|
|
4
5
|
using UnityEditor.Callbacks;
|
|
5
6
|
using UnityEditor.iOS.Xcode;
|
|
@@ -9,9 +10,10 @@ namespace PuzzlescapeGames.Services.Editor
|
|
|
9
10
|
{
|
|
10
11
|
public static class XCodePostProcess
|
|
11
12
|
{
|
|
13
|
+
private const string k_LocationWhenInUseUsageDescription = "This app uses your location to show more relevant and personalized advertising content that matches your interests and region.";
|
|
12
14
|
// Set the IDFA request description:
|
|
13
15
|
private const string k_TrackingDescription = "Your data will be used to provide you a better and personalized ad experience.";
|
|
14
|
-
|
|
16
|
+
|
|
15
17
|
[ PostProcessBuild ]
|
|
16
18
|
public static void ChangeXcodePlist( BuildTarget buildTarget, string path )
|
|
17
19
|
{
|
|
@@ -27,6 +29,8 @@ namespace PuzzlescapeGames.Services.Editor
|
|
|
27
29
|
|
|
28
30
|
//Default Encrypt
|
|
29
31
|
rootDict.SetBoolean( "ITSAppUsesNonExemptEncryption", false );
|
|
32
|
+
//Location
|
|
33
|
+
rootDict.SetString( "NSLocationWhenInUseUsageDescription", k_LocationWhenInUseUsageDescription );
|
|
30
34
|
//ATT
|
|
31
35
|
rootDict.SetString( "NSUserTrackingUsageDescription", k_TrackingDescription );
|
|
32
36
|
//AppsFlyer Swizzling
|
|
@@ -36,9 +40,93 @@ namespace PuzzlescapeGames.Services.Editor
|
|
|
36
40
|
//https://dev.appsflyer.com/hc/docs/integrate-ios-sdk#sending-skan-postback-copies-to-appsflyer
|
|
37
41
|
rootDict.SetString( "NSAdvertisingAttributionReportEndpoint ", "https://appsflyer-skadnetwork.com/" );
|
|
38
42
|
|
|
43
|
+
#if SINGULAR_SWIZZLE
|
|
44
|
+
//https://support.singular.net/hc/en-us/articles/360037635452-Unity-SDK-Basic-Integration?navigation_side_bar=true#ios_unityappcontroller_conflict
|
|
45
|
+
SingularSwizzle( path );
|
|
46
|
+
#endif
|
|
39
47
|
File.WriteAllText( plistPath, plist.WriteToString() );
|
|
40
48
|
}
|
|
41
49
|
}
|
|
50
|
+
|
|
51
|
+
private static void SingularSwizzle( string path )
|
|
52
|
+
{
|
|
53
|
+
var swizzled = FindFile(path, "SingularSwizzledAppController.m");
|
|
54
|
+
var appDelegate = FindFile(path, "SingularAppDelegate.m");
|
|
55
|
+
|
|
56
|
+
if (swizzled != null)
|
|
57
|
+
{
|
|
58
|
+
UncommentWholeFileIfWrapped(swizzled);
|
|
59
|
+
Debug.Log($"[XCodePostProcess] Singular Patched: {swizzled}");
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
{
|
|
63
|
+
Debug.LogWarning("[XCodePostProcess] SingularSwizzledAppController.m not found in Xcode project.");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (appDelegate != null)
|
|
67
|
+
{
|
|
68
|
+
EnsureLineNotCommented(appDelegate, "IMPL_APP_CONTROLLER_SUBCLASS(SingularAppDelegate)");
|
|
69
|
+
Debug.Log($"[XCodePostProcess] Singular Patched: {appDelegate}");
|
|
70
|
+
}
|
|
71
|
+
else
|
|
72
|
+
{
|
|
73
|
+
Debug.LogWarning("[XCodePostProcess] SingularAppDelegate.m not found in Xcode project.");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private static string FindFile( string root, string fileName ) => Directory.EnumerateFiles( root, fileName, SearchOption.AllDirectories ).FirstOrDefault();
|
|
78
|
+
|
|
79
|
+
/// <summary>
|
|
80
|
+
/// Частый кейс: весь файл закомментирован блоком /* ... */.
|
|
81
|
+
/// Снимаем внешний блок-комментарий, если он реально "оборачивает" почти весь файл.
|
|
82
|
+
/// </summary>
|
|
83
|
+
private static void UncommentWholeFileIfWrapped( string filePath )
|
|
84
|
+
{
|
|
85
|
+
var text = File.ReadAllText( filePath );
|
|
86
|
+
|
|
87
|
+
var trimmed = text.TrimStart();
|
|
88
|
+
if ( !trimmed.StartsWith( "/*" ) ) return;
|
|
89
|
+
|
|
90
|
+
// Удаляем ПЕРВЫЙ /* и ПОСЛЕДНИЙ */ (если есть)
|
|
91
|
+
var first = text.IndexOf( "/*" );
|
|
92
|
+
var last = text.LastIndexOf( "*/" );
|
|
93
|
+
|
|
94
|
+
if ( first >= 0 && last > first )
|
|
95
|
+
{
|
|
96
|
+
var before = text.Substring( 0, first );
|
|
97
|
+
var middle = text.Substring( first + 2, last - ( first + 2 ) );
|
|
98
|
+
var after = text.Substring( last + 2 );
|
|
99
|
+
|
|
100
|
+
File.WriteAllText( filePath, before + middle + after );
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// <summary>
|
|
105
|
+
/// Гарантируем, что нужная строка не закомментирована (// или /* */ на одной строке).
|
|
106
|
+
/// </summary>
|
|
107
|
+
private static void EnsureLineNotCommented( string filePath, string exactLine )
|
|
108
|
+
{
|
|
109
|
+
var lines = File.ReadAllLines( filePath );
|
|
110
|
+
|
|
111
|
+
for ( int i = 0; i < lines.Length; i++ )
|
|
112
|
+
{
|
|
113
|
+
var l = lines[ i ];
|
|
114
|
+
|
|
115
|
+
// Убираем однострочный комментарий перед строкой
|
|
116
|
+
if ( l.Contains( exactLine ) && l.TrimStart().StartsWith( "//" ) )
|
|
117
|
+
{
|
|
118
|
+
lines[ i ] = l.Replace( "//", "" ).TrimStart();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Убираем /* ... */ если строка целиком закомментирована
|
|
122
|
+
if ( l.Contains( exactLine ) && l.Contains( "/*" ) && l.Contains( "*/" ) )
|
|
123
|
+
{
|
|
124
|
+
lines[ i ] = l.Replace( "/*", "" ).Replace( "*/", "" );
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
File.WriteAllLines( filePath, lines );
|
|
129
|
+
}
|
|
42
130
|
}
|
|
43
131
|
}
|
|
44
132
|
#endif
|