I have an Xcode project with two targets. I want to share assets between the two targets so as to avoid duplicate files.
What I've tried:
.wav
file to SharedAssets.xcassets.wav
file in codeResult:
The .wav
file can't be found by either target.
Question:
Why are both targets unable to find the .wav
file? How do I share assets between two targets?
Thank you!
Edit:
I'm using a SpriteKit SKAction
to load the file from inside an SKScene
:
private var sound: SKAction?
override func didMove(to view: SKView) {
sound = SKAction.playSoundFileNamed("mySound.wav", waitForCompletion: false)
}
I'm then playing the sound like this:
if let action = sound {
self.run(action)
}
This strategy works perfectly if I reference a .wav
file in the main bundle, but fails when referencing the file in SharedAssets.xcassets.
Edit #2:
I am able to successfully use images stored in SharedAssets.xcassets -- so, it's a problem with sounds.
Instead of putting the .wav
file in SharedAssets.xcassets, I kept it where it was in the bundle and simply added it to the second target under "Target Membership".
Doing this for each .wav
file solved the problem.