We have discovered this issue when trying to add custom sounds for our notifications in our project for iOS, we’ve found the solution is to add the sound file extensions in the Engine file “Engine/Source/Programs/UnrealBuildTool/ProjectFiles/Xcode/XcodeProject.File.cs” as part of the ResourceExtension array variable defined in the class XCodeFileCollection.
Right now, this fix works for our pipeline, but it’s a functionality that will be needed on next versions of the engine too and will be great to have it out of the box. Just need to support “.caff”, “.wav” and “.aiff” files. Or have the feature to add any supported file by ios.
Steps to Reproduce
On any of your <project/plugin>.Build.cs file, add an additional sound resource for custom notifications sounds (aiff, wav, caf file, no longer than 30 secs) to be bundled into your xcode project, like this:
if (Target.Platform == UnrealTargetPlatform.IOS)
{ string SoundPath=Path.Combine(ModuleDirectory,<Relative path to your aiff, wav, caf file>);
AdditionalBundleResources.Add(new BundleResource(SoundPath));
}
Generate the Xcode project and open it.
On the Xcode project, go to “BuildPhases -> Copy Bundle Resources” and see the sound it’s not added, when it should be.
Sorry for the confusion on the first place and thanks for the info, but after trying the solution you gave us, it seems to work only for Mac projects, while we need this for iOS.
What we need, is to include the notification sounds under the "Build Phases -> Copy Bundle Resources" of the iOS Project in order to make the custom sounds to play when an app (remote or local) notification is triggered on the device.
Right now, we try to add the sounds to the generated Xcode project using the AdditionalBundleResources property of the ModuleRules class in our *.Build.cs files. Then, when creating the target XCode Project, the XCodeProject.File.cs should include the sounds to the right section of the Project, but we’ve found the kind of files that can be added are restricted to their file extensions, being those defined in the ResourceExtensions array of the XCodeProject.File.cs file. This array doesn’t include the extension for the compatible sound files (“.caf”, “.wav”, “.aiff”), therefore they’re not included on the generated project. We’ve tried the same approach but with other supported extensions, like .png, and they’re being added properly.
So, with the small addition of the sound extensions to this array, we’re being able to include them into the app. We would like to have this change integrated in future version of the engine, instead of having to deal with patches everytime we update, as this is something that is of common usage on iOS apps.
This is the image of the resulting Xcode project after modifying the engine source, and including the sounds using the AdditionalBundleResources property.
We can definitely look at the addition to the extensions filter. However, regarding the initial solution that didn’t require engine edits, this seemed to work as well for iOS on our end on stock 5.6.
I’m working with the source code version of 5.6.1 and I’ve been unable to make it work this morning, i’ll give it a try again ir order to discover what went wrong.
I was able to import the sound folder inside the project. The problem was how I was seting the path, using the pattern (FilePath=“/Game/…”) instead of $Project/path.
But we have another problem. Not related to the Engine, but the integration in our workflow.
When triggereing the notification with the custom sound for iOS, we have to setup the name of the sound as the full path inside the bundle (NotificationSounds/CustomNotificationSound.aiff), if not, the sound won’t play. Our problem is that this is intended to be integrated in a multi-game + multiplatform system that also runs with android and other engines, an it requires only the name of the sound (CustomNotificaitonSound.aiff) to be setup for the notification, not the full path, making this situation an exception for the combination of UE + iOS. I think this path situation would affect custom images inside the folder as well, but we can add them using the AdditonalBundleResources property in order to have them as single entries in the app.
So that makes us need the change in the XCodeProject.File.cs file to allow the sound files to be added individually. I understand that in this situation this is not a priority for you and we can patch the engine each time we update on our side, but It would be helpful to have it.