Skip to content

Commit 017482d

Browse files
authored
• When a developer attempted to re-build their project (instead of generating a new Xcode project), the iOS build script would attempt to copy a file to a destination that already existed, throwing an error (#128)
• This caused the build script to fail and print an error, though the rebuild would still work and there shouldn't have been any other negative effects
1 parent aee5b09 commit 017482d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

OneSignalExample/Assets/OneSignal/Editor/PostProcessBuildPlayer_iOS.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
4040
var extensionTargetName = "OneSignalNotificationServiceExtension";
4141
var pathToNotificationService = path + "/" + extensionTargetName;
4242

43-
Directory.CreateDirectory (pathToNotificationService);
44-
4543
var notificationServicePlistPath = pathToNotificationService + "/Info.plist";
44+
45+
//if this is a rebuild, we've already added the extension service, no need to run this script a second time
46+
if (File.Exists(notificationServicePlistPath))
47+
return;
48+
49+
Directory.CreateDirectory(pathToNotificationService);
4650

4751
PlistDocument notificationServicePlist = new PlistDocument();
4852
notificationServicePlist.ReadFromFile ("Assets/OneSignal/Platforms/iOS/Info.plist");
@@ -70,9 +74,10 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
7074
project.SetBuildProperty (notificationServiceTarget, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID);
7175

7276
notificationServicePlist.WriteToFile (notificationServicePlistPath);
73-
74-
FileUtil.CopyFileOrDirectory ("Assets/OneSignal/Platforms/iOS/NotificationService.h", path + "/" + sourceDestination + ".h");
75-
FileUtil.CopyFileOrDirectory ("Assets/OneSignal/Platforms/iOS/NotificationService.m", path + "/" + sourceDestination + ".m");
77+
78+
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);
7681

7782
project.WriteToFile (projectPath);
7883

0 commit comments

Comments
 (0)