make XcodeCapp compatible with Xcode 4.4

This commit is contained in:
Antoine Mercadal
2012-08-08 19:08:16 -07:00
parent bf6c0c95eb
commit ea31bd2be2
2 changed files with 417 additions and 16 deletions
+63 -16
View File
@@ -318,6 +318,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
DLog(@"Parsing modified file: %@", fullPath);
NSArray *arguments = nil;
NSArray *PBXArguments = nil;
NSString *successTitle = nil;
NSString *successMsg = nil;
NSString *response = nil;
@@ -331,13 +332,29 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
if ([self isXIBFile:fullPath])
{
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; nib2cib '%@';) 2>&1", profilePath, fullPath],@"",nil];
arguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; nib2cib '%@';) 2>&1", profilePath, fullPath],@"",nil];
successTitle = @"XIB converted";
successMsg = splitPath;
}
else if ([self isObjJFile:fullPath])
{
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1", profilePath, parserPath, fullPath, shadowPath],@"",nil];
arguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1",
profilePath,
parserPath,
fullPath,
shadowPath],
@"",nil];
PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ add '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowPath],nil];
successTitle = @"Objective-J source processed";
successMsg = splitPath;
}
@@ -352,13 +369,22 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
// Run the task and get the response if needed
if (arguments)
{
DLog(@"Running task...");
DLog(@"Running conversion task...");
NSArray *statusInfo = [self runTask:arguments];
status = [statusInfo objectAtIndex:0];
response = [statusInfo objectAtIndex:1];
DLog(@"Task result/response: %@/%@", status, response);
DLog(@"Conversion task result/response: %@/%@", status, response);
}
if (PBXArguments)
{
DLog(@"Running update PBX task...");
NSArray *statusInfo = [self runTask:PBXArguments];
status = [statusInfo objectAtIndex:0];
response = [statusInfo objectAtIndex:1];
DLog(@"Update PBX Task result/response: %@/%@", status, response);
}
if ([status intValue] == 0 && shouldNotify)
@@ -393,8 +419,21 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
{
NSString *shadowPath = [[self shadowURLForSourceURL:[NSURL URLWithString:[fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] path];
[fm removeItemAtPath:shadowPath error:nil];
NSArray *PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowPath],nil];
DLog(@"Removing shadow file: %@", shadowPath);
[fm removeItemAtPath:shadowPath error:nil];
DLog(@"Removing PBX reference task...");
NSArray *statusInfo = [self runTask:PBXArguments];
NSNumber *status = [statusInfo objectAtIndex:0];
NSString *response = [statusInfo objectAtIndex:1];
DLog(@"PBX Reference removal status/response: %@/%@", status, response);
}
else if ([self isXCCIgnoreFile:fullPath])
{
@@ -445,15 +484,17 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
{
XCodeSupportProjectName = [NSString stringWithFormat:@"%@.xcodeproj/", currentProjectName];
XCodeTemplatePBXPath = [[NSBundle mainBundle] pathForResource:@"project.pbxproj" ofType:@"sample"];
XCodeSupportFolder = [NSURL URLWithString:@".xCodeSupport/" relativeToURL:currentProjectURL];
XCodeSupportFolder = currentProjectURL;
XCodeSupportProject = [NSURL URLWithString:XCodeSupportProjectName relativeToURL:XCodeSupportFolder];
XCodeSupportProjectSources = [NSURL URLWithString:@"Sources/" relativeToURL:XCodeSupportFolder];
XCodeSupportProjectSources = [NSURL URLWithString:@"XcodeSupport/" relativeToURL:XCodeSupportFolder];
XCodeSupportPBXPath = [NSString stringWithFormat:@"%@/project.pbxproj", [XCodeSupportProject path]];
PBXModifierScriptPath = [[NSBundle mainBundle] pathForResource:@"pbxprojModifier" ofType:@"py"];
//[fm removeItemAtURL:XCodeSupportFolder error:nil];
// create the template project if it doesn't exist
if (![fm fileExistsAtPath:[XCodeSupportFolder path]])
if (![fm fileExistsAtPath:[XCodeSupportProjectSources path]])
{
NSLog(@"Xcode support folder created at: %@", [XCodeSupportProject path]);
[fm createDirectoryAtPath:[XCodeSupportProject path] withIntermediateDirectories:YES attributes:nil error:nil];
@@ -463,14 +504,6 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
DLog(@"Reading the content of the project.pbxproj");
NSMutableString *PBXContent = [NSMutableString stringWithContentsOfFile:XCodeSupportPBXPath encoding:NSUTF8StringEncoding error:nil];
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectName}"
withString:currentProjectName
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [PBXContent length])];
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectRelativePath}"
withString:@".."
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [PBXContent length])];
[PBXContent writeToFile:XCodeSupportPBXPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
DLog(@"PBX file adapted to the project");
@@ -614,6 +647,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
[ignoredFilePaths addObject:@"*/.xCodeSupport/*"];
[ignoredFilePaths addObject:@"*/Build/*"];
[ignoredFilePaths addObject:@"*/NS_*.j"];
[ignoredFilePaths addObject:@"*main.j"];
NSLog(@"Ignoring file paths: %@", ignoredFilePaths);
}
@@ -710,6 +744,19 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
{
DLog(@"cleaning shadow file: %@", subpath);
[fm removeItemAtPath:shadowFullPath error:nil];
NSArray *PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowFullPath],nil];
DLog(@"Cleaning PBX reference task...");
NSArray *statusInfo = [self runTask:PBXArguments];
NSNumber *status = [statusInfo objectAtIndex:0];
NSString *response = [statusInfo objectAtIndex:1];
DLog(@"PBX Reference cleaning status/response: %@/%@", status, response);
if (![self supportFileLevelAPI] && [self respondsToSelector:@selector(updateLastModificationDate:forPath:)])
[self performSelector:@selector(updateLastModificationDate:forPath:) withObject:nil withObject:unshadowed];