From 27f610a392b3ffa3d8507fa3144b6287c9a785fc Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 28 Jan 2016 21:44:16 +0000 Subject: [PATCH] Cleaning up the previously generated .strings file before running genstrings, prevents inexistent keys from showing up in the generated files. --- SCStringsUtility/SCStringsController.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SCStringsUtility/SCStringsController.m b/SCStringsUtility/SCStringsController.m index dbda073..1fe26ed 100644 --- a/SCStringsUtility/SCStringsController.m +++ b/SCStringsUtility/SCStringsController.m @@ -224,8 +224,12 @@ - (void)importProjectAtPath:(NSString *)path [fileParent sortUsingDescriptors:@[sortByLanguage]]; } + NSString *stringsFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:stringsFileName]; + [[NSFileManager defaultManager] removeItemAtPath:stringsFilePath error:nil]; + [self executeGenStringsAtPath:[self.project.filePath stringByDeletingLastPathComponent] withRoutine:genstringsRoutine positionalParameters:includePositionalParameters]; - SCReader *genstringsOutputReader = [[SCReader alloc] initWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:stringsFileName]]; + + SCReader *genstringsOutputReader = [[SCReader alloc] initWithPath:stringsFilePath]; NSString *comment, *key, *translation; while([genstringsOutputReader getNextComment:&comment key:&key translation:&translation]) { [self.translationsDictionary setObject:[NSMutableDictionary dictionaryWithObject:comment forKey:kKeyComment] forKey:key];