Search code examples
iosios4xcode4ios5

Can't remove files from mainBundle


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?

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;

}


Solution

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