2

I have audio files in my app.

I can listen to any of them but I can't run the app. Xcode writes " No such file or directory". Here are the error and file paths.

I have tried to delete Xcode/Derived Data, but it doesn't work and in Copy Bundle Resources there are not red files.

1 Answer 1

3

iOS apps can access resources which are bundled into its Bundle during archive or the one that exists within its SandBox (resources downloaded programmatically and kept in document/temp folder of sandBox). Your audio files are on Desktop of your Mac and iOS app cant access them.

What should I do?

Select the entry of these items in your Xcode, delete them (remove only reference not original file)

enter image description here

now go back to desktop, select items and drag it to your project and select copy items if needed while copying

enter image description here

this will copy items to your app bundle now you can access it :)

Free of cost Advice

Thats a horrible coding approach to copy audio files (Assuming audio files are huge in size as I don't have context of your audio file sizes) to your app bundle :| this will bulk up your app size, think of more scalable approach, like downloading it on the fly from servers (lazy download, background download, or if you are streaming the m3U8 format etc etc)

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for the solution and advice, but this app must work on offline, and audio file sizes are pretty small. Is it possible?
@sam: You can download and cache the audio files to be able to work offline, it obviously needs internet at least when the resource is being played for the first time, you can use AVAssetResourceLoader to stream and download simultaneously:D so when user comes back to app tries to play the audio again it will play from cache and won't download anything new.
I am assuming it does work online too. So a suggestion would be to download these files when user is online and then save locally for offline support rather than bundling in with the app. This way even though app size will be large on phone but at first install it will be much thinner.
Personally I think you’re totally fine with keeping your assets bundled with your app. I mean come on, you’ve only got a few sound effect files. We’re not talking hundreds of MB here. That’s a lot of extra unnecessary optimization to do. Why get into all of that downloading / background downloading, caching, CDN to shave a couple of MB. Don’t optimize prematurely. Cross that bridge only when it makes sense to.
@peter-parker: It was general suggestion, if its a very small audio clips for games or custom audio for notification than its okay, because we are not sure of the size of audio file I suggested it as a general rule of thumb :+1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.