无法从mainBundle中删除文件 [英] Can't remove files from mainBundle

查看:81
本文介绍了无法从mainBundle中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从主套装中删除文件。当我从XCODE 4.2中的支持文件手动删除它们时。当我运行我的应用程序时,它们仍会显示我用显示包内容打开了app文件,并从那里手动删除它们,当我运行应用程序时它们仍会显示。我已经从模拟器和库中的〜/ applications文件夹中删除了应用程序,并且存在相同的行为。我错过了什么吗?

I am having trouble removing files from my main bundle. When I delete them manually from support files in XCODE 4.2. They still show up when I run my app. I have opened up the app file with "show package contents" and manually deleted them from there and they still show up when I run the app. I have deleted the app from the simulator and from the ~/applications folder in library and the same behavior exists. Am I missing something?

背景:我有一个帮助应用程序,我可以将文件放入支持文件文件夹并运行,以便将它们从KML转换为自定义通过服务器下载到设备的另一个应用程序中使用的XML。我使用下面的代码从主包创建一个文件名数组,并将其传递给解析器。我有问题,因为它包括已删除/删除的文件包,我无法弄清楚原因。任何帮助将不胜感激。

Background: I have a helper app that I can drop files into the "support files" folder and run in order to convert them from KML to custom XML for use in another app via server downloads to the device. I create an array of file names from the main bundle with the code below and pass that to the parser. I have issues because it is including the deleted/removed files from the bundle and I can't figure out why. Any help would be appreciated.

-(NSArray*)findKMLFilesInMainBundle{
NSString *path = [[NSBundle mainBundle]resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = [[NSError alloc]init];
NSMutableArray *kmlArray = [[NSMutableArray alloc]initWithCapacity:10];

NSArray *files = [fileManager contentsOfDirectoryAtPath:path error:&error];
unichar buffer[5];

//now seach for the kml files
for (NSString *fileName in files){
    NSLog(@"%@",fileName);
    int count = [fileName length];
    int start = count - 3;
    NSRange range = {start,3};


    [fileName getCharacters:buffer range:range];
    NSString *endString = [NSString stringWithCharacters:buffer length:3];
    if ([endString isEqualToString:@"kml"]){
        NSString *kmlFileName = [fileName stringByDeletingPathExtension];
        NSLog(@"kmlFilename%@",kmlFileName);
        [kmlArray addObject:kmlFileName];

    }
}
for (NSString *name in kmlArray){
    NSLog(@"file = %@",name);
}

return kmlArray;

}

推荐答案

按住⌥选项并选择Product→从菜单栏清除构建文件夹....此操作的默认快捷方式是⌥⇧⌘K

Hold down ⌥ Option and choose Product → Clean Build Folder... from the menu bar. The default shortcut for this action is ⌥⇧⌘K.

这篇关于无法从mainBundle中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆