@@ -25,6 +25,8 @@ public class BuildPostProcessor
25
25
[ PostProcessBuildAttribute ( 1 ) ]
26
26
public static void OnPostProcessBuild ( BuildTarget target , string path )
27
27
{
28
+ var separator = Path . DirectorySeparatorChar ;
29
+
28
30
string projectPath = PBXProject . GetPBXProjectPath ( path ) ;
29
31
PBXProject project = new PBXProject ( ) ;
30
32
@@ -34,13 +36,14 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
34
36
35
37
// UserNotifications.framework is required by libOneSignal.a
36
38
project . AddFrameworkToProject ( targetGUID , "UserNotifications.framework" , false ) ;
37
-
39
+
38
40
#if UNITY_2017_2_OR_NEWER && ! UNITY_CLOUD_BUILD
39
-
41
+
42
+ var platformsLocation = "Assets" + separator + "OneSignal" + separator + "Platforms" + separator ;
40
43
var extensionTargetName = "OneSignalNotificationServiceExtension" ;
41
- var pathToNotificationService = path + "/" + extensionTargetName ;
44
+ var pathToNotificationService = path + separator + extensionTargetName ;
42
45
43
- var notificationServicePlistPath = pathToNotificationService + "/ Info.plist";
46
+ var notificationServicePlistPath = pathToNotificationService + separator + " Info.plist";
44
47
45
48
//if this is a rebuild, we've already added the extension service, no need to run this script a second time
46
49
if ( File . Exists ( notificationServicePlistPath ) )
@@ -49,13 +52,13 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
49
52
Directory . CreateDirectory ( pathToNotificationService ) ;
50
53
51
54
PlistDocument notificationServicePlist = new PlistDocument ( ) ;
52
- notificationServicePlist . ReadFromFile ( "Assets/OneSignal/Platforms/ iOS/ Info.plist") ;
55
+ notificationServicePlist . ReadFromFile ( platformsLocation + " iOS" + separator + " Info.plist") ;
53
56
notificationServicePlist . root . SetString ( "CFBundleShortVersionString" , PlayerSettings . bundleVersion ) ;
54
57
notificationServicePlist . root . SetString ( "CFBundleVersion" , PlayerSettings . iOS . buildNumber . ToString ( ) ) ;
55
58
56
59
var notificationServiceTarget = PBXProjectExtensions . AddAppExtension ( project , targetGUID , extensionTargetName , PlayerSettings . GetApplicationIdentifier ( BuildTargetGroup . iOS ) + "." + extensionTargetName , notificationServicePlistPath ) ;
57
60
58
- var sourceDestination = extensionTargetName + "/ NotificationService";
61
+ var sourceDestination = extensionTargetName + separator + " NotificationService";
59
62
60
63
project . AddFileToBuild ( notificationServiceTarget , project . AddFile ( sourceDestination + ".h" , sourceDestination + ".h" , PBXSourceTree . Source ) ) ;
61
64
project . AddFileToBuild ( notificationServiceTarget , project . AddFile ( sourceDestination + ".m" , sourceDestination + ".m" , PBXSourceTree . Source ) ) ;
@@ -76,8 +79,8 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
76
79
notificationServicePlist . WriteToFile ( notificationServicePlistPath ) ;
77
80
78
81
foreach ( string type in new string [ ] { "m" , "h" } )
79
- if ( ! File . Exists ( path + "/" + sourceDestination + "." + type ) )
80
- FileUtil . CopyFileOrDirectory ( "Assets/OneSignal/Platforms/ iOS/ NotificationService.h", path + "/" + sourceDestination + "." + type ) ;
82
+ if ( ! File . Exists ( path + separator + sourceDestination + "." + type ) )
83
+ FileUtil . CopyFileOrDirectory ( platformsLocation + " iOS" + separator + " NotificationService.h", path + separator + sourceDestination + "." + type ) ;
81
84
82
85
project . WriteToFile ( projectPath ) ;
83
86
@@ -97,7 +100,7 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
97
100
98
101
// enable the Notifications capability in the main app target
99
102
project . ReadFromString ( contents ) ;
100
- var entitlementPath = path + "/" + targetName + "/" + targetName + ".entitlements" ;
103
+ var entitlementPath = path + separator + targetName + separator + targetName + ".entitlements" ;
101
104
102
105
PlistDocument entitlements = new PlistDocument ( ) ;
103
106
entitlements . root . SetString ( "aps-environment" , "development" ) ;
@@ -112,7 +115,7 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
112
115
// Copy the entitlement file to the xcode project
113
116
var entitlementFileName = Path . GetFileName ( entitlementPath ) ;
114
117
var unityTarget = PBXProject . GetUnityTargetName ( ) ;
115
- var relativeDestination = unityTarget + "/" + entitlementFileName ;
118
+ var relativeDestination = unityTarget + separator + entitlementFileName ;
116
119
117
120
// Add the pbx configs to include the entitlements files on the project
118
121
project . AddFile ( relativeDestination , entitlementFileName ) ;
0 commit comments