I have had a problem with a video asset not being accessible from mainBundle. I am using XCode 7 and Swift 2.0. I wrote a very simple test app.
var objects = [String]()
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let fm = NSFileManager.defaultManager()
let path = NSBundle.mainBundle().resourcePath!
let items = try! fm.contentsOfDirectoryAtPath(path)
for item in items {
print ("item = \(item)")
objects.append(item)
}
}
}
I have four media assets in my app: i) testVideo.m4v ii) benbeijing.mov iii) TestVideoCopy.m4v and iv) benbeijing2.mov.
When I run the program I get the following output.
item = Base.lproj
item = benbeijing.mov
item = benbeijing2.mov
item = Frameworks
item = Info.plist
item = mainBundleTests
item = PkgInfo
In other words 2 of the video media items are not listed.
I have played around with titles, suffixes, locations in the mainBundle folder but can't for the life of me figure out why these items can't be found. Any help would be much appreciated.