I'm trying to create a Daemon (service) as part of the installation, and before creating the new one I'm deleting the previous one, and under the new one I check whether the previous has been deleted, and only then create it. I've tried first using the innate "Create Service" block of the installer, but when it checks whether the old Daemon exists, it seems to not delete fast enough and the creation step just gets skipped.. so I've changed it to instead cp a .plist file and launchctl load it.. but after the cp, if i do a rule in the launchctl command to check for the file's existence, it also doesn't see it - i assume because it doesn't wait for the cp to finish and just continues. I've solved the problem by putting a 5s wait between the cp and the launchctl (I've also noticed that in the Windows service deletion you can add a <delay> tag to wait for the deletion - why is there no such option for the OSX service tag?).
Is there a better way to do this? maybe tell one step to wait for the previous step to finish? or have a step wait for the program being run to actually run or finish running? since I can't really count on an arbitrary delay number, and I can't increase it to no end.