で「フォルダの参照」ファイルを見つけることができません私はそれはiPhone 6のXCodeののシミュレータアプリ
ファイルIに罰金見つけることができます私の開発iPhone 6に私のアプリにパッケージ化されたファイルを参照するように見えることはできません参照しようとしています:私は、ファイル参照
:
NSString *epubPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"epubjs/ios.html"];
エラーはこれが返されます。
Error Domain=NSCocoaErrorDomain Code=260 "The file “ios.html” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/containers/Bundle/Application/8BB11DEC-4823-4603-83E7-F4C23BC3C983/BSAVA.app/epubjs/ios.html, NSUnderlyingError=0x126df1110 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
私はNSBundle内のファイルのリストを取得および/またはファイルを検索するためにいろいろなことを試してみましたが、それは実際のデバイス上で実行しているとき、私はアプリ内でそれを取得することはできません。
//
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil];
NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self ENDSWITH '.html'"];
NSArray *onlyHTMLs = [dirContents filteredArrayUsingPredicate:fltr];
NSLog(@".html file array: %@", onlyHTMLs);
//
NSError * error;
NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:resourcePath error:&error];
//
NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"BSAVA"];
NSArray * directoryContents2 = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error];
//
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"ios" ofType:@"html"];
NSURL *path = [[NSBundle mainBundle] URLForResource:@"ios" withExtension:@"html"];
//
これらはすべてnilを返します。
Finderオプションで表示すると、そのフォルダの正しいパスを確認するのに役立ちます。 – Nirav
はファイルのターゲットセットですか?これは、ファイルが選択されたときにXCodeの右側のパネルに表示されます。あなたは "ターゲットメンバーシップ"を探しています – Dominic
私はファインダーを使って開発用Macでファイルokを見つけることができます。私のアプリは、実行中のファイルのバンドル版を見つけることができません。 – Ryan