diff --git a/Source/XCAbstractDefinition.h b/Source/SXCAbstractDefinition.h similarity index 77% rename from Source/XCAbstractDefinition.h rename to Source/SXCAbstractDefinition.h index 1b02341..561dece 100755 --- a/Source/XCAbstractDefinition.h +++ b/Source/SXCAbstractDefinition.h @@ -9,40 +9,37 @@ // //////////////////////////////////////////////////////////////////////////////// - #import typedef enum { - /** * Creates the reference in the project and writes the contents to disk. If a file already exists at the specified * location, its contents will be updated. */ - XCFileOperationTypeOverwrite, + SXCFileOperationTypeOverwrite, /** * Creates the reference in the project. If a file already exists at the specified location, the contents will not * be updated. */ - XCFileOperationTypeAcceptExisting, + SXCFileOperationTypeAcceptExisting, /** * Creates the reference in the project, but does not write to disk. The filesystem is expected to be updated * through some other means. */ - XCFileOperationTypeReferenceOnly -} XCFileOperationType; + SXCFileOperationTypeReferenceOnly +} SXCFileOperationType; /** * Holds properties to all types of resource that can be added to an Xcode project. */ -@interface XCAbstractDefinition : NSObject +@interface SXCAbstractDefinition : NSObject { - XCFileOperationType _fileOperationType; + SXCFileOperationType _fileOperationType; } -@property(nonatomic) XCFileOperationType fileOperationType; - +@property(nonatomic) SXCFileOperationType fileOperationType; -@end \ No newline at end of file +@end diff --git a/Source/XCAbstractDefinition.m b/Source/SXCAbstractDefinition.m similarity index 75% rename from Source/XCAbstractDefinition.m rename to Source/SXCAbstractDefinition.m index 20e51e6..55b16eb 100755 --- a/Source/XCAbstractDefinition.m +++ b/Source/SXCAbstractDefinition.m @@ -9,16 +9,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCAbstractDefinition.h" -#import "XCAbstractDefinition.h" - - -@implementation XCAbstractDefinition +@implementation SXCAbstractDefinition @synthesize fileOperationType = _fileOperationType; - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Initialization & Destruction - (id)init @@ -26,10 +23,9 @@ - (id)init self = [super init]; if (self) { - _fileOperationType = XCFileOperationTypeOverwrite; + _fileOperationType = SXCFileOperationTypeOverwrite; } return self; } - -@end \ No newline at end of file +@end diff --git a/Source/XCClassDefinition.h b/Source/SXCClassDefinition.h similarity index 51% rename from Source/XCClassDefinition.h rename to Source/SXCClassDefinition.h index a8ea76d..82d399e 100755 --- a/Source/XCClassDefinition.h +++ b/Source/SXCClassDefinition.h @@ -9,54 +9,47 @@ // //////////////////////////////////////////////////////////////////////////////// - #import -#import "XCAbstractDefinition.h" + +#import "SXCAbstractDefinition.h" typedef enum { - ObjectiveC, - ObjectiveCPlusPlus, - CPlusPlus, -} ClassDefinitionLanguage; + SXCClassDefinitionLanguageObjectiveC, + SXCClassDefinitionLanguageObjectiveCPlusPlus, + SXCClassDefinitionLanguageCPlusPlus, +} SXCClassDefinitionLanguage; -@interface XCClassDefinition : XCAbstractDefinition +@interface SXCClassDefinition : SXCAbstractDefinition { - NSString* _className; NSString* _header; NSString* _source; @private - ClassDefinitionLanguage _language; + SXCClassDefinitionLanguage _language; + NSString* _sourceFileName; } @property(strong, nonatomic, readonly) NSString* className; @property(nonatomic, strong) NSString* header; @property(nonatomic, strong) NSString* source; -+ (XCClassDefinition*)classDefinitionWithName:(NSString*)fileName; - -+ (XCClassDefinition*)classDefinitionWithName:(NSString*)className language:(ClassDefinitionLanguage)language; - /** -* Initializes a new objective-c class definition. -*/ -- (id)initWithName:(NSString*)fileName; + * Creates a new objective-c class definition. + */ ++ (instancetype)classDefinitionWithName:(NSString*)fileName; /** -* Initializes a new class definition with the specified language. -*/ -- (id)initWithName:(NSString*)className language:(ClassDefinitionLanguage)language; + * Creates a new class definition with the specified language. + */ ++ (instancetype)classDefinitionWithName:(NSString*)className language:(SXCClassDefinitionLanguage)language; - (BOOL)isObjectiveC; - - (BOOL)isObjectiveCPlusPlus; - - (BOOL)isCPlusPlus; -- (NSString*)headerFileName; - -- (NSString*)sourceFileName; +@property(nonatomic, copy, readonly) NSString* headerFileName; +@property(nonatomic, copy, readonly) NSString* sourceFileName; @end diff --git a/Source/SXCClassDefinition.m b/Source/SXCClassDefinition.m new file mode 100755 index 0000000..98d5443 --- /dev/null +++ b/Source/SXCClassDefinition.m @@ -0,0 +1,97 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 - 2013 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import "SXCClassDefinition.h" + +@implementation SXCClassDefinition + +@synthesize className = _className; +@synthesize header = _header; +@synthesize source = _source; + +/* ================================================================================================================== */ +#pragma mark - Class Methods + ++ (instancetype)classDefinitionWithName:(NSString*)fileName +{ + return [[self alloc] initWithName:fileName]; +} + ++ (instancetype)classDefinitionWithName:(NSString*)className language:(SXCClassDefinitionLanguage)language +{ + return [[self alloc] initWithName:className language:language]; +} + +/* ================================================================================================================== */ +#pragma mark - Initialization & Destruction + +- (instancetype)initWithName:(NSString*)className +{ + return [self initWithName:className language:SXCClassDefinitionLanguageObjectiveC]; +} + +- (instancetype)initWithName:(NSString*)className language:(SXCClassDefinitionLanguage)language +{ + self = [super init]; + if (self) { + _className = [className copy]; + if (!(language == SXCClassDefinitionLanguageObjectiveC || + language == SXCClassDefinitionLanguageObjectiveCPlusPlus || + language == SXCClassDefinitionLanguageCPlusPlus)) { + [NSException raise:NSInvalidArgumentException + format:@"Language must be one of ObjectiveC, ObjectiveCPlusPlus"]; + } + _language = language; + } + return self; +} + +/* ================================================================================================================== */ +#pragma mark - Interface Methods + +- (BOOL)isObjectiveC +{ + return _language == SXCClassDefinitionLanguageObjectiveC; +} + +- (BOOL)isObjectiveCPlusPlus +{ + return _language == SXCClassDefinitionLanguageObjectiveCPlusPlus; +} + +- (BOOL)isCPlusPlus +{ + return _language == SXCClassDefinitionLanguageCPlusPlus; +} + +- (NSString*)headerFileName +{ + return [_className stringByAppendingString:@".h"]; +} + +- (NSString*)sourceFileName +{ + if (!_sourceFileName) { + if ([self isObjectiveC]) { + _sourceFileName = [_className stringByAppendingString:@".m"]; + } + else if ([self isObjectiveCPlusPlus]) { + _sourceFileName = [_className stringByAppendingString:@".mm"]; + } + else if ([self isCPlusPlus]) { + _sourceFileName = [_className stringByAppendingString:@".cpp"]; + } + return _sourceFileName; + } + return _sourceFileName; +} + +@end diff --git a/Source/XCFileOperationQueue.h b/Source/SXCFileOperationQueue.h similarity index 91% rename from Source/XCFileOperationQueue.h rename to Source/SXCFileOperationQueue.h index a911775..086efe5 100755 --- a/Source/XCFileOperationQueue.h +++ b/Source/SXCFileOperationQueue.h @@ -9,13 +9,10 @@ // //////////////////////////////////////////////////////////////////////////////// - #import - -@interface XCFileOperationQueue : NSObject +@interface SXCFileOperationQueue : NSObject { - @private NSString* _baseDirectory; NSMutableDictionary* _filesToWrite; @@ -24,22 +21,16 @@ NSMutableArray* _directoriesToCreate; } - -- (id)initWithBaseDirectory:(NSString*)baseDirectory; +- (instancetype)initWithBaseDirectory:(NSString*)baseDirectory; - (BOOL)fileWithName:(NSString*)name existsInProjectDirectory:(NSString*)directory; - (void)queueTextFile:(NSString*)fileName inDirectory:(NSString*)directory withContents:(NSString*)contents; - - (void)queueDataFile:(NSString*)fileName inDirectory:(NSString*)directory withContents:(NSData*)contents; - - (void)queueFrameworkWithFilePath:(NSString*)filePath inDirectory:(NSString*)directory; - - (void)queueDeletion:(NSString*)filePath; - - (void)queueDirectory:(NSString*)withName inDirectory:(NSString*)parentDirectory; - (void)commitFileOperations; @end - diff --git a/Source/XCFileOperationQueue.m b/Source/SXCFileOperationQueue.m similarity index 84% rename from Source/XCFileOperationQueue.m rename to Source/SXCFileOperationQueue.m index ce5ac92..a48533d 100755 --- a/Source/XCFileOperationQueue.m +++ b/Source/SXCFileOperationQueue.m @@ -9,31 +9,25 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCFileOperationQueue.h" - -#import "XCFileOperationQueue.h" - -@interface XCFileOperationQueue () +@interface SXCFileOperationQueue () - (NSString*)destinationPathFor:(NSString*)fileName inProjectDirectory:(NSString*)directory; - (void)performFileWrites; - - (void)performCopyFrameworks; - - (void)performFileDeletions; - - (void)performCreateDirectories; @end +@implementation SXCFileOperationQueue -@implementation XCFileOperationQueue - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Initialization & Destruction -- (id)initWithBaseDirectory:(NSString*)baseDirectory +- (instancetype)initWithBaseDirectory:(NSString*)baseDirectory { self = [super init]; if (self) @@ -47,7 +41,7 @@ - (id)initWithBaseDirectory:(NSString*)baseDirectory return self; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Interface Methods - (BOOL)fileWithName:(NSString*)name existsInProjectDirectory:(NSString*)directory @@ -56,7 +50,6 @@ - (BOOL)fileWithName:(NSString*)name existsInProjectDirectory:(NSString*)directo return [[NSFileManager defaultManager] fileExistsAtPath:filePath]; } - - (void)queueTextFile:(NSString*)fileName inDirectory:(NSString*)directory withContents:(NSString*)contents { [_filesToWrite setObject:[contents dataUsingEncoding:NSUTF8StringEncoding] @@ -68,13 +61,12 @@ - (void)queueDataFile:(NSString*)fileName inDirectory:(NSString*)directory withC [_filesToWrite setObject:contents forKey:[self destinationPathFor:fileName inProjectDirectory:directory]]; } - - (void)queueFrameworkWithFilePath:(NSString*)filePath inDirectory:(NSString*)directory { - + NSString* fileName = [filePath lastPathComponent]; NSURL* sourceUrl = [NSURL fileURLWithPath:filePath isDirectory:YES]; NSString* destinationPath = - [[_baseDirectory stringByAppendingPathComponent:directory] stringByAppendingPathComponent:[filePath lastPathComponent]]; + [[_baseDirectory stringByAppendingPathComponent:directory] stringByAppendingPathComponent:fileName]; NSURL* destinationUrl = [NSURL fileURLWithPath:destinationPath isDirectory:YES]; [_frameworksToCopy setObject:sourceUrl forKey:destinationUrl]; } @@ -98,8 +90,7 @@ - (void)commitFileOperations [self performCreateDirectories]; } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Private Methods - (NSString*)destinationPathFor:(NSString*)fileName inProjectDirectory:(NSString*)directory @@ -114,7 +105,8 @@ - (void)performFileWrites NSError* error = nil; if (![data writeToFile:filePath options:NSDataWritingAtomic error:&error]) { - [NSException raise:NSInternalInconsistencyException format:@"Error writing file at filePath: %@, error: %@", filePath, error]; + [NSException raise:NSInternalInconsistencyException + format:@"Error writing file at filePath: %@, error: %@", filePath, error]; } }]; [_filesToWrite removeAllObjects]; @@ -124,7 +116,6 @@ - (void)performCopyFrameworks { [_frameworksToCopy enumerateKeysAndObjectsUsingBlock:^(NSURL* destinationUrl, NSURL* frameworkPath, BOOL* stop) { - NSFileManager* fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:[destinationUrl path]]) @@ -134,8 +125,8 @@ - (void)performCopyFrameworks NSError* error = nil; if (![fileManager copyItemAtURL:frameworkPath toURL:destinationUrl error:&error]) { - [NSException raise:NSInternalInconsistencyException format:@"Error writing file at filePath: %@", - [frameworkPath absoluteString]]; + [NSException raise:NSInternalInconsistencyException + format:@"Error writing file at filePath: %@", [frameworkPath absoluteString]]; } }]; [_frameworksToCopy removeAllObjects]; @@ -151,7 +142,8 @@ - (void)performFileDeletions if (![[NSFileManager defaultManager] removeItemAtPath:fullPath error:&error]) { NSLog(@"failed to remove item at path; error == %@", error); - [NSException raise:NSInternalInconsistencyException format:@"Error deleting file at filePath: %@", filePath]; + [NSException raise:NSInternalInconsistencyException + format:@"Error deleting file at filePath: %@", filePath]; } else { @@ -176,5 +168,4 @@ - (void)performCreateDirectories } } - -@end \ No newline at end of file +@end diff --git a/Source/XCFrameworkDefinition.h b/Source/SXCFrameworkDefinition.h similarity index 67% rename from Source/XCFrameworkDefinition.h rename to Source/SXCFrameworkDefinition.h index 2e78b6f..388271d 100755 --- a/Source/XCFrameworkDefinition.h +++ b/Source/SXCFrameworkDefinition.h @@ -9,13 +9,11 @@ // //////////////////////////////////////////////////////////////////////////////// - - #import -#import "XCAbstractDefinition.h" +#import "SXCAbstractDefinition.h" -@interface XCFrameworkDefinition : XCAbstractDefinition +@interface SXCFrameworkDefinition : SXCAbstractDefinition { NSString* _filePath; BOOL _copyToDestination; @@ -24,11 +22,8 @@ @property(nonatomic, strong, readonly) NSString* filePath; @property(nonatomic, readonly) BOOL copyToDestination; -+ (XCFrameworkDefinition*)frameworkDefinitionWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination; - -- (id)initWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination; ++ (instancetype)frameworkDefinitionWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination; - (NSString*)name; - -@end \ No newline at end of file +@end diff --git a/Source/XCFrameworkDefinition.m b/Source/SXCFrameworkDefinition.m similarity index 62% rename from Source/XCFrameworkDefinition.m rename to Source/SXCFrameworkDefinition.m index df180b0..8a0306a 100755 --- a/Source/XCFrameworkDefinition.m +++ b/Source/SXCFrameworkDefinition.m @@ -9,28 +9,25 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCFrameworkDefinition.h" - -#import "XCFrameworkDefinition.h" - -@implementation XCFrameworkDefinition +@implementation SXCFrameworkDefinition @synthesize filePath = _filePath; @synthesize copyToDestination = _copyToDestination; -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Class Methods -+ (XCFrameworkDefinition*)frameworkDefinitionWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination ++ (instancetype)frameworkDefinitionWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination { - - return [[XCFrameworkDefinition alloc] initWithFilePath:filePath copyToDestination:copyToDestination]; + return [[self alloc] initWithFilePath:filePath copyToDestination:copyToDestination]; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Initialization & Destruction -- (id)initWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination +- (instancetype)initWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestination { self = [super init]; if (self) @@ -41,7 +38,7 @@ - (id)initWithFilePath:(NSString*)filePath copyToDestination:(BOOL)copyToDestina return self; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Interface Methods - (NSString*)name @@ -49,5 +46,4 @@ - (NSString*)name return [_filePath lastPathComponent]; } - -@end \ No newline at end of file +@end diff --git a/Source/XCGroup.h b/Source/SXCGroup.h similarity index 67% rename from Source/XCGroup.h rename to Source/SXCGroup.h index 37b2835..b7f0dcd 100755 --- a/Source/XCGroup.h +++ b/Source/SXCGroup.h @@ -9,43 +9,38 @@ // //////////////////////////////////////////////////////////////////////////////// - #import -#import "XcodeGroupMember.h" -@class XCProject; -@class XCClassDefinition; -@class XCSourceFile; -@class XCXibDefinition; -@class XCFileOperationQueue; -@class XCFrameworkDefinition; -@class XCSourceFileDefinition; -@class XCSubProjectDefinition; +#import "SXCXcodeGroupMember.h" +@class SXCClassDefinition; +@class SXCFileOperationQueue; +@class SXCFrameworkDefinition; +@class SXCProject; +@class SXCSourceFile; +@class SXCSourceFileDefinition; +@class SXCSubProjectDefinition; +@class SXCXibDefinition; /** * Represents a group container in an Xcode project. A group can contain members of type `XCSourceFile` or other * groups. */ -@interface XCGroup : NSObject +@interface SXCGroup : NSObject { - NSString* _pathRelativeToParent; NSString* _key; NSString* _alias; - @private NSString* _pathRelativeToProjectRoot; NSMutableArray* _children; NSMutableArray* _members; - XCFileOperationQueue* _fileOperationQueue; // weak - XCProject* _project; - + SXCFileOperationQueue* _fileOperationQueue; // weak + SXCProject* _project; } - /** * The alias of the group, which can be used to give the group a name other than the last path component. * @@ -70,20 +65,20 @@ */ @property(nonatomic, strong, readonly) NSMutableArray* children; - #pragma mark Initializers -+ (XCGroup*)groupWithProject:(XCProject*)project key:(NSString*)key alias:(NSString*)alias path:(NSString*)path children:(NSArray*)children; - -- (id)initWithProject:(XCProject*)project key:(NSString*)key alias:(NSString*)alias path:(NSString*)path children:(NSArray*)children; ++ (instancetype)groupWithProject:(SXCProject*)project + key:(NSString*)key + alias:(NSString*)alias + path:(NSString*)path + children:(NSArray*)children; #pragma mark Parent group - (void)removeFromParentGroup; - - (void)removeFromParentDeletingChildren:(BOOL)deleteChildren; -- (XCGroup*)parentGroup; +- (SXCGroup*)parentGroup; - (BOOL)isRootGroup; @@ -92,23 +87,23 @@ * Adds a class to the group, as specified by the ClassDefinition. If the group already contains a class by the same * name, the contents will be updated. */ -- (void)addClass:(XCClassDefinition*)classDefinition; +- (void)addClass:(SXCClassDefinition*)classDefinition; /** * Adds a class to the group, making it a member of the specified [targets](XCTarget). */ -- (void)addClass:(XCClassDefinition*)classDefinition toTargets:(NSArray*)targets; +- (void)addClass:(SXCClassDefinition*)classDefinition toTargets:(NSArray*)targets; /** * Adds a framework to the group. If the group already contains the framework, the contents will be updated if the * framework definition's copyToDestination flag is yes, otherwise it will be ignored. */ -- (void)addFramework:(XCFrameworkDefinition*)frameworkDefinition; +- (void)addFramework:(SXCFrameworkDefinition*)frameworkDefinition; /** * Adds a group with a path relative to this group. */ -- (XCGroup*)addGroupWithPath:(NSString*)path; +- (SXCGroup*)addGroupWithPath:(NSString*)path; /** * Adds a reference to a folder @@ -118,23 +113,22 @@ /** * Adds a framework to the group, making it a member of the specified targets. */ -- (void)addFramework:(XCFrameworkDefinition*)framework toTargets:(NSArray*)targets; +- (void)addFramework:(SXCFrameworkDefinition*)framework toTargets:(NSArray*)targets; /** * Adds a source file of arbitrary type - image resource, header, etc. */ -- (void)addSourceFile:(XCSourceFileDefinition*)sourceFileDefinition; - +- (void)addSourceFile:(SXCSourceFileDefinition*)sourceFileDefinition; /** * Adds a xib file to the group. If the group already contains a class by the same name, the contents will be updated. */ -- (void)addXib:(XCXibDefinition*)xibDefinition; +- (void)addXib:(SXCXibDefinition*)xibDefinition; /** * Adds a xib to the group, making it a member of the specified [targets](XCTarget). */ -- (void)addXib:(XCXibDefinition*)xibDefinition toTargets:(NSArray*)targets; +- (void)addXib:(SXCXibDefinition*)xibDefinition toTargets:(NSArray*)targets; /** * Adds a sub-project to the group. If the group already contains a sub-project by the same name, the contents will be @@ -142,19 +136,19 @@ * Returns boolean success/fail; if method fails, caller should assume that project file is corrupt (or file format has * changed). */ -- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition; +- (void)addSubProject:(SXCSubProjectDefinition*)projectDefinition; /** * Adds a sub-project to the group, making it a member of the specified [targets](XCTarget). */ -- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition toTargets:(NSArray*)targets; - -- (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition; +- (void)addSubProject:(SXCSubProjectDefinition*)projectDefinition toTargets:(NSArray*)targets; -- (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets:(NSArray*)targets; +- (void)removeSubProject:(SXCSubProjectDefinition*)projectDefinition; +- (void)removeSubProject:(SXCSubProjectDefinition*)projectDefinition fromTargets:(NSArray*)targets; #pragma mark Locating children + /** * Instances of `XCSourceFile` and `XCGroup` returned as the type `XcodeGroupMember`. */ @@ -165,18 +159,16 @@ */ - (NSArray*)recursiveMembers; - - (NSArray*)buildFileKeys; /** * Returns the child with the specified key, or nil. */ -- (id )memberWithKey:(NSString*)key; +- (id )memberWithKey:(NSString*)key; /** * Returns the child with the specified name, or nil. */ -- (id )memberWithDisplayName:(NSString*)name; - +- (id )memberWithDisplayName:(NSString*)name; @end diff --git a/Source/XCGroup.m b/Source/SXCGroup.m similarity index 59% rename from Source/XCGroup.m rename to Source/SXCGroup.m index 092ab42..96a39b9 100755 --- a/Source/XCGroup.m +++ b/Source/SXCGroup.m @@ -9,40 +9,44 @@ // //////////////////////////////////////////////////////////////////////////////// - - -#import "XCFrameworkDefinition.h" -#import "XCTarget.h" -#import "XCFileOperationQueue.h" -#import "XCXibDefinition.h" -#import "XCSourceFile.h" -#import "XCGroup.h" -#import "XCProject.h" -#import "XCClassDefinition.h" -#import "Utils/XCKeyBuilder.h" -#import "XCSourceFileDefinition.h" -#import "XCSubProjectDefinition.h" -#import "XCProject+SubProject.h" - - -@implementation XCGroup - +#import "SXCGroup.h" + +#import "SXCClassDefinition.h" +#import "SXCFileOperationQueue.h" +#import "SXCFrameworkDefinition.h" +#import "SXCProject+SubProject.h" +#import "SXCProject.h" +#import "SXCSourceFile.h" +#import "SXCSourceFileDefinition.h" +#import "SXCSubProjectDefinition.h" +#import "SXCTarget.h" +#import "SXCXibDefinition.h" +#import "Utils/SXCKeyBuilder.h" + +@implementation SXCGroup //------------------------------------------------------------------------------------------- #pragma mark - Class Methods //------------------------------------------------------------------------------------------- -+ (XCGroup*)groupWithProject:(XCProject*)project key:(NSString*)key alias:(NSString*)alias path:(NSString*)path children:(NSArray*)children ++ (instancetype)groupWithProject:(SXCProject*)project + key:(NSString*)key + alias:(NSString*)alias + path:(NSString*)path + children:(NSArray*)children { - - return [[XCGroup alloc] initWithProject:project key:key alias:alias path:path children:children]; + return [[self alloc] initWithProject:project key:key alias:alias path:path children:children]; } //------------------------------------------------------------------------------------------- #pragma mark - Initialization & Destruction //------------------------------------------------------------------------------------------- -- (id)initWithProject:(XCProject*)project key:(NSString*)key alias:(NSString*)alias path:(NSString*)path children:(NSArray*)children +- (instancetype)initWithProject:(SXCProject*)project + key:(NSString*)key + alias:(NSString*)alias + path:(NSString*)path + children:(NSArray*)children { self = [super init]; if (self) @@ -73,29 +77,22 @@ - (void)removeFromParentGroup [self removeFromParentDeletingChildren:NO]; } - - (void)removeFromParentDeletingChildren:(BOOL)deleteChildren { if (deleteChildren) { [_fileOperationQueue queueDeletion:[self pathRelativeToProjectRoot]]; } - NSDictionary* dictionary = [_project objects][_key]; - NSLog(@"Here's the dictionary: %@", dictionary); - [[_project objects] removeObjectForKey:_key]; + [_project.objects removeObjectForKey:_key]; - dictionary = [_project objects][_key]; - NSLog(@"Here's the dictionary: %@", dictionary); - - for (XCTarget* target in [_project targets]) + for (SXCTarget* target in [_project targets]) { [target removeMembersWithKeys:[self recursiveMembers]]; } - NSLog(@"Done!!!"); } -- (XCGroup*)parentGroup +- (SXCGroup*)parentGroup { return [_project groupForGroupMemberWithKey:_key]; } @@ -105,59 +102,65 @@ - (BOOL)isRootGroup return [self pathRelativeToParent] == nil && [self displayName] == nil; } - //------------------------------------------------------------------------------------------- #pragma mark Adding children - -- (void)addClass:(XCClassDefinition*)classDefinition +- (void)addClass:(SXCClassDefinition*)classDefinition { - if ([classDefinition header]) { - [self makeGroupMemberWithName:[classDefinition headerFileName] contents:[classDefinition header] type:SourceCodeHeader - fileOperationStyle:[classDefinition fileOperationType]]; + [self makeGroupMemberWithName:[classDefinition headerFileName] + contents:[classDefinition header] + type:SXCXcodeFileTypeSourceCodeHeader + fileOperationStyle:[classDefinition fileOperationType]]; } if ([classDefinition isObjectiveC]) { - [self makeGroupMemberWithName:[classDefinition sourceFileName] contents:[classDefinition source] type:SourceCodeObjC - fileOperationStyle:[classDefinition fileOperationType]]; + [self makeGroupMemberWithName:[classDefinition sourceFileName] + contents:[classDefinition source] + type:SXCXcodeFileTypeSourceCodeObjC + fileOperationStyle:[classDefinition fileOperationType]]; } else if ([classDefinition isObjectiveCPlusPlus]) { - [self makeGroupMemberWithName:[classDefinition sourceFileName] contents:[classDefinition source] type:SourceCodeObjCPlusPlus - fileOperationStyle:[classDefinition fileOperationType]]; + [self makeGroupMemberWithName:[classDefinition sourceFileName] + contents:[classDefinition source] + type:SXCXcodeFileTypeSourceCodeObjCPlusPlus + fileOperationStyle:[classDefinition fileOperationType]]; } - [_project objects][_key] = [self asDictionary]; + _project.objects[_key] = [self asDictionary]; } - -- (void)addClass:(XCClassDefinition*)classDefinition toTargets:(NSArray*)targets +- (void)addClass:(SXCClassDefinition*)classDefinition toTargets:(NSArray*)targets { [self addClass:classDefinition]; - XCSourceFile* sourceFile = [_project fileWithName:[classDefinition sourceFileName]]; + SXCSourceFile* sourceFile = [_project fileWithName:[classDefinition sourceFileName]]; [self addSourceFile:sourceFile toTargets:targets]; } -- (void)addFramework:(XCFrameworkDefinition*)frameworkDefinition +- (void)addFramework:(SXCFrameworkDefinition*)frameworkDefinition { + NSMutableDictionary* objects = _project.objects; if (([self memberWithDisplayName:[frameworkDefinition name]]) == nil) { NSDictionary* fileReference; if ([frameworkDefinition copyToDestination]) { - fileReference = [self makeFileReferenceWithPath:[frameworkDefinition name] name:nil type:Framework]; + fileReference = [self makeFileReferenceWithPath:[frameworkDefinition name] + name:nil + type:SXCXcodeFileTypeFramework]; BOOL copyFramework = NO; - if ([frameworkDefinition fileOperationType] == XCFileOperationTypeOverwrite) + if ([frameworkDefinition fileOperationType] == SXCFileOperationTypeOverwrite) { copyFramework = YES; } - else if ([frameworkDefinition fileOperationType] == XCFileOperationTypeAcceptExisting) + else if ([frameworkDefinition fileOperationType] == SXCFileOperationTypeAcceptExisting) { NSString* frameworkName = [[frameworkDefinition filePath] lastPathComponent]; - if (![_fileOperationQueue fileWithName:frameworkName existsInProjectDirectory:[self pathRelativeToProjectRoot]]) + if (![_fileOperationQueue fileWithName:frameworkName + existsInProjectDirectory:[self pathRelativeToProjectRoot]]) { copyFramework = YES; } @@ -166,106 +169,120 @@ - (void)addFramework:(XCFrameworkDefinition*)frameworkDefinition if (copyFramework) { [_fileOperationQueue queueFrameworkWithFilePath:[frameworkDefinition filePath] - inDirectory:[self pathRelativeToProjectRoot]]; + inDirectory:[self pathRelativeToProjectRoot]]; } } else { NSString* path = [frameworkDefinition filePath]; NSString* name = [frameworkDefinition name]; - fileReference = [self makeFileReferenceWithPath:path name:name type:Framework]; + fileReference = [self makeFileReferenceWithPath:path name:name type:SXCXcodeFileTypeFramework]; } - NSString* frameworkKey = [[XCKeyBuilder forItemNamed:[frameworkDefinition name]] build]; - [_project objects][frameworkKey] = fileReference; + NSString* frameworkKey = [[SXCKeyBuilder forItemNamed:[frameworkDefinition name]] build]; + objects[frameworkKey] = fileReference; [self addMemberWithKey:frameworkKey]; } - [_project objects][_key] = [self asDictionary]; + objects[_key] = [self asDictionary]; } - -- (void)addFramework:(XCFrameworkDefinition*)frameworkDefinition toTargets:(NSArray*)targets +- (void)addFramework:(SXCFrameworkDefinition*)frameworkDefinition toTargets:(NSArray*)targets { [self addFramework:frameworkDefinition]; - XCSourceFile* frameworkSourceRef = (XCSourceFile*) [self memberWithDisplayName:[frameworkDefinition name]]; + SXCSourceFile* frameworkSourceRef = (SXCSourceFile*) [self memberWithDisplayName:[frameworkDefinition name]]; [self addSourceFile:frameworkSourceRef toTargets:targets]; } - - (void)addFolderReference:(NSString*)sourceFolder { - NSDictionary *folderReferenceDictionary = [self makeFileReferenceWithPath:sourceFolder name:[sourceFolder lastPathComponent] type:Folder]; - NSString* folderReferenceKey = [[XCKeyBuilder forItemNamed:[sourceFolder lastPathComponent]] build]; + NSString* folderName = [sourceFolder lastPathComponent]; + NSDictionary *folderReferenceDictionary = [self makeFileReferenceWithPath:sourceFolder + name:folderName + type:SXCXcodeFileTypeFolder]; + NSString* folderReferenceKey = [[SXCKeyBuilder forItemNamed:[sourceFolder lastPathComponent]] build]; [self addMemberWithKey:folderReferenceKey]; - [_project objects][folderReferenceKey] = folderReferenceDictionary; - [_project objects][_key] = [self asDictionary]; + + NSMutableDictionary* objects = _project.objects; + objects[folderReferenceKey] = folderReferenceDictionary; + objects[_key] = [self asDictionary]; } -- (XCGroup*)addGroupWithPath:(NSString*)path +- (SXCGroup*)addGroupWithPath:(NSString*)path { - NSString* groupKeyPath = self.pathRelativeToProjectRoot ? [self.pathRelativeToProjectRoot stringByAppendingPathComponent:path] : path; + NSString* groupKeyPath = self.pathRelativeToProjectRoot + ? [self.pathRelativeToProjectRoot stringByAppendingPathComponent:path] + : path; - NSString* groupKey = [[XCKeyBuilder forItemNamed:groupKeyPath] build]; + NSString* groupKey = [[SXCKeyBuilder forItemNamed:groupKeyPath] build]; NSArray* members = [self members]; - for (id groupMember in members) + for (id groupMember in members) { - if ([groupMember groupMemberType] == PBXGroupType || [groupMember groupMemberType] == PBXVariantGroupType) + SXCXcodeMemberType groupMemberType = [groupMember groupMemberType]; + if (groupMemberType == SXCXcodeMemberTypePBXGroup || + groupMemberType == SXCXcodeMemberTypePBXVariantGroup) { if ([[[groupMember pathRelativeToProjectRoot] lastPathComponent] isEqualToString:path] || - [[groupMember displayName] isEqualToString:path] || [[groupMember key] isEqualToString:groupKey]) + [[groupMember displayName] isEqualToString:path] || + [[groupMember key] isEqualToString:groupKey]) { return nil; } } } - XCGroup* group = [[XCGroup alloc] initWithProject:_project key:groupKey alias:nil path:path children:nil]; + SXCGroup* group = [[SXCGroup alloc] initWithProject:_project key:groupKey alias:nil path:path children:nil]; NSDictionary* groupDict = [group asDictionary]; - [_project objects][groupKey] = groupDict; + NSMutableDictionary* objects = _project.objects; + objects[groupKey] = groupDict; [_fileOperationQueue queueDirectory:path inDirectory:[self pathRelativeToProjectRoot]]; [self addMemberWithKey:groupKey]; NSDictionary* dict = [self asDictionary]; - [_project objects][_key] = dict; + objects[_key] = dict; return group; } -- (void)addSourceFile:(XCSourceFileDefinition*)sourceFileDefinition +- (void)addSourceFile:(SXCSourceFileDefinition*)sourceFileDefinition { - [self makeGroupMemberWithName:[sourceFileDefinition sourceFileName] contents:[sourceFileDefinition data] - type:[sourceFileDefinition type] fileOperationStyle:[sourceFileDefinition fileOperationType]]; - [_project objects][_key] = [self asDictionary]; + [self makeGroupMemberWithName:[sourceFileDefinition sourceFileName] + contents:[sourceFileDefinition data] + type:[sourceFileDefinition type] + fileOperationStyle:[sourceFileDefinition fileOperationType]]; + _project.objects[_key] = [self asDictionary]; } -- (void)addXib:(XCXibDefinition*)xibDefinition +- (void)addXib:(SXCXibDefinition*)xibDefinition { - [self makeGroupMemberWithName:[xibDefinition xibFileName] contents:[xibDefinition content] type:XibFile - fileOperationStyle:[xibDefinition fileOperationType]]; - [_project objects][_key] = [self asDictionary]; + [self makeGroupMemberWithName:[xibDefinition xibFileName] + contents:[xibDefinition content] + type:SXCXcodeFileTypeXibFile + fileOperationStyle:[xibDefinition fileOperationType]]; + _project.objects[_key] = [self asDictionary]; } -- (void)addXib:(XCXibDefinition*)xibDefinition toTargets:(NSArray*)targets +- (void)addXib:(SXCXibDefinition*)xibDefinition toTargets:(NSArray*)targets { [self addXib:xibDefinition]; - XCSourceFile* sourceFile = [_project fileWithName:[xibDefinition xibFileName]]; + SXCSourceFile* sourceFile = [_project fileWithName:[xibDefinition xibFileName]]; [self addSourceFile:sourceFile toTargets:targets]; } - // adds an xcodeproj as a subproject of the current project. -- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition +- (void)addSubProject:(SXCSubProjectDefinition*)projectDefinition { // set up path to the xcodeproj file as Xcode sees it - path to top level of project + group path if any - [projectDefinition initFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]]; + [projectDefinition setFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]]; // create PBXFileReference for xcodeproj file and add to PBXGroup for the current group // (will retrieve existing if already there) - [self makeGroupMemberWithName:[projectDefinition projectFileName] path:[projectDefinition pathRelativeToProjectRoot] type:XcodeProject - fileOperationStyle:[projectDefinition fileOperationType]]; - [_project objects][_key] = [self asDictionary]; + [self makeGroupMemberWithName:[projectDefinition projectFileName] + path:[projectDefinition pathRelativeToProjectRoot] + type:SXCXcodeFileTypeXcodeProject + fileOperationStyle:[projectDefinition fileOperationType]]; + _project.objects[_key] = [self asDictionary]; // create PBXContainerItemProxies and PBXReferenceProxies [_project addProxies:projectDefinition]; @@ -276,13 +293,13 @@ - (void)addSubProject:(XCSubProjectDefinition*)projectDefinition // adds an xcodeproj as a subproject of the current project, and also adds all build products except for test bundle(s) // to targets. -- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition toTargets:(NSArray*)targets +- (void)addSubProject:(SXCSubProjectDefinition*)projectDefinition toTargets:(NSArray*)targets { [self addSubProject:projectDefinition]; // add subproject's build products to targets (does not add the subproject's test bundle) NSArray* buildProductFiles = [_project buildProductsForTargets:[projectDefinition projectKey]]; - for (XCSourceFile* file in buildProductFiles) + for (SXCSourceFile* file in buildProductFiles) { [self addSourceFile:file toTargets:targets]; } @@ -291,7 +308,7 @@ - (void)addSubProject:(XCSubProjectDefinition*)projectDefinition toTargets:(NSAr } // removes an xcodeproj from the current project. -- (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition +- (void)removeSubProject:(SXCSubProjectDefinition*)projectDefinition { if (projectDefinition == nil) { @@ -299,7 +316,7 @@ - (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition } // set up path to the xcodeproj file as Xcode sees it - path to top level of project + group path if any - [projectDefinition initFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]]; + [projectDefinition setFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]]; NSString* xcodeprojKey = [projectDefinition projectKey]; @@ -319,13 +336,13 @@ - (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition [self removeProductsGroupFromProject:productsGroupKey]; // remove Products group - [[_project objects] removeObjectForKey:productsGroupKey]; + [_project.objects removeObjectForKey:productsGroupKey]; // remove from all targets [_project removeTargetDependencies:[projectDefinition name]]; } -- (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets:(NSArray*)targets +- (void)removeSubProject:(SXCSubProjectDefinition*)projectDefinition fromTargets:(NSArray*)targets { if (projectDefinition == nil) { @@ -333,7 +350,7 @@ - (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets: } // set up path to the xcodeproj file as Xcode sees it - path to top level of project + group path if any - [projectDefinition initFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]]; + [projectDefinition setFullProjectPath:_project.filePath groupPath:[self pathRelativeToParent]]; NSString* xcodeprojKey = [projectDefinition projectKey]; @@ -342,10 +359,11 @@ - (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets: [self removeProductsGroupFromProject:productsGroupKey]; // Remove the PBXContainerItemProxy for this xcodeproj with proxyType 1 - NSString* containerItemProxyKey = [_project containerItemProxyKeyForName:[projectDefinition pathRelativeToProjectRoot] proxyType:@"1"]; + NSString* containerItemProxyKey = + [_project containerItemProxyKeyForName:[projectDefinition pathRelativeToProjectRoot] proxyType:@"1"]; if (containerItemProxyKey != nil) { - [[_project objects] removeObjectForKey:containerItemProxyKey]; + [_project.objects removeObjectForKey:containerItemProxyKey]; } // Remove PBXTargetDependency and entry in PBXNativeTarget @@ -362,15 +380,16 @@ - (NSArray*)members _members = [[NSMutableArray alloc] init]; for (NSString* childKey in _children) { - XcodeMemberType type = [self typeForKey:childKey]; + SXCXcodeMemberType type = [self typeForKey:childKey]; @autoreleasepool { - if (type == PBXGroupType || type == PBXVariantGroupType) + if (type == SXCXcodeMemberTypePBXGroup || + type == SXCXcodeMemberTypePBXVariantGroup) { [_members addObject:[_project groupWithKey:childKey]]; } - else if (type == PBXFileReferenceType) + else if (type == SXCXcodeMemberTypePBXFileReference) { [_members addObject:[_project fileWithKey:childKey]]; } @@ -385,14 +404,15 @@ - (NSArray*)recursiveMembers NSMutableArray* recursiveMembers = [NSMutableArray array]; for (NSString* childKey in _children) { - XcodeMemberType type = [self typeForKey:childKey]; - if (type == PBXGroupType || type == PBXVariantGroupType) + SXCXcodeMemberType type = [self typeForKey:childKey]; + if (type == SXCXcodeMemberTypePBXGroup || + type == SXCXcodeMemberTypePBXVariantGroup) { - XCGroup* group = [_project groupWithKey:childKey]; + SXCGroup* group = [_project groupWithKey:childKey]; NSArray* groupChildren = [group recursiveMembers]; [recursiveMembers addObjectsFromArray:groupChildren]; } - else if (type == PBXFileReferenceType) + else if (type == SXCXcodeMemberTypePBXFileReference) { [recursiveMembers addObject:childKey]; } @@ -403,17 +423,17 @@ - (NSArray*)recursiveMembers - (NSArray*)buildFileKeys { - NSMutableArray* arrayOfBuildFileKeys = [NSMutableArray array]; - for (id groupMember in [self members]) + for (id groupMember in [self members]) { - - if ([groupMember groupMemberType] == PBXGroupType || [groupMember groupMemberType] == PBXVariantGroupType) + SXCXcodeMemberType groupMemberType = [groupMember groupMemberType]; + if (groupMemberType == SXCXcodeMemberTypePBXGroup || + groupMemberType == SXCXcodeMemberTypePBXVariantGroup) { - XCGroup* group = (XCGroup*) groupMember; + SXCGroup* group = (SXCGroup*) groupMember; [arrayOfBuildFileKeys addObjectsFromArray:[group buildFileKeys]]; } - else if ([groupMember groupMemberType] == PBXFileReferenceType) + else if (groupMemberType == SXCXcodeMemberTypePBXFileReference) { [arrayOfBuildFileKeys addObject:[groupMember key]]; } @@ -421,18 +441,19 @@ - (NSArray*)buildFileKeys return arrayOfBuildFileKeys; } -- (id )memberWithKey:(NSString*)key +- (id )memberWithKey:(NSString*)key { - id groupMember = nil; + id groupMember = nil; if ([_children containsObject:key]) { - XcodeMemberType type = [self typeForKey:key]; - if (type == PBXGroupType || type == PBXVariantGroupType) + SXCXcodeMemberType type = [self typeForKey:key]; + if (type == SXCXcodeMemberTypePBXGroup || + type == SXCXcodeMemberTypePBXVariantGroup) { groupMember = [_project groupWithKey:key]; } - else if (type == PBXFileReferenceType) + else if (type == SXCXcodeMemberTypePBXFileReference) { groupMember = [_project fileWithKey:key]; } @@ -440,9 +461,9 @@ - (NSArray*)buildFileKeys return groupMember; } -- (id )memberWithDisplayName:(NSString*)name +- (id )memberWithDisplayName:(NSString*)name { - for (id member in [self members]) + for (id member in [self members]) { if ([[member displayName] isEqualToString:name]) { @@ -455,7 +476,7 @@ - (NSArray*)buildFileKeys //------------------------------------------------------------------------------------------- #pragma mark - Protocol Methods -- (XcodeMemberType)groupMemberType +- (SXCXcodeMemberType)groupMemberType { return [self typeForKey:self.key]; } @@ -474,10 +495,11 @@ - (NSString*)pathRelativeToProjectRoot if (_pathRelativeToProjectRoot == nil) { NSMutableArray* pathComponents = [[NSMutableArray alloc] init]; - XCGroup* group = nil; + SXCGroup* group = nil; NSString* key = [_key copy]; - while ((group = [_project groupForGroupMemberWithKey:key]) != nil && [group pathRelativeToParent] != nil) + while ((group = [_project groupForGroupMemberWithKey:key]) != nil && + [group pathRelativeToParent] != nil) { [pathComponents addObject:[group pathRelativeToParent]]; key = [[group key] copy]; @@ -507,7 +529,6 @@ - (NSString*)description - (void)addMemberWithKey:(NSString*)key { - for (NSString* childKey in _children) { if ([childKey isEqualToString:key]) @@ -527,17 +548,18 @@ - (void)flagMembersAsDirty //------------------------------------------------------------------------------------------- -- (void)makeGroupMemberWithName:(NSString*)name contents:(id)contents type:(XcodeSourceFileType)type - fileOperationStyle:(XCFileOperationType)fileOperationStyle +- (void)makeGroupMemberWithName:(NSString*)name + contents:(id)contents + type:(SXCXcodeFileType)type + fileOperationStyle:(SXCFileOperationType)fileOperationStyle { - NSString* filePath; - XCSourceFile* currentSourceFile = (XCSourceFile*) [self memberWithDisplayName:name]; + SXCSourceFile* currentSourceFile = (SXCSourceFile*) [self memberWithDisplayName:name]; if ((currentSourceFile) == nil) { NSDictionary* reference = [self makeFileReferenceWithPath:name name:nil type:type]; - NSString* fileKey = [[XCKeyBuilder forItemNamed:name] build]; - [_project objects][fileKey] = reference; + NSString* fileKey = [[SXCKeyBuilder forItemNamed:name] build]; + _project.objects[fileKey] = reference; [self addMemberWithKey:fileKey]; filePath = [self pathRelativeToProjectRoot]; } @@ -547,12 +569,12 @@ - (void)makeGroupMemberWithName:(NSString*)name contents:(id)contents type:(Xcod } BOOL writeFile = NO; - if (fileOperationStyle == XCFileOperationTypeOverwrite) + if (fileOperationStyle == SXCFileOperationTypeOverwrite) { writeFile = YES; [_fileOperationQueue fileWithName:name existsInProjectDirectory:filePath]; } - else if (fileOperationStyle == XCFileOperationTypeAcceptExisting && + else if (fileOperationStyle == SXCFileOperationTypeAcceptExisting && ![_fileOperationQueue fileWithName:name existsInProjectDirectory:filePath]) { writeFile = YES; @@ -576,21 +598,23 @@ - (void)makeGroupMemberWithName:(NSString*)name contents:(id)contents type:(Xcod // creates PBXFileReference and adds to group if not already there; returns key for file reference. Locates // member via path rather than name, because that is how subprojects are stored by Xcode -- (void)makeGroupMemberWithName:(NSString*)name path:(NSString*)path type:(XcodeSourceFileType)type - fileOperationStyle:(XCFileOperationType)fileOperationStyle +- (void)makeGroupMemberWithName:(NSString*)name + path:(NSString*)path + type:(SXCXcodeFileType)type + fileOperationStyle:(SXCFileOperationType)fileOperationStyle { - XCSourceFile* currentSourceFile = (XCSourceFile*) [self memberWithDisplayName:name]; + SXCSourceFile* currentSourceFile = (SXCSourceFile*) [self memberWithDisplayName:name]; if ((currentSourceFile) == nil) { NSDictionary* reference = [self makeFileReferenceWithPath:path name:name type:type]; - NSString* fileKey = [[XCKeyBuilder forItemNamed:name] build]; - [_project objects][fileKey] = reference; + NSString* fileKey = [[SXCKeyBuilder forItemNamed:name] build]; + _project.objects[fileKey] = reference; [self addMemberWithKey:fileKey]; } } // makes a new group called Products and returns its key -- (NSString*)makeProductsGroup:(XCSubProjectDefinition*)xcodeprojDefinition +- (NSString*)makeProductsGroup:(SXCSubProjectDefinition*)xcodeprojDefinition { NSMutableArray* children = [NSMutableArray array]; NSString* uniquer = @""; @@ -599,15 +623,19 @@ - (NSString*)makeProductsGroup:(XCSubProjectDefinition*)xcodeprojDefinition [children addObject:[_project referenceProxyKeyForName:productName]]; uniquer = [uniquer stringByAppendingString:productName]; } - NSString* productKey = [[XCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-Products", uniquer]] build]; - XCGroup* productsGroup = [XCGroup groupWithProject:_project key:productKey alias:@"Products" path:nil children:children]; - [_project objects][productKey] = [productsGroup asDictionary]; + NSString* productKey = [[SXCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-Products", uniquer]] build]; + SXCGroup* productsGroup = [SXCGroup groupWithProject:_project + key:productKey + alias:@"Products" + path:nil + children:children]; + _project.objects[productKey] = [productsGroup asDictionary]; return productKey; } // makes a new Products group (by calling the method above), makes a new projectReferences array for it and // then adds it to the PBXProject object -- (void)addProductsGroupToProject:(XCSubProjectDefinition*)xcodeprojDefinition +- (void)addProductsGroupToProject:(SXCSubProjectDefinition*)xcodeprojDefinition { NSString* productKey = [self makeProductsGroup:xcodeprojDefinition]; @@ -642,13 +670,17 @@ - (void)removeGroupMemberWithKey:(NSString*)key // they are not required because we are currently not adding these entries; Xcode is doing it for us. The existing // code for adding to a target doesn't do it, and I didn't add it since Xcode will take care of it for me and I was // avoiding modifying existing code as much as possible) -- (void)removeBuildPhaseFileKey:(NSString*)key forType:(XcodeMemberType)memberType +- (void)removeBuildPhaseFileKey:(NSString*)key forType:(SXCXcodeMemberType)memberType { - NSArray* buildPhases = [_project keysForProjectObjectsOfType:memberType withIdentifier:nil singleton:NO required:NO]; + NSArray* buildPhases = [_project keysForProjectObjectsOfType:memberType + withIdentifier:nil + singleton:NO + required:NO]; + NSDictionary* objects = _project.objects; for (NSString* buildPhaseKey in buildPhases) { - NSDictionary* buildPhaseDict = [[_project objects] valueForKey:buildPhaseKey]; - NSMutableArray* fileKeys = [buildPhaseDict valueForKey:@"files"]; + NSDictionary* buildPhaseDict = objects[buildPhaseKey]; + NSMutableArray* fileKeys = buildPhaseDict[@"files"]; for (NSString* fileKey in fileKeys) { if ([fileKey isEqualToString:key]) @@ -662,18 +694,22 @@ - (void)removeBuildPhaseFileKey:(NSString*)key forType:(XcodeMemberType)memberTy // removes entries from PBXBuildFiles, PBXFrameworksBuildPhase and PBXResourcesBuildPhase - (void)removeProductsGroupFromProject:(NSString*)key { + NSMutableDictionary* objects = _project.objects; // remove product group's build products from PDXBuildFiles - NSDictionary* productsGroup = _project.objects[key]; + NSDictionary* productsGroup = objects[key]; for (NSString* childKey in [productsGroup valueForKey:@"children"]) { - NSArray* buildFileKeys = [_project keysForProjectObjectsOfType:PBXBuildFileType withIdentifier:childKey singleton:NO required:NO]; + NSArray* buildFileKeys = [_project keysForProjectObjectsOfType:SXCXcodeMemberTypePBXBuildFile + withIdentifier:childKey + singleton:NO + required:NO]; // could be zero - we didn't add the test bundle as a build product if ([buildFileKeys count] == 1) { NSString* buildFileKey = buildFileKeys[0]; - [[_project objects] removeObjectForKey:buildFileKey]; - [self removeBuildPhaseFileKey:buildFileKey forType:PBXFrameworksBuildPhaseType]; - [self removeBuildPhaseFileKey:buildFileKey forType:PBXResourcesBuildPhaseType]; + [objects removeObjectForKey:buildFileKey]; + [self removeBuildPhaseFileKey:buildFileKey forType:SXCXcodeMemberTypePBXFrameworksBuildPhase]; + [self removeBuildPhaseFileKey:buildFileKey forType:SXCXcodeMemberTypePBXResourcesBuildPhase]; } } } @@ -682,12 +718,12 @@ - (void)removeProductsGroupFromProject:(NSString*)key #pragma mark Dictionary Representations -- (NSDictionary*)makeFileReferenceWithPath:(NSString*)path name:(NSString*)name type:(XcodeSourceFileType)type +- (NSDictionary*)makeFileReferenceWithPath:(NSString*)path name:(NSString*)name type:(SXCXcodeFileType)type { NSMutableDictionary* reference = [NSMutableDictionary dictionary]; - reference[@"isa"] = [NSString stringFromMemberType:PBXFileReferenceType]; + reference[@"isa"] = [NSString sxc_stringFromMemberType:SXCXcodeMemberTypePBXFileReference]; reference[@"fileEncoding"] = @"4"; - reference[@"lastKnownFileType"] = NSStringFromXCSourceFileType(type); + reference[@"lastKnownFileType"] = SXCNSStringFromSXCXcodeFileType(type); if (name != nil) { reference[@"name"] = [name lastPathComponent]; @@ -700,11 +736,10 @@ - (NSDictionary*)makeFileReferenceWithPath:(NSString*)path name:(NSString*)name return reference; } - - (NSDictionary*)asDictionary { NSMutableDictionary* groupData = [NSMutableDictionary dictionary]; - groupData[@"isa"] = [NSString stringFromMemberType:PBXGroupType]; + groupData[@"isa"] = [NSString sxc_stringFromMemberType:SXCXcodeMemberTypePBXGroup]; groupData[@"sourceTree"] = @""; if (_alias != nil) @@ -725,18 +760,18 @@ - (NSDictionary*)asDictionary return groupData; } -- (XcodeMemberType)typeForKey:(NSString*)key +- (SXCXcodeMemberType)typeForKey:(NSString*)key { - NSDictionary* obj = [[_project objects] valueForKey:key]; - return [[obj valueForKey:@"isa"] asMemberType]; + NSDictionary* obj = _project.objects[key]; + return [obj[@"isa"] sxc_asMemberType]; } -- (void)addSourceFile:(XCSourceFile*)sourceFile toTargets:(NSArray*)targets +- (void)addSourceFile:(SXCSourceFile*)sourceFile toTargets:(NSArray*)targets { - for (XCTarget* target in targets) + for (SXCTarget* target in targets) { [target addMember:sourceFile]; } } -@end \ No newline at end of file +@end diff --git a/Source/XCProject+SubProject.h b/Source/SXCProject+SubProject.h similarity index 66% rename from Source/XCProject+SubProject.h rename to Source/SXCProject+SubProject.h index 5b304eb..5b95747 100644 --- a/Source/XCProject+SubProject.h +++ b/Source/SXCProject+SubProject.h @@ -9,28 +9,27 @@ // //////////////////////////////////////////////////////////////////////////////// - +#import "SXCProject.h" #import -#import "XCProject.h" - -@interface XCProject (SubProject) +@interface SXCProject (SubProject) - (NSString *)referenceProxyKeyForName:(NSString *)name; - (NSArray *)buildProductsForTargets:(NSString *)xcodeprojKey; -- (void)addAsTargetDependency:(XCSubProjectDefinition *)xcodeprojDefinition toTargets:(NSArray *)targets; +- (void)addAsTargetDependency:(SXCSubProjectDefinition *)xcodeprojDefinition toTargets:(NSArray *)targets; -- (NSArray *)keysForProjectObjectsOfType:(XcodeMemberType)memberType withIdentifier:(NSString *)identifier - singleton:(BOOL)singleton required:(BOOL)required; +- (NSArray *)keysForProjectObjectsOfType:(SXCXcodeMemberType)memberType + withIdentifier:(NSString *)identifier + singleton:(BOOL)singleton + required:(BOOL)required; - (NSMutableDictionary *)PBXProjectDict; - (void)removeProxies:(NSString *)xcodeprojKey; - -- (void)addProxies:(XCSubProjectDefinition *)xcodeproj; +- (void)addProxies:(SXCSubProjectDefinition *)xcodeproj; - (void)removeFromProjectReferences:(NSString *)key forProductsGroup:(NSString *)productsGroupKey; @@ -40,4 +39,4 @@ - (NSString *)productsGroupKeyForKey:(NSString *)key; -@end \ No newline at end of file +@end diff --git a/Source/XCProject+SubProject.m b/Source/SXCProject+SubProject.m similarity index 54% rename from Source/XCProject+SubProject.m rename to Source/SXCProject+SubProject.m index 055a496..3411c7d 100644 --- a/Source/XCProject+SubProject.m +++ b/Source/SXCProject+SubProject.m @@ -9,18 +9,14 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCProject+SubProject.h" +#import "SXCSourceFile.h" +#import "SXCSubProjectDefinition.h" +#import "SXCTarget.h" +#import "Utils/SXCKeyBuilder.h" -#import "XCSourceFile.h" -#import "XCTarget.h" -#import "Utils/XCKeyBuilder.h" -#import "XCProject+SubProject.h" -#import "XCSubProjectDefinition.h" -#import - - -@implementation XCProject (SubProject) - +@implementation SXCProject (SubProject) #pragma mark sub-project related public methods @@ -30,9 +26,9 @@ @implementation XCProject (SubProject) - (NSString *)referenceProxyKeyForName:(NSString *)name { __block NSString *result = nil; - [[self objects] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXReferenceProxyType) { - NSString *candidate = [obj valueForKey:@"path"]; + [self.objects enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { + if ([obj[@"isa"] sxc_hasReferenceProxyType]) { + NSString *candidate = obj[@"path"]; if ([candidate isEqualToString:name]) { result = key; *stop = YES; @@ -47,18 +43,23 @@ - (NSString *)referenceProxyKeyForName:(NSString *)name - (NSArray *)buildProductsForTargets:(NSString *)xcodeprojKey { NSMutableArray *results = [[NSMutableArray alloc] init]; - [[self objects] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXReferenceProxyType) { + NSMutableDictionary *objects = self.objects; + [objects enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { + if ([obj[@"isa"] sxc_hasReferenceProxyType]) { // make sure it belongs to the xcodeproj we're adding - NSString *remoteRef = [obj valueForKey:@"remoteRef"]; - NSDictionary *containerProxy = [[self objects] valueForKey:remoteRef]; - NSString *containerPortal = [containerProxy valueForKey:@"containerPortal"]; + NSString *remoteRef = obj[@"remoteRef"]; + NSDictionary *containerProxy = objects[remoteRef]; + NSString *containerPortal = containerProxy[@"containerPortal"]; if ([containerPortal isEqualToString:xcodeprojKey]) { - XcodeSourceFileType type = XCSourceFileTypeFromStringRepresentation([obj valueForKey:@"fileType"]); - NSString *path = (NSString *)[obj valueForKey:@"path"]; - if (type != Bundle || [[path pathExtension] isEqualToString:@"bundle"]) { - [results addObject:[XCSourceFile sourceFileWithProject:self key:key type:type name:path - sourceTree:nil path:nil]]; + SXCXcodeFileType type = SXCXcodeFileTypeFromStringRepresentation(obj[@"fileType"]); + NSString *path = (NSString *)obj[@"path"]; + if (type != SXCXcodeFileTypeBundle || [[path pathExtension] isEqualToString:@"bundle"]) { + [results addObject:[SXCSourceFile sourceFileWithProject:self + key:key + type:type + name:path + sourceTree:nil + path:nil]]; } } } @@ -68,16 +69,19 @@ - (NSArray *)buildProductsForTargets:(NSString *)xcodeprojKey // makes PBXContainerItemProxy and PBXTargetDependency objects for the xcodeproj, and adds the dependency key // to all the specified targets -- (void)addAsTargetDependency:(XCSubProjectDefinition *)xcodeprojDefinition toTargets:(NSArray *)targets +- (void)addAsTargetDependency:(SXCSubProjectDefinition *)xcodeprojDefinition toTargets:(NSArray *)targets { - for (XCTarget *target in targets) { + for (SXCTarget *target in targets) { // make a new PBXContainerItemProxy NSString *key = [[self fileWithName:[xcodeprojDefinition pathRelativeToProjectRoot]] key]; - NSString *containerItemProxyKey = [self makeContainerItemProxyForName:[xcodeprojDefinition name] fileRef:key - proxyType:@"1" uniqueName:[target name]]; + NSString *containerItemProxyKey = [self makeContainerItemProxyForName:[xcodeprojDefinition name] + fileRef:key + proxyType:@"1" + uniqueName:[target name]]; // make a PBXTargetDependency NSString *targetDependencyKey = [self makeTargetDependency:[xcodeprojDefinition name] - forContainerItemProxyKey:containerItemProxyKey uniqueName:[target name]]; + forContainerItemProxyKey:containerItemProxyKey + uniqueName:[target name]]; // add entry in each targets dependencies list [target addDependency:targetDependencyKey]; } @@ -86,65 +90,71 @@ - (void)addAsTargetDependency:(XCSubProjectDefinition *)xcodeprojDefinition toTa // returns an array of keys for all project objects (not just files) that match the given criteria. Since this is // a convenience method intended to save typing elsewhere, each type has its own field to match to rather than each // matching on name or path as you might expect. -- (NSArray *)keysForProjectObjectsOfType:(XcodeMemberType)memberType withIdentifier:(NSString *)identifier - singleton:(BOOL)singleton required:(BOOL)required +- (NSArray *)keysForProjectObjectsOfType:(SXCXcodeMemberType)memberType + withIdentifier:(NSString *)identifier + singleton:(BOOL)singleton + required:(BOOL)required { __block NSMutableArray *returnValue = [[NSMutableArray alloc] init]; - [[self objects] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == memberType) { - if (memberType == PBXContainerItemProxyType) { - if ([[obj valueForKey:@"containerPortal"] isEqualToString:identifier]) { + [self.objects enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { + if ([obj[@"isa"] sxc_asMemberType] == memberType) { + if (memberType == SXCXcodeMemberTypePBXContainerItemProxy) { + if ([obj[@"containerPortal"] isEqualToString:identifier]) { [returnValue addObject:key]; } } - else if (memberType == PBXReferenceProxyType) { - if ([[obj valueForKey:@"remoteRef"] isEqualToString:identifier]) { + else if (memberType == SXCXcodeMemberTypePBXReferenceProxy) { + if ([obj[@"remoteRef"] isEqualToString:identifier]) { [returnValue addObject:key]; } } - else if (memberType == PBXTargetDependencyType || memberType == PBXGroupType || memberType == PBXVariantGroupType) { - if ([[obj valueForKey:@"name"] isEqualToString:identifier]) { + else if (memberType == SXCXcodeMemberTypePBXTargetDependency || + memberType == SXCXcodeMemberTypePBXGroup || + memberType == SXCXcodeMemberTypePBXVariantGroup) { + if ([obj[@"name"] isEqualToString:identifier]) { [returnValue addObject:key]; } } - else if (memberType == PBXNativeTargetType) { - for (NSString *dependencyKey in [obj valueForKey:@"dependencies"]) { + else if (memberType == SXCXcodeMemberTypePBXNativeTarget) { + for (NSString *dependencyKey in obj[@"dependencies"]) { if ([dependencyKey isEqualToString:identifier]) { [returnValue addObject:key]; } } } - else if (memberType == PBXBuildFileType) { - if ([[obj valueForKey:@"fileRef"] isEqualToString:identifier]) { + else if (memberType == SXCXcodeMemberTypePBXBuildFile) { + if ([obj[@"fileRef"] isEqualToString:identifier]) { [returnValue addObject:key]; } } - else if (memberType == PBXProjectType) { + else if (memberType == SXCXcodeMemberTypePBXProject) { [returnValue addObject:key]; } - else if (memberType == PBXFileReferenceType) { - if ([[obj valueForKey:@"path"] isEqualToString:identifier]) { + else if (memberType == SXCXcodeMemberTypePBXFileReference) { + if ([obj[@"path"] isEqualToString:identifier]) { [returnValue addObject:key]; } } - else if (memberType == PBXFrameworksBuildPhaseType || memberType == PBXResourcesBuildPhaseType) { + else if (memberType == SXCXcodeMemberTypePBXFrameworksBuildPhase || + memberType == SXCXcodeMemberTypePBXResourcesBuildPhase) { [returnValue addObject:key]; } else { - [NSException raise:NSInvalidArgumentException format:@"Unrecognized member type %@", - [NSString stringFromMemberType:memberType]]; + [NSException raise:NSInvalidArgumentException + format:@"Unrecognized member type %@", [NSString sxc_stringFromMemberType:memberType]]; } } }]; if (singleton && [returnValue count] > 1) { [NSException raise:NSGenericException - format:@"Searched for one instance of member type %@ with value %@, but found %ld", - [NSString stringFromMemberType:memberType], identifier, (unsigned long) [returnValue count]]; + format:@"Searched for one instance of member type %@ with value %@, but found %ld", + [NSString sxc_stringFromMemberType:memberType], identifier, + (unsigned long) [returnValue count]]; } if (required && [returnValue count] == 0) { [NSException raise:NSGenericException - format:@"Searched for instances of member type %@ with value %@, but did not find any", - [NSString stringFromMemberType:memberType], identifier]; + format:@"Searched for instances of member type %@ with value %@, but did not find any", + [NSString sxc_stringFromMemberType:memberType], identifier]; } return returnValue; } @@ -153,10 +163,12 @@ - (NSArray *)keysForProjectObjectsOfType:(XcodeMemberType)memberType withIdentif - (NSMutableDictionary *)PBXProjectDict { NSString *PBXProjectKey; - NSArray *PBXProjectKeys = [self keysForProjectObjectsOfType:PBXProjectType withIdentifier:nil singleton:YES - required:YES]; + NSArray *PBXProjectKeys = [self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXProject + withIdentifier:nil + singleton:YES + required:YES]; PBXProjectKey = [PBXProjectKeys objectAtIndex:0]; - NSMutableDictionary *PBXProjectDict = [[self objects] valueForKey:PBXProjectKey]; + NSMutableDictionary *PBXProjectDict = self.objects[PBXProjectKey]; return PBXProjectDict; } @@ -164,10 +176,10 @@ - (NSMutableDictionary *)PBXProjectDict - (NSString *)containerItemProxyKeyForName:(NSString *)name proxyType:(NSString *)proxyType { NSMutableArray *results = [[NSMutableArray alloc] init]; - [[self objects] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXContainerItemProxyType) { - NSString *remoteInfo = [obj valueForKey:@"remoteInfo"]; - NSString *proxy = [obj valueForKey:@"proxyType"]; + [self.objects enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { + if ([obj[@"isa"] sxc_hasContainerItemProxyType]) { + NSString *remoteInfo = obj[@"remoteInfo"]; + NSString *proxy = obj[@"proxyType"]; if ([remoteInfo isEqualToString:name] && [proxy isEqualToString:proxyType]) { [results addObject:key]; } @@ -189,10 +201,11 @@ - (NSString *)containerItemProxyKeyForName:(NSString *)name proxyType:(NSString #pragma mark - Private Methods //------------------------------------------------------------------------------------------- - // makes a PBXContainerItemProxy object for a given PBXFileReference object. Replaces pre-existing objects. -- (NSString *)makeContainerItemProxyForName:(NSString *)name fileRef:(NSString *)fileRef proxyType:(NSString *)proxyType - uniqueName:(NSString *)uniqueName +- (NSString *)makeContainerItemProxyForName:(NSString *)name + fileRef:(NSString *)fileRef + proxyType:(NSString *)proxyType + uniqueName:(NSString *)uniqueName { NSString *keyName; if (uniqueName != nil) { @@ -201,55 +214,62 @@ - (NSString *)makeContainerItemProxyForName:(NSString *)name fileRef:(NSString * else { keyName = name; } + + NSMutableDictionary *objects = self.objects; + // remove old if it exists NSString *existingProxyKey = [self containerItemProxyKeyForName:keyName proxyType:proxyType]; if (existingProxyKey) { - [[self objects] removeObjectForKey:existingProxyKey]; + [objects removeObjectForKey:existingProxyKey]; } // make new one NSMutableDictionary *proxy = [NSMutableDictionary dictionary]; - proxy[@"isa"] = [NSString stringFromMemberType:PBXContainerItemProxyType]; + proxy[@"isa"] = [NSString sxc_stringFromMemberType:SXCXcodeMemberTypePBXContainerItemProxy]; proxy[@"containerPortal"] = fileRef; proxy[@"proxyType"] = proxyType; // give it a random key - the keys xcode puts here are not in the project file anywhere else - NSString *key = [[XCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-junk", keyName]] build]; + NSString *key = [[SXCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-junk", keyName]] build]; proxy[@"remoteGlobalIDString"] = key; proxy[@"remoteInfo"] = name; // add to project. use proxyType to generate key, so that multiple keys for the same name don't overwrite each other - key = [[XCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-containerProxy-%@", keyName, proxyType]] build]; - [self objects][key] = proxy; + key = [[SXCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-containerProxy-%@", keyName, proxyType]] build]; + objects[key] = proxy; return key; } // makes a PBXReferenceProxy object for a given PBXContainerProxy object. Replaces pre-existing objects. - (void)makeReferenceProxyForContainerItemProxy:(NSString *)containerItemProxyKey - buildProductReference:(NSDictionary *)buildProductReference + buildProductReference:(NSDictionary *)buildProductReference { - NSString *path = [buildProductReference valueForKey:@"path"]; + NSMutableDictionary *objects = self.objects; + NSString *path = buildProductReference[@"path"]; // remove old if any exists - NSArray *existingProxyKeys = [self keysForProjectObjectsOfType:PBXReferenceProxyType withIdentifier:path - singleton:NO required:NO]; + NSArray *existingProxyKeys = [self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXReferenceProxy + withIdentifier:path + singleton:NO + required:NO]; if ([existingProxyKeys count] > 0) { for (NSString *existingProxyKey in existingProxyKeys) { - [[self objects] removeObjectForKey:existingProxyKey]; + [objects removeObjectForKey:existingProxyKey]; } } // make new one NSMutableDictionary *proxy = [NSMutableDictionary dictionary]; - proxy[@"isa"] = [NSString stringFromMemberType:PBXReferenceProxyType]; + proxy[@"isa"] = [NSString sxc_stringFromMemberType:SXCXcodeMemberTypePBXReferenceProxy]; proxy[@"fileType"] = [buildProductReference valueForKey:@"explicitFileType"]; proxy[@"path"] = path; proxy[@"remoteRef"] = containerItemProxyKey; proxy[@"sourceTree"] = [buildProductReference valueForKey:@"sourceTree"]; // add to project - NSString *key = [[XCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-referenceProxy", path]] build]; - [self objects][key] = proxy; + NSString *key = [[SXCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-referenceProxy", path]] build]; + objects[key] = proxy; } // makes a PBXTargetDependency object for a given PBXContainerItemProxy. Replaces pre-existing objects. -- (NSString *)makeTargetDependency:(NSString *)name forContainerItemProxyKey:(NSString *)containerItemProxyKey - uniqueName:(NSString *)uniqueName +- (NSString *)makeTargetDependency:(NSString *)name + forContainerItemProxyKey:(NSString *)containerItemProxyKey + uniqueName:(NSString *)uniqueName { NSString *keyName; if (uniqueName != nil) { @@ -258,55 +278,72 @@ - (NSString *)makeTargetDependency:(NSString *)name forContainerItemProxyKey:(NS else { keyName = name; } + + NSMutableDictionary *objects = self.objects; + // remove old if it exists - NSArray *existingDependencyKeys = [self keysForProjectObjectsOfType:PBXTargetDependencyType withIdentifier:keyName - singleton:NO required:NO]; + NSArray *existingDependencyKeys = [self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXTargetDependency + withIdentifier:keyName + singleton:NO + required:NO]; if ([existingDependencyKeys count] > 0) { for (NSString *existingDependencyKey in existingDependencyKeys) { - [[self objects] removeObjectForKey:existingDependencyKey]; + [objects removeObjectForKey:existingDependencyKey]; } } // make new one NSMutableDictionary *targetDependency = [NSMutableDictionary dictionary]; - targetDependency[@"isa"] = [NSString stringFromMemberType:PBXTargetDependencyType]; + targetDependency[@"isa"] = [NSString sxc_stringFromMemberType:SXCXcodeMemberTypePBXTargetDependency]; targetDependency[@"name"] = name; targetDependency[@"targetProxy"] = containerItemProxyKey; - NSString *targetDependencyKey = [[XCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-targetProxy", keyName]] - build]; - [self objects][targetDependencyKey] = targetDependency; + NSString *targetDependencyKey = + [[SXCKeyBuilder forItemNamed:[NSString stringWithFormat:@"%@-targetProxy", keyName]] build]; + objects[targetDependencyKey] = targetDependency; return targetDependencyKey; } // make a PBXContainerItemProxy and PBXReferenceProxy for each target in the subProject -- (void)addProxies:(XCSubProjectDefinition *)xcodeproj +- (void)addProxies:(SXCSubProjectDefinition *)xcodeproj { NSString *fileRef = [[self fileWithName:[xcodeproj pathRelativeToProjectRoot]] key]; - for (NSDictionary *target in [xcodeproj.subProject targets]) { - NSString *containerItemProxyKey = [self makeContainerItemProxyForName:[target valueForKey:@"name"] - fileRef:fileRef proxyType:@"2" uniqueName:nil]; - NSString *productFileReferenceKey = [target valueForKey:@"productReference"]; - NSDictionary *productFileReference = [[xcodeproj.subProject objects] valueForKey:productFileReferenceKey]; + SXCProject *subProject = xcodeproj.subProject; + NSDictionary *subProjectObjects = subProject.objects; + + for (SXCTarget *target in [subProject targets]) { + NSString *containerItemProxyKey = [self makeContainerItemProxyForName:target.name + fileRef:fileRef + proxyType:@"2" + uniqueName:nil]; + NSString *productFileReferenceKey = target.productReference; + NSDictionary *productFileReference = subProjectObjects[productFileReferenceKey]; [self makeReferenceProxyForContainerItemProxy:containerItemProxyKey buildProductReference:productFileReference]; } } -// remove the PBXContainerItemProxy and PBXReferenceProxy objects for the given object key (which is the PBXFilereference -// for the xcodeproj file) +// remove the PBXContainerItemProxy and PBXReferenceProxy objects for the given object key +// (which is the PBXFilereference for the xcodeproj file) - (void)removeProxies:(NSString *)xcodeprojKey { - NSMutableArray *keysToDelete = [NSMutableArray array]; + NSMutableArray *keysToDelete = [[NSMutableArray alloc] init]; // use the xcodeproj's PBXFileReference key to get the PBXContainerItemProxy keys - NSArray *containerItemProxyKeys = [self keysForProjectObjectsOfType:PBXContainerItemProxyType - withIdentifier:xcodeprojKey singleton:NO required:YES]; + NSArray *containerItemProxyKeys = [self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXContainerItemProxy + withIdentifier:xcodeprojKey + singleton:NO + required:YES]; + // use the PBXContainerItemProxy keys to get the PBXReferenceProxy keys for (NSString *key in containerItemProxyKeys) { - [keysToDelete addObjectsFromArray:[self keysForProjectObjectsOfType:PBXReferenceProxyType withIdentifier:key - singleton:NO required:NO]]; + [keysToDelete addObjectsFromArray:[self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXReferenceProxy + withIdentifier:key + singleton:NO + required:NO]]; [keysToDelete addObject:key]; } + // remove all objects located above + NSMutableDictionary *objects = self.objects; [keysToDelete enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [[self objects] removeObjectForKey:obj]; + [objects removeObjectForKey:obj]; }]; } @@ -352,26 +389,36 @@ - (void)removeFromProjectReferences:(NSString *)key forProductsGroup:(NSString * // because we support adding a project file without adding it to any targets. - (void)removeTargetDependencies:(NSString *)name { + NSMutableDictionary *objects = self.objects; + // get the key for the PBXTargetDependency with name = xcodeproj file name (without extension) - NSArray *targetDependencyKeys = [self keysForProjectObjectsOfType:PBXTargetDependencyType withIdentifier:name - singleton:NO required:NO]; + NSArray *targetDependencyKeys = [self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXTargetDependency + withIdentifier:name + singleton:NO + required:NO]; + // we might not find any if the project wasn't added to targets in the first place if ([targetDependencyKeys count] == 0) { return; } NSString *targetDependencyKey = targetDependencyKeys[0]; + // use the key for the PBXTargetDependency to get the key for any PBXNativeTargets that depend on it - NSArray *nativeTargetKeys = [self keysForProjectObjectsOfType:PBXNativeTargetType withIdentifier:targetDependencyKey - singleton:NO required:NO]; - // remove the key for the PBXTargetDependency from the PBXNativeTarget's dependencies arrays (leave in place even if empty) + NSArray *nativeTargetKeys = [self keysForProjectObjectsOfType:SXCXcodeMemberTypePBXNativeTarget + withIdentifier:targetDependencyKey + singleton:NO + required:NO]; + + // remove the key for the PBXTargetDependency from the PBXNativeTarget's dependencies arrays + // (leave in place even if empty) for (NSString *nativeTargetKey in nativeTargetKeys) { - NSMutableDictionary *nativeTarget = [self objects][nativeTargetKey]; + NSMutableDictionary *nativeTarget = objects[nativeTargetKey]; NSMutableArray *dependencies = [nativeTarget valueForKey:@"dependencies"]; [dependencies removeObject:targetDependencyKey]; nativeTarget[@"dependencies"] = dependencies; } // remove the PBXTargetDependency - [[self objects] removeObjectForKey:targetDependencyKey]; + [objects removeObjectForKey:targetDependencyKey]; } -@end \ No newline at end of file +@end diff --git a/Source/XCProject.h b/Source/SXCProject.h similarity index 74% rename from Source/XCProject.h rename to Source/SXCProject.h index 84e722d..a7d3022 100755 --- a/Source/XCProject.h +++ b/Source/SXCProject.h @@ -10,25 +10,27 @@ //////////////////////////////////////////////////////////////////////////////// #import -#import "XcodeMemberType.h" -#import "XcodeSourceFileType.h" -@class XCClassDefinition; -@class XCGroup; -@class XCFileOperationQueue; -@class XCSourceFile; -@class XCTarget; -@class XCSubProjectDefinition; -@class XCProjectBuildConfig; +#import "SXCXcodeFileType.h" +#import "SXCXcodeMemberType.h" -NSString* const XCProjectNotFoundException; +@class SXCClassDefinition; +@class SXCFileOperationQueue; +@class SXCGroup; +@class SXCProjectBuildConfig; +@class SXCSourceFile; +@class SXCSubProjectDefinition; +@class SXCTarget; -@interface XCProject : NSObject +extern NSString* const SXCProjectNotFoundException; + +@interface SXCProject : NSObject { @protected - XCFileOperationQueue* _fileOperationQueue; + SXCFileOperationQueue* _fileOperationQueue; NSString* _filePath; + NSString* _dataStorePath; NSMutableDictionary* _dataStore; NSMutableArray* _targets; @@ -39,19 +41,16 @@ NSString* const XCProjectNotFoundException; NSString* _rootObjectKey; } -@property(nonatomic, strong, readonly) XCFileOperationQueue* fileOperationQueue; +@property(nonatomic, strong, readonly) SXCFileOperationQueue* fileOperationQueue; //------------------------------------------------------------------------------------------- #pragma mark - Initialization & Destruction //------------------------------------------------------------------------------------------- - -+ (XCProject*)projectWithFilePath:(NSString*)filePath; - /** -* Creates a new project editor instance with the specified Project.xcodeproj file. -*/ -- (id)initWithFilePath:(NSString*)filePath; + * Creates a new project editor instance with the specified Project.xcodeproj file. + */ ++ (instancetype)projectWithFilePath:(NSString*)filePath; //------------------------------------------------------------------------------------------- #pragma mark Files @@ -63,13 +62,13 @@ NSString* const XCProjectNotFoundException; /** * Returns the project file with the specified key, or nil. */ -- (XCSourceFile*)fileWithKey:(NSString*)key; +- (SXCSourceFile*)fileWithKey:(NSString*)key; /** * Returns the project file with the specified name, or nil. If more than one project file matches the specified name, * which one is returned is undefined. */ -- (XCSourceFile*)fileWithName:(NSString*)name; +- (SXCSourceFile*)fileWithName:(NSString*)name; /** * Returns all header files in the project, as an array of `XCSourceFile` objects. @@ -95,7 +94,6 @@ NSString* const XCProjectNotFoundException; - (NSString*)filePath; - //------------------------------------------------------------------------------------------- #pragma mark Groups /** @@ -106,7 +104,7 @@ NSString* const XCProjectNotFoundException; /** * Returns the root (top-level) group. */ -- (XCGroup*)rootGroup; +- (SXCGroup*)rootGroup; /** * Returns the root (top-level) groups, if there are multiple. An array of rootGroup if there is only one. @@ -116,22 +114,22 @@ NSString* const XCProjectNotFoundException; /** * Returns the group with the given key, or nil. */ -- (XCGroup*)groupWithKey:(NSString*)key; +- (SXCGroup*)groupWithKey:(NSString*)key; /** * Returns the group with the specified display name path - the directory relative to the root group. Eg Source/Main */ -- (XCGroup*)groupWithPathFromRoot:(NSString*)path; +- (SXCGroup*)groupWithPathFromRoot:(NSString*)path; /** * Returns the parent group for the group or file with the given key; */ -- (XCGroup*)groupForGroupMemberWithKey:(NSString*)key; +- (SXCGroup*)groupForGroupMemberWithKey:(NSString*)key; /** * Returns the parent group for the group or file with the source file */ -- (XCGroup*)groupWithSourceFile:(XCSourceFile*)sourceFile; +- (SXCGroup*)groupWithSourceFile:(SXCSourceFile*)sourceFile; //------------------------------------------------------------------------------------------- #pragma mark Targets @@ -143,7 +141,7 @@ NSString* const XCProjectNotFoundException; /** * Returns the target with the specified name, or nil. */ -- (XCTarget*)targetWithName:(NSString*)name; +- (SXCTarget*)targetWithName:(NSString*)name; #pragma mark Configurations @@ -151,10 +149,9 @@ NSString* const XCProjectNotFoundException; * Returns the target with the specified name, or nil. */ - (NSDictionary*)configurations; - - (NSDictionary*)configurationWithName:(NSString*)name; -- (XCProjectBuildConfig *)defaultConfiguration; +- (SXCProjectBuildConfig *)defaultConfiguration; //------------------------------------------------------------------------------------------- #pragma mark Saving @@ -163,14 +160,13 @@ NSString* const XCProjectNotFoundException; */ - (void)save; - //------------------------------------------------------------------------------------------- /** * Raw project data. */ -- (NSMutableDictionary*)objects; +@property(nonatomic, strong, readonly) NSMutableDictionary* objects; -- (NSMutableDictionary*)dataStore; +@property(nonatomic, strong, readonly) NSMutableDictionary* dataStore; - (void)dropCache; diff --git a/Source/SXCProject.m b/Source/SXCProject.m new file mode 100755 index 0000000..17cb8d1 --- /dev/null +++ b/Source/SXCProject.m @@ -0,0 +1,368 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 - 2013 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import "SXCProject.h" + +#import "SXCFileOperationQueue.h" +#import "SXCGroup.h" +#import "SXCProjectBuildConfig.h" +#import "SXCSourceFile.h" +#import "SXCTarget.h" + +NSString* const SXCProjectNotFoundException = @"SXCProjectNotFoundException"; + +@implementation SXCProject + +@synthesize fileOperationQueue = _fileOperationQueue; + +//------------------------------------------------------------------------------------------- +#pragma mark - Class Methods +//------------------------------------------------------------------------------------------- + ++ (instancetype)projectWithFilePath:(NSString*)filePath +{ + return [[self alloc] initWithFilePath:filePath]; +} + +//------------------------------------------------------------------------------------------- +#pragma mark - Initialization & Destruction +//------------------------------------------------------------------------------------------- + +- (instancetype)initWithFilePath:(NSString*)filePath +{ + if ((self = [super init])) { + _filePath = [filePath copy]; + _dataStorePath = [_filePath stringByAppendingPathComponent:@"project.pbxproj"]; + + _dataStore = [[NSMutableDictionary alloc] initWithContentsOfFile:_dataStorePath]; + if (!_dataStore) { + [NSException raise:SXCProjectNotFoundException format:@"Project file not found at file path %@", _filePath]; + } + + _fileOperationQueue = + [[SXCFileOperationQueue alloc] initWithBaseDirectory:[_filePath stringByDeletingLastPathComponent]]; + + } + return self; +} + +//------------------------------------------------------------------------------------------- +#pragma mark - Interface Methods +//------------------------------------------------------------------------------------------- + +#pragma mark Files + +- (NSArray*)files +{ + NSMutableArray* results = [NSMutableArray array]; + [self.objects enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSDictionary* obj, BOOL* stop) { + if ([obj[@"isa"] sxc_hasFileReferenceType]) { + SXCXcodeFileType fileType = SXCXcodeFileTypeFromStringRepresentation(obj[@"lastKnownFileType"]); + NSString* path = obj[@"path"]; + NSString* sourceTree = obj[@"sourceTree"]; + SXCSourceFile* sourceFile = [SXCSourceFile sourceFileWithProject:self + key:key + type:fileType + name:path + sourceTree:(sourceTree ?: @"") + path:nil]; + [results addObject:sourceFile]; + } + }]; + return results; +} + +- (SXCSourceFile*)fileWithKey:(NSString*)key +{ + NSDictionary* obj = self.objects[key]; + if (obj && [obj[@"isa"] sxc_hasFileReferenceOrReferenceProxyType]) { + SXCXcodeFileType fileType = SXCXcodeFileTypeFromStringRepresentation(obj[@"lastKnownFileType"]); + + NSString* name = obj[@"name"]; + NSString* sourceTree = obj[@"sourceTree"]; + NSString* path = obj[@"path"]; + + if (name == nil) { + name = path; + } + return [SXCSourceFile sourceFileWithProject:self + key:key + type:fileType + name:name + sourceTree:(sourceTree ?: @"") + path:path]; + } + return nil; +} + +- (SXCSourceFile*)fileWithName:(NSString*)name +{ + for (SXCSourceFile* projectFile in [self files]) { + if ([[projectFile name] isEqualToString:name]) { + return projectFile; + } + } + return nil; +} + +- (NSArray*)headerFiles +{ + return [self projectFilesOfType:SXCXcodeFileTypeSourceCodeHeader]; +} + +- (NSArray*)objectiveCFiles +{ + return [self projectFilesOfType:SXCXcodeFileTypeSourceCodeObjC]; +} + +- (NSArray*)objectiveCPlusPlusFiles +{ + return [self projectFilesOfType:SXCXcodeFileTypeSourceCodeObjCPlusPlus]; +} + +- (NSArray*)xibFiles +{ + return [self projectFilesOfType:SXCXcodeFileTypeXibFile]; +} + +- (NSArray*)imagePNGFiles +{ + return [self projectFilesOfType:SXCXcodeFileTypeImageResourcePNG]; +} + +// need this value to construct relative path in XcodeprojDefinition +- (NSString*)filePath +{ + return _filePath; +} + +//------------------------------------------------------------------------------------------- +#pragma mark Groups +//------------------------------------------------------------------------------------------- + +- (NSArray*)groups +{ + NSMutableArray* results = [[NSMutableArray alloc] init]; + [self.objects enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSDictionary* obj, BOOL* stop) { + if ([obj[@"isa"] sxc_hasGroupType]) { + SXCGroup* group = _groups[key]; + if (group == nil) { + group = [self createGroupWithDictionary:obj forKey:key]; + _groups[key] = group; + } + [results addObject:group]; + } + }]; + return results; +} + +//TODO: Optimize this implementation. +- (SXCGroup*)rootGroup +{ + for (SXCGroup* group in [self groups]) { + if ([group isRootGroup]) { + return group; + } + } + return nil; +} + +- (NSArray*)rootGroups +{ + SXCGroup* group = [self rootGroup]; + if (group) { + return [NSArray arrayWithObject:group]; + } + + NSMutableArray* results = [NSMutableArray array]; + for (SXCGroup* group in [self groups]) { + if ([group parentGroup] == nil) { + [results addObject:group]; + } + } + + return [results copy]; +} + +- (SXCGroup*)groupWithKey:(NSString*)key +{ + SXCGroup* group = _groups[key]; + if (group) { + return group; + } + + NSDictionary* obj = self.objects[key]; + if (obj && [obj[@"isa"] sxc_hasGroupType]) { + SXCGroup* group = [self createGroupWithDictionary:obj forKey:key]; + _groups[key] = group; + + return group; + } + return nil; +} + +- (SXCGroup*)groupForGroupMemberWithKey:(NSString*)key +{ + for (SXCGroup* group in [self groups]) { + if ([group memberWithKey:key]) { + return group; + } + } + return nil; +} + +- (SXCGroup*)groupWithSourceFile:(SXCSourceFile*)sourceFile +{ + for (SXCGroup* group in [self groups]) { + for (id member in [group members]) { + if ([member isKindOfClass:[SXCSourceFile class]] && [[sourceFile key] isEqualToString:[member key]]) { + return group; + } + } + } + return nil; +} + +//TODO: This could fail if the path attribute on a given group is more than one directory. Start with candidates and +//TODO: search backwards. +- (SXCGroup*)groupWithPathFromRoot:(NSString*)path +{ + NSArray* pathItems = [path pathComponents]; + SXCGroup* currentGroup = [self rootGroup]; + for (NSString* pathItem in pathItems) { + id group = [currentGroup memberWithDisplayName:pathItem]; + if ([group isKindOfClass:[SXCGroup class]]) { + currentGroup = group; + } else { + return nil; + } + } + return currentGroup; +} + +- (SXCGroup*)createGroupWithDictionary:(NSDictionary*)dictionary forKey:(NSString*)key +{ + return [SXCGroup groupWithProject:self + key:key + alias:dictionary[@"name"] + path:dictionary[@"path"] + children:dictionary[@"children"]]; +} + +//------------------------------------------------------------------------------------------- +#pragma mark targets +//------------------------------------------------------------------------------------------- + +- (NSArray*)targets +{ + if (_targets == nil) { + _targets = [[NSMutableArray alloc] init]; + [self.objects enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSDictionary* obj, BOOL* stop) { + if ([obj[@"isa"] sxc_hasNativeTargetType]) { + SXCTarget* target = [SXCTarget targetWithProject:self + key:key + name:obj[@"name"] + productName:obj[@"productName"] + productReference:obj[@"productReference"]]; + [_targets addObject:target]; + } + }]; + } + return _targets; +} + +- (SXCTarget*)targetWithName:(NSString*)name +{ + for (SXCTarget* target in [self targets]) { + if ([[target name] isEqualToString:name]) { + return target; + } + } + return nil; +} + +- (void)save +{ + [_fileOperationQueue commitFileOperations]; + [_dataStore writeToFile:_dataStorePath atomically:YES]; + + NSLog(@"Saved project"); +} + +- (NSMutableDictionary*)objects +{ + return _dataStore[@"objects"]; +} + +- (NSMutableDictionary*)dataStore +{ + return _dataStore; +} + +- (void)dropCache +{ + _targets = nil; + _configurations = nil; + _rootObjectKey = nil; +} + +- (NSDictionary*)configurations +{ + if (_configurations == nil) { + NSDictionary* objects = self.objects; + NSString* buildConfigurationRootSectionKey = + [[objects objectForKey:[self rootObjectKey]] objectForKey:@"buildConfigurationList"]; + NSDictionary* buildConfigurationDictionary = objects[buildConfigurationRootSectionKey]; + NSArray* buildConfigurations = buildConfigurationDictionary[@"buildConfigurations"]; + _configurations = + [[SXCProjectBuildConfig buildConfigurationsFromArray:buildConfigurations + inProject:self] mutableCopy]; + _defaultConfigurationName = [buildConfigurationDictionary[@"defaultConfigurationName"] copy]; + } + + return [_configurations copy]; +} + +- (NSDictionary*)configurationWithName:(NSString*)name +{ + return [[self configurations] objectForKey:name]; +} + +- (SXCProjectBuildConfig *)defaultConfiguration +{ + return [[self configurations] objectForKey:_defaultConfigurationName]; +} + +//------------------------------------------------------------------------------------------- +#pragma mark Private +//------------------------------------------------------------------------------------------- + +- (NSString*)rootObjectKey +{ + if (_rootObjectKey == nil) { + _rootObjectKey = [_dataStore[@"rootObject"] copy]; + } + + return _rootObjectKey; +} + +- (NSArray*)projectFilesOfType:(SXCXcodeFileType)projectFileType +{ + NSMutableArray* results = [NSMutableArray array]; + for (SXCSourceFile* file in [self files]) { + if ([file type] == projectFileType) { + [results addObject:file]; + } + } + return results; +} + +@end diff --git a/Source/XCProjectBuildConfig.h b/Source/SXCProjectBuildConfig.h similarity index 67% rename from Source/XCProjectBuildConfig.h rename to Source/SXCProjectBuildConfig.h index d57911e..37446e3 100644 --- a/Source/XCProjectBuildConfig.h +++ b/Source/SXCProjectBuildConfig.h @@ -9,14 +9,14 @@ // //////////////////////////////////////////////////////////////////////////////// +#import +@class SXCProject; -@class XCProject; - -@interface XCProjectBuildConfig : NSObject +@interface SXCProjectBuildConfig : NSObject { @private - __weak XCProject* _project; + __weak SXCProject* _project; NSString* _key; NSMutableDictionary* _buildSettings; @@ -25,17 +25,17 @@ @property(nonatomic, readonly) NSDictionary* specifiedBuildSettings; -+ (NSDictionary*)buildConfigurationsFromArray:(NSArray*)array inProject:(XCProject*)project; ++ (NSDictionary*)buildConfigurationsFromArray:(NSArray*)array inProject:(SXCProject*)project; -- (instancetype)initWithProject:(XCProject*)project key:(NSString*)key; +- (instancetype)initWithProject:(SXCProject*)project key:(NSString*)key; - (void)addBuildSettings:(NSDictionary*)buildSettings; - - (void)addOrReplaceSetting:(id )setting forKey:(NSString*)key; - (id )valueForKey:(NSString*)key; -+ (NSString*)duplicatedBuildConfigurationListWithKey:(NSString*)buildConfigurationListKey inProject:(XCProject*)project - withBuildConfigurationVisitor:(void (^)(NSMutableDictionary*))buildConfigurationVisitor; ++ (NSString*)duplicatedBuildConfigurationListWithKey:(NSString*)buildConfigurationListKey + inProject:(SXCProject*)project + withBuildConfigurationVisitor:(void (^)(NSMutableDictionary*))buildConfigurationVisitor; @end diff --git a/Source/XCProjectBuildConfig.m b/Source/SXCProjectBuildConfig.m similarity index 58% rename from Source/XCProjectBuildConfig.m rename to Source/SXCProjectBuildConfig.m index 1689a3e..ee298e4 100644 --- a/Source/XCProjectBuildConfig.m +++ b/Source/SXCProjectBuildConfig.m @@ -9,77 +9,68 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCProjectBuildConfig.h" +#import "SXCGroup.h" +#import "SXCKeyBuilder.h" +#import "SXCProject.h" +#import "SXCSourceFile.h" -#import "XCProjectBuildConfig.h" -#import "XCGroup.h" -#import "XCKeyBuilder.h" -#import "XCProject.h" -#import "XCSourceFile.h" +@implementation SXCProjectBuildConfig -@implementation XCProjectBuildConfig - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Class Methods -+ (NSDictionary*)buildConfigurationsFromArray:(NSArray*)array inProject:(XCProject*)project ++ (NSDictionary*)buildConfigurationsFromArray:(NSArray*)array inProject:(SXCProject*)project { - NSMutableDictionary* configurations = [NSMutableDictionary dictionary]; + NSMutableDictionary* configurations = [[NSMutableDictionary alloc] init]; - for (NSString* buildConfigurationKey in array) - { - NSDictionary* buildConfiguration = [[project objects] objectForKey:buildConfigurationKey]; + NSString* projectDir = [[project filePath] stringByDeletingLastPathComponent]; - if ([[buildConfiguration valueForKey:@"isa"] asMemberType] == XCBuildConfigurationType) - { - XCProjectBuildConfig * configuration = [configurations objectForKey:[buildConfiguration objectForKey:@"name"]]; - if (!configuration) - { - configuration = [[XCProjectBuildConfig alloc] initWithProject:project key:buildConfigurationKey]; + for (NSString* buildConfigurationKey in array) { + NSDictionary* buildConfiguration = project.objects[buildConfigurationKey]; + NSString* name = buildConfiguration[@"name"]; - [configurations setObject:configuration forKey:[buildConfiguration objectForKey:@"name"]]; + if ([buildConfiguration[@"isa"] sxc_hasBuildConfigurationType]) { + SXCProjectBuildConfig* configuration = configurations[name]; + if (!configuration) { + configuration = [[SXCProjectBuildConfig alloc] initWithProject:project key:buildConfigurationKey]; + configurations[name] = configuration; } - - XCSourceFile* configurationFile = [project fileWithKey:[buildConfiguration objectForKey:@"baseConfigurationReference"]]; - if (configurationFile) - { + SXCSourceFile* configurationFile = [project fileWithKey:buildConfiguration[@"baseConfigurationReference"]]; + if (configurationFile) { NSString* path = configurationFile.path; - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - { - XCGroup* group = [project groupWithSourceFile:configurationFile]; + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { + SXCGroup* group = [project groupWithSourceFile:configurationFile]; path = [[group pathRelativeToParent] stringByAppendingPathComponent:path]; } - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - { - path = [[[project filePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:path]; + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { + path = [projectDir stringByAppendingPathComponent:path]; } - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - { - path = [[[project filePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:configurationFile.path]; + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { + path = [projectDir stringByAppendingPathComponent:configurationFile.path]; } - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - { + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { [NSException raise:@"XCConfig not found" format:@"Unable to find XCConfig file at %@", path]; } - } [configuration addBuildSettings:[buildConfiguration objectForKey:@"buildSettings"]]; } } - return configurations; + return [configurations copy]; } -+ (NSString*)duplicatedBuildConfigurationListWithKey:(NSString*)buildConfigurationListKey inProject:(XCProject*)project - withBuildConfigurationVisitor:(void (^)(NSMutableDictionary*))buildConfigurationVisitor ++ (NSString*)duplicatedBuildConfigurationListWithKey:(NSString*)buildConfigurationListKey + inProject:(SXCProject*)project + withBuildConfigurationVisitor:(void (^)(NSMutableDictionary*))buildConfigurationVisitor { - NSDictionary* buildConfigurationList = project.objects[buildConfigurationListKey]; NSMutableDictionary* dupBuildConfigurationList = [buildConfigurationList mutableCopy]; @@ -87,23 +78,24 @@ + (NSString*)duplicatedBuildConfigurationListWithKey:(NSString*)buildConfigurati for (NSString* buildConfigurationKey in buildConfigurationList[@"buildConfigurations"]) { - [dupBuildConfigurations addObject:[self duplicatedBuildConfigurationWithKey:buildConfigurationKey inProject:project - withBuildConfigurationVisitor:buildConfigurationVisitor]]; + [dupBuildConfigurations addObject:[self duplicatedBuildConfigurationWithKey:buildConfigurationKey + inProject:project + withBuildConfigurationVisitor:buildConfigurationVisitor]]; } dupBuildConfigurationList[@"buildConfigurations"] = dupBuildConfigurations; - NSString* dupBuildConfigurationListKey = [[XCKeyBuilder createUnique] build]; + NSString* dupBuildConfigurationListKey = [[SXCKeyBuilder createUnique] build]; project.objects[dupBuildConfigurationListKey] = dupBuildConfigurationList; return dupBuildConfigurationListKey; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Initialization & Destruction -- (instancetype)initWithProject:(XCProject*)project key:(NSString*)key +- (instancetype)initWithProject:(SXCProject*)project key:(NSString*)key { self = [super init]; if (self) @@ -117,13 +109,12 @@ - (instancetype)initWithProject:(XCProject*)project key:(NSString*)key return self; } -- (id)init +- (instancetype)init { return [self initWithProject:nil key:nil]; } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Interface Methods - (NSDictionary*)specifiedBuildSettings @@ -142,16 +133,12 @@ - (void)addOrReplaceSetting:(id )setting forKey:(NSString*)key NSDictionary* settings = [NSDictionary dictionaryWithObject:setting forKey:key]; [self addBuildSettings:settings]; - NSLog(@"$$$$$$$$$$$ before: %@", [_project.objects objectForKey:_key]); - - NSMutableDictionary* dict = [[[_project objects] objectForKey:_key] mutableCopy]; - [dict setValue:_buildSettings forKey:@"buildSettings"]; - [_project.objects setValue:dict forKey:_key]; - - NSLog(@"The settings: %@", [_project.objects objectForKey:_key]); - - } + NSMutableDictionary* objects = _project.objects; + NSMutableDictionary* dict = [objects[_key] mutableCopy]; + dict[@"buildSettings"] = _buildSettings; + objects[_key] = dict; +} - (id )valueForKey:(NSString*)key { @@ -163,7 +150,7 @@ - (void)addOrReplaceSetting:(id )setting forKey:(NSString*)key return value; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Utility Methods - (NSString*)description @@ -175,19 +162,19 @@ - (NSString*)description return description; } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Private Methods -+ (NSString*)duplicatedBuildConfigurationWithKey:(NSString*)buildConfigurationKey inProject:(XCProject*)project - withBuildConfigurationVisitor:(void (^)(NSMutableDictionary*))buildConfigurationVisitor ++ (NSString*)duplicatedBuildConfigurationWithKey:(NSString*)buildConfigurationKey + inProject:(SXCProject*)project + withBuildConfigurationVisitor:(void (^)(NSMutableDictionary*))buildConfigurationVisitor { NSDictionary* buildConfiguration = project.objects[buildConfigurationKey]; NSMutableDictionary* dupBuildConfiguration = [buildConfiguration mutableCopy]; buildConfigurationVisitor(dupBuildConfiguration); - NSString* dupBuildConfigurationKey = [[XCKeyBuilder createUnique] build]; + NSString* dupBuildConfigurationKey = [[SXCKeyBuilder createUnique] build]; project.objects[dupBuildConfigurationKey] = dupBuildConfiguration; diff --git a/Source/XCSourceFile.h b/Source/SXCSourceFile.h similarity index 67% rename from Source/XCSourceFile.h rename to Source/SXCSourceFile.h index 8ea8a03..cbf1082 100755 --- a/Source/XCSourceFile.h +++ b/Source/SXCSourceFile.h @@ -9,22 +9,21 @@ // //////////////////////////////////////////////////////////////////////////////// - - #import -#import "XcodeGroupMember.h" -#import "XcodeSourceFileType.h" -@class XCProject; +#import "SXCXcodeGroupMember.h" +#import "SXCXcodeFileType.h" + +@class SXCProject; /** * Represents a file resource in an xcode project. */ -@interface XCSourceFile : NSObject +@interface SXCSourceFile : NSObject { @private - XCProject *_project; + SXCProject *_project; NSNumber *_isBuildFile; NSString *_buildFileKey; @@ -32,29 +31,29 @@ NSString *_sourceTree; NSString *_key; NSString *_path; - XcodeSourceFileType _type; + SXCXcodeFileType _type; } -@property (nonatomic, readonly) XcodeSourceFileType type; +@property (nonatomic, readonly) SXCXcodeFileType type; @property (nonatomic, strong, readonly) NSString *key; @property (nonatomic, strong) NSString *name; @property (nonatomic, strong, readonly) NSString *sourceTree; @property (nonatomic, strong) NSString *path; -+ (XCSourceFile *)sourceFileWithProject:(XCProject *)project key:(NSString *)key type:(XcodeSourceFileType)type - name:(NSString *)name sourceTree:(NSString *)tree path:(NSString *)path; - -- (id)initWithProject:(XCProject *)project key:(NSString *)key type:(XcodeSourceFileType)type name:(NSString *)name - sourceTree:(NSString *)tree path:(NSString *)path; ++ (instancetype)sourceFileWithProject:(SXCProject *)project + key:(NSString *)key + type:(SXCXcodeFileType)type + name:(NSString *)name + sourceTree:(NSString *)tree + path:(NSString *)path; /** * If yes, indicates the file is able to be included for compilation in an `XCTarget`. */ - (BOOL)isBuildFile; - - (BOOL)canBecomeBuildFile; -- (XcodeMemberType)buildPhase; +- (SXCXcodeMemberType)buildPhase; - (NSString *)buildFileKey; diff --git a/Source/XCSourceFile.m b/Source/SXCSourceFile.m similarity index 53% rename from Source/XCSourceFile.m rename to Source/SXCSourceFile.m index 4f2274a..1a1daeb 100755 --- a/Source/XCSourceFile.m +++ b/Source/SXCSourceFile.m @@ -9,14 +9,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCSourceFile.h" +#import "SXCGroup.h" +#import "SXCProject.h" +#import "Utils/SXCKeyBuilder.h" -#import "XCSourceFile.h" -#import "XCProject.h" -#import "Utils/XCKeyBuilder.h" -#import "XCGroup.h" - -@implementation XCSourceFile +@implementation SXCSourceFile @synthesize type = _type; @synthesize key = _key; @@ -26,21 +25,27 @@ @implementation XCSourceFile #pragma mark - Class Methods //------------------------------------------------------------------------------------------- -+ (XCSourceFile *)sourceFileWithProject:(XCProject *)project key:(NSString *)key type:(XcodeSourceFileType)type - name:(NSString *)name sourceTree:(NSString *)_tree path:(NSString *)path ++ (instancetype)sourceFileWithProject:(SXCProject *)project + key:(NSString *)key + type:(SXCXcodeFileType)type + name:(NSString *)name + sourceTree:(NSString *)tree + path:(NSString *)path { - return [[XCSourceFile alloc] initWithProject:project key:key type:type name:name sourceTree:_tree path:path]; + return [[self alloc] initWithProject:project key:key type:type name:name sourceTree:tree path:path]; } - //------------------------------------------------------------------------------------------- #pragma mark - Initialization & Destruction //------------------------------------------------------------------------------------------- -- (id)initWithProject:(XCProject *)project key:(NSString *)key type:(XcodeSourceFileType)type name:(NSString *)name - sourceTree:(NSString *)tree path:(NSString *)path +- (instancetype)initWithProject:(SXCProject *)project + key:(NSString *)key + type:(SXCXcodeFileType)type + name:(NSString *)name + sourceTree:(NSString *)tree + path:(NSString *)path { - self = [super init]; if (self) { _project = project; @@ -53,23 +58,22 @@ - (id)initWithProject:(XCProject *)project key:(NSString *)key type:(XcodeSource return self; } - //------------------------------------------------------------------------------------------- #pragma mark - Interface Methods //------------------------------------------------------------------------------------------- // Goes to the entry for this object in the project and sets a value for one of the keys, such as name, path, etc. -- (void)setValue:(id)val forProjectItemPropertyWithKey:(NSString *)key +- (void)setValue:(id)value forProjectItemPropertyWithKey:(NSString *)key { - NSMutableDictionary *obj = [[[_project objects] objectForKey:_key] mutableCopy]; + NSMutableDictionary *objects = _project.objects; + NSMutableDictionary *obj = [objects[_key] mutableCopy]; if (nil == obj) { [NSException raise:@"Project item not found" format:@"Project item with key %@ not found.", _key]; } - [obj setValue:val forKey:key]; - [[_project objects] setValue:obj forKey:_key]; + obj[key] = value; + objects[_key] = obj; } - - (NSString *)name { return _name; @@ -82,7 +86,6 @@ - (void)setName:(NSString *)name [self setValue:name forProjectItemPropertyWithKey:@"name"]; } - - (NSString *)path { return _path; @@ -99,97 +102,106 @@ - (BOOL)isBuildFile { if ([self canBecomeBuildFile] && _isBuildFile == nil) { _isBuildFile = @NO; - [[_project objects] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXBuildFileType) { - if ([[obj valueForKey:@"fileRef"] isEqualToString:_key]) { - _isBuildFile = nil; - + for (NSDictionary* obj in [_project.objects objectEnumerator]) { + if ([obj[@"isa"] sxc_hasBuildFileType]) { + if ([obj[@"fileRef"] isEqualToString:_key]) { _isBuildFile = @YES; } } - }]; + }; } return [_isBuildFile boolValue]; } - (BOOL)canBecomeBuildFile { - return _type == SourceCodeObjC || _type == SourceCodeObjCPlusPlus || _type == SourceCodeCPlusPlus || _type == XibFile || _type == Framework || _type == ImageResourcePNG || _type == HTML || _type == Bundle || _type == Archive; -} - - -- (XcodeMemberType)buildPhase -{ - if (_type == SourceCodeObjC || _type == SourceCodeObjCPlusPlus || _type == SourceCodeCPlusPlus || _type == XibFile) { - return PBXSourcesBuildPhaseType; + return + _type == SXCXcodeFileTypeSourceCodeObjC || + _type == SXCXcodeFileTypeSourceCodeObjCPlusPlus || + _type == SXCXcodeFileTypeSourceCodeCPlusPlus || + _type == SXCXcodeFileTypeXibFile || + _type == SXCXcodeFileTypeFramework || + _type == SXCXcodeFileTypeImageResourcePNG || + _type == SXCXcodeFileTypeHTML || + _type == SXCXcodeFileTypeBundle || + _type == SXCXcodeFileTypeArchive; +} + +- (SXCXcodeMemberType)buildPhase +{ + if (_type == SXCXcodeFileTypeSourceCodeObjC || + _type == SXCXcodeFileTypeSourceCodeObjCPlusPlus || + _type == SXCXcodeFileTypeSourceCodeCPlusPlus || + _type == SXCXcodeFileTypeXibFile) { + return SXCXcodeMemberTypePBXSourcesBuildPhase; } - else if (_type == Framework) { - return PBXFrameworksBuildPhaseType; + else if (_type == SXCXcodeFileTypeFramework) { + return SXCXcodeMemberTypePBXFrameworksBuildPhase; } - else if (_type == ImageResourcePNG || _type == HTML || _type == Bundle) { - return PBXResourcesBuildPhaseType; + else if (_type == SXCXcodeFileTypeImageResourcePNG || + _type == SXCXcodeFileTypeHTML || + _type == SXCXcodeFileTypeBundle) { + return SXCXcodeMemberTypePBXResourcesBuildPhase; } - else if (_type == Archive) { - return PBXFrameworksBuildPhaseType; + else if (_type == SXCXcodeFileTypeArchive) { + return SXCXcodeMemberTypePBXFrameworksBuildPhase; } - return PBXNilType; + return SXCXcodeMemberTypePBXNil; } - (NSString *)buildFileKey { if (_buildFileKey == nil) { - [[_project objects] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXBuildFileType) { - if ([[obj valueForKey:@"fileRef"] isEqualToString:_key]) { + [_project.objects enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { + if ([obj[@"isa"] sxc_hasBuildFileType]) { + if ([obj[@"fileRef"] isEqualToString:_key]) { _buildFileKey = [key copy]; } } }]; } return [_buildFileKey copy]; - } - - (void)becomeBuildFile { if (![self isBuildFile]) { if ([self canBecomeBuildFile]) { NSMutableDictionary *sourceBuildFile = [NSMutableDictionary dictionary]; - sourceBuildFile[@"isa"] = [NSString stringFromMemberType:PBXBuildFileType]; + sourceBuildFile[@"isa"] = [NSString sxc_stringFromMemberType:SXCXcodeMemberTypePBXBuildFile]; sourceBuildFile[@"fileRef"] = _key; - NSString *buildFileKey = [[XCKeyBuilder forItemNamed:[_name stringByAppendingString:@".buildFile"]] build]; - [_project objects][buildFileKey] = sourceBuildFile; + NSString *buildFileKey = [[SXCKeyBuilder forItemNamed:[_name stringByAppendingString:@".buildFile"]] build]; + _project.objects[buildFileKey] = sourceBuildFile; } - else if (_type == Framework) { + else if (_type == SXCXcodeFileTypeFramework) { [NSException raise:NSInvalidArgumentException format:@"Add framework to target not implemented yet."]; } else { [NSException raise:NSInvalidArgumentException format:@"Project file of type %@ can't become a build file.", - NSStringFromXCSourceFileType(_type)]; + SXCNSStringFromSXCXcodeFileType(_type)]; } - } } - (void)setCompilerFlags:(NSString *)value { - NSMutableDictionary *objectArrayCopy = [[_project objects] mutableCopy]; + NSMutableDictionary *objects = _project.objects; + NSMutableDictionary *objectArrayCopy = [objects mutableCopy]; [objectArrayCopy enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXBuildFileType) { + if ([obj[@"isa"] sxc_hasBuildFileType]) { if ([obj[@"fileRef"] isEqualToString:self.key]) { - NSMutableDictionary *replaceBuildFile = [NSMutableDictionary dictionaryWithDictionary:obj]; - NSDictionary *compilerFlagsDict = @{@"COMPILER_FLAGS" : value}; - if ([replaceBuildFile[@"settings"] objectForKey:@"COMPILER_FLAGS"] != nil) { - NSMutableDictionary *newSettings = [NSMutableDictionary dictionaryWithDictionary:replaceBuildFile[@"settings"]]; + NSMutableDictionary *replaceBuildFile = [obj mutableCopy]; + NSDictionary *compilerFlagsDict = @{ @"COMPILER_FLAGS" : value }; + NSMutableDictionary *settings = replaceBuildFile[@"settings"]; + if (settings[@"COMPILER_FLAGS"] != nil) { + NSMutableDictionary *newSettings = [settings mutableCopy]; [newSettings removeObjectForKey:@"COMPILER_FLAGS"]; replaceBuildFile[@"settings"] = compilerFlagsDict; } else { replaceBuildFile[@"settings"] = compilerFlagsDict; } - [[_project objects] removeObjectForKey:key]; - [_project objects][key] = replaceBuildFile; + objects[key] = replaceBuildFile; } } }]; @@ -198,9 +210,9 @@ - (void)setCompilerFlags:(NSString *)value //------------------------------------------------------------------------------------------- #pragma mark - Protocol Methods -- (XcodeMemberType)groupMemberType +- (SXCXcodeMemberType)groupMemberType { - return PBXFileReferenceType; + return SXCXcodeMemberTypePBXFileReference; } - (NSString *)displayName @@ -224,6 +236,4 @@ - (NSString *)description [self pathRelativeToProjectRoot]]; } - @end - diff --git a/Source/SXCSourceFileDefinition.h b/Source/SXCSourceFileDefinition.h new file mode 100644 index 0000000..8c775d1 --- /dev/null +++ b/Source/SXCSourceFileDefinition.h @@ -0,0 +1,31 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import + +#import "SXCAbstractDefinition.h" +#import "SXCXcodeFileType.h" + +@interface SXCSourceFileDefinition : SXCAbstractDefinition +{ + NSString* _sourceFileName; + SXCXcodeFileType _type; + NSData* _data; +} + +@property(nonatomic, strong, readonly) NSString* sourceFileName; +@property(nonatomic, strong, readonly) NSData* data; +@property(nonatomic, readonly) SXCXcodeFileType type; + ++ (instancetype)sourceDefinitionWithName:(NSString*)name text:(NSString*)text type:(SXCXcodeFileType)type; ++ (instancetype)sourceDefinitionWithName:(NSString*)name data:(NSData*)data type:(SXCXcodeFileType)type; + +@end diff --git a/Source/XCSourceFileDefinition.m b/Source/SXCSourceFileDefinition.m similarity index 57% rename from Source/XCSourceFileDefinition.m rename to Source/SXCSourceFileDefinition.m index 417c21c..6d1d463 100644 --- a/Source/XCSourceFileDefinition.m +++ b/Source/SXCSourceFileDefinition.m @@ -9,36 +9,31 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCSourceFileDefinition.h" - -#import "XCSourceFileDefinition.h" - -@implementation XCSourceFileDefinition +@implementation SXCSourceFileDefinition @synthesize sourceFileName = _sourceFileName; @synthesize type = _type; @synthesize data = _data; -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Class Methods -+ (XCSourceFileDefinition*)sourceDefinitionWithName:(NSString*)name text:(NSString*)text type:(XcodeSourceFileType)type ++ (instancetype)sourceDefinitionWithName:(NSString*)name text:(NSString*)text type:(SXCXcodeFileType)type { - - return [[XCSourceFileDefinition alloc] initWithName:name text:text type:type]; + return [[self alloc] initWithName:name text:text type:type]; } -+ (XCSourceFileDefinition*)sourceDefinitionWithName:(NSString*)name data:(NSData*)data type:(XcodeSourceFileType)type ++ (instancetype)sourceDefinitionWithName:(NSString*)name data:(NSData*)data type:(SXCXcodeFileType)type { - - return [[XCSourceFileDefinition alloc] initWithName:name data:data type:type]; + return [[self alloc] initWithName:name data:data type:type]; } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Initialization & Destruction -- (id)initWithName:(NSString*)name text:(NSString*)text type:(XcodeSourceFileType)type +- (instancetype)initWithName:(NSString*)name text:(NSString*)text type:(SXCXcodeFileType)type { self = [super init]; if (self) @@ -50,7 +45,7 @@ - (id)initWithName:(NSString*)name text:(NSString*)text type:(XcodeSourceFileTyp return self; } -- (id)initWithName:(NSString*)name data:(NSData*)data type:(XcodeSourceFileType)type +- (instancetype)initWithName:(NSString*)name data:(NSData*)data type:(SXCXcodeFileType)type { self = [super init]; if (self) @@ -60,7 +55,6 @@ - (id)initWithName:(NSString*)name data:(NSData*)data type:(XcodeSourceFileType) _type = type; } return self; - } -@end \ No newline at end of file +@end diff --git a/Source/XCSubProjectDefinition.h b/Source/SXCSubProjectDefinition.h similarity index 57% rename from Source/XCSubProjectDefinition.h rename to Source/SXCSubProjectDefinition.h index c871a28..e543ea1 100644 --- a/Source/XCSubProjectDefinition.h +++ b/Source/SXCSubProjectDefinition.h @@ -9,43 +9,38 @@ // //////////////////////////////////////////////////////////////////////////////// - - #import -#import "XCAbstractDefinition.h" -#import "XcodeSourceFileType.h" -@class XCProject; +#import "SXCAbstractDefinition.h" +#import "SXCXcodeFileType.h" +@class SXCProject; -@interface XCSubProjectDefinition : XCAbstractDefinition +@interface SXCSubProjectDefinition : SXCAbstractDefinition { - NSString *_name; NSString *_path; - XcodeSourceFileType _type; - XCProject *_subProject; - XCProject *_parentProject; + SXCXcodeFileType _type; + SXCProject *_subProject; + SXCProject *_parentProject; NSString *_key; NSString *_fullProjectPath; NSString *_relativePath; } - @property (nonatomic, strong, readonly) NSString *name; @property (nonatomic, strong, readonly) NSString *path; -@property (nonatomic, readonly) XcodeSourceFileType type; -@property (nonatomic, strong, readonly) XCProject *subProject; -@property (nonatomic, strong, readonly) XCProject *parentProject; +@property (nonatomic, readonly) SXCXcodeFileType type; +@property (nonatomic, strong, readonly) SXCProject *subProject; +@property (nonatomic, strong, readonly) SXCProject *parentProject; @property (nonatomic, strong, readonly) NSString *key; @property (nonatomic, strong, readwrite) NSString *fullProjectPath; -+ (XCSubProjectDefinition *)withName:(NSString *)name path:(NSString *)path parentProject:(XCProject *)parentProject; - -- (id)initWithName:(NSString *)name path:(NSString *)path parentProject:(XCProject *)parentProject; ++ (instancetype)subProjectDefinitionWithName:(NSString *)name + path:(NSString *)path + parentProject:(SXCProject *)parentProject; - (NSString *)projectFileName; - - (NSString *)fullPathName; - (NSArray *)buildProductNames; @@ -54,6 +49,6 @@ - (NSString *)pathRelativeToProjectRoot; -- (void)initFullProjectPath:(NSString *)fullProjectPath groupPath:(NSString *)groupPath; +- (void)setFullProjectPath:(NSString *)fullProjectPath groupPath:(NSString *)groupPath; @end diff --git a/Source/XCSubProjectDefinition.m b/Source/SXCSubProjectDefinition.m similarity index 78% rename from Source/XCSubProjectDefinition.m rename to Source/SXCSubProjectDefinition.m index a215a25..656498f 100644 --- a/Source/XCSubProjectDefinition.m +++ b/Source/SXCSubProjectDefinition.m @@ -9,17 +9,18 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCSubProjectDefinition.h" +#import "SXCProject+SubProject.h" +#import "SXCProject.h" -#import "XCProject.h" -#import "XCProject+SubProject.h" -#import "XCSubProjectDefinition.h" +@interface SXCSubProjectDefinition () -@interface XCSubProjectDefinition () @property (nonatomic, strong, readwrite) NSString *relativePath; + @end -@implementation XCSubProjectDefinition +@implementation SXCSubProjectDefinition @synthesize name = _name; @synthesize path = _path; @@ -34,10 +35,11 @@ @implementation XCSubProjectDefinition #pragma mark - Class Methods //------------------------------------------------------------------------------------------- -+ (XCSubProjectDefinition *)withName:(NSString *)name path:(NSString *)path parentProject:(XCProject *)parentProject ++ (instancetype)subProjectDefinitionWithName:(NSString *)name + path:(NSString *)path + parentProject:(SXCProject *)parentProject { - - return [[XCSubProjectDefinition alloc] initWithName:name path:path parentProject:parentProject]; + return [[self alloc] initWithName:name path:path parentProject:parentProject]; } //------------------------------------------------------------------------------------------- @@ -46,15 +48,15 @@ + (XCSubProjectDefinition *)withName:(NSString *)name path:(NSString *)path pare // Note - _path is most often going to be an absolute path. The method pathRelativeToProjectRoot below should be // used to get the form that's stored in the main project file. -- (id)initWithName:(NSString *)name path:(NSString *)path parentProject:(XCProject *)parentProject +- (instancetype)initWithName:(NSString *)name path:(NSString *)path parentProject:(SXCProject *)parentProject { self = [super init]; if (self) { _name = [name copy]; _path = [path copy]; - _type = XcodeProject; + _type = SXCXcodeFileTypeXcodeProject; _parentProject = parentProject; - _subProject = [[XCProject alloc] initWithFilePath:[NSString stringWithFormat:@"%@/%@.xcodeproj", path, name]]; + _subProject = [SXCProject projectWithFilePath:[NSString stringWithFormat:@"%@/%@.xcodeproj", path, name]]; } return self; } @@ -76,34 +78,34 @@ - (NSString *)fullPathName // returns an array of names of the build products of this project - (NSArray *)buildProductNames { - NSMutableArray *results = [NSMutableArray array]; - NSDictionary *objects = [_subProject objects]; + NSMutableArray *results = [[NSMutableArray alloc] init]; + NSDictionary *objects = _subProject.objects; [objects enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSDictionary *obj, BOOL *stop) { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXProjectType) { - NSString *productRefGroupKey = [obj valueForKey:@"productRefGroup"]; - NSDictionary *products = [objects valueForKey:productRefGroupKey]; - NSArray *children = [products valueForKey:@"children"]; + if ([obj[@"isa"] sxc_hasProjectType]) { + NSString *productRefGroupKey = obj[@"productRefGroup"]; + NSDictionary *products = objects[productRefGroupKey]; + NSArray *children = products[@"children"]; for (NSString *childKey in children) { - NSDictionary *child = [objects valueForKey:childKey]; - [results addObject:[child valueForKey:@"path"]]; + NSDictionary *child = objects[childKey]; + [results addObject:child[@"path"]]; } } }]; - return results; + return [results copy]; } // returns the key of the PBXFileReference of the xcodeproj file - (NSString *)projectKey { if (_key == nil) { - NSArray *xcodeprojKeys = [_parentProject keysForProjectObjectsOfType:PBXFileReferenceType + NSArray *xcodeprojKeys = [_parentProject keysForProjectObjectsOfType:SXCXcodeMemberTypePBXFileReference withIdentifier:[self pathRelativeToProjectRoot] singleton:YES required:YES]; _key = [[xcodeprojKeys objectAtIndex:0] copy]; } return [_key copy]; } -- (void)initFullProjectPath:(NSString *)fullProjectPath groupPath:(NSString *)groupPath +- (void)setFullProjectPath:(NSString *)fullProjectPath groupPath:(NSString *)groupPath { if (groupPath != nil) { NSMutableArray *fullPathComponents = [[fullProjectPath pathComponents] mutableCopy]; @@ -153,14 +155,13 @@ - (NSString *)pathRelativeToProjectRoot return [_relativePath copy]; } - //------------------------------------------------------------------------------------------- #pragma mark - Utility Methods - (NSString *)description { - return [NSString stringWithFormat:@"XcodeprojDefinition: sourceFileName = %@, path=%@, type=%li", _name, _path, - (long)_type]; + return [NSString stringWithFormat:@"XcodeprojDefinition: sourceFileName = %@, path=%@, type=%li", + _name, _path, (long)_type]; } -@end \ No newline at end of file +@end diff --git a/Source/XCTarget.h b/Source/SXCTarget.h similarity index 67% rename from Source/XCTarget.h rename to Source/SXCTarget.h index 7b6349e..5566e4a 100755 --- a/Source/XCTarget.h +++ b/Source/SXCTarget.h @@ -9,20 +9,18 @@ // //////////////////////////////////////////////////////////////////////////////// - #import -@class XCProject; -@class XCSourceFile; -@class XCProjectBuildConfig; +@class SXCProject; +@class SXCProjectBuildConfig; +@class SXCSourceFile; /** * Represents a target in an xcode project. */ -@interface XCTarget : NSObject +@interface SXCTarget : NSObject { - - XCProject* _project; + SXCProject* _project; NSString* _key; NSString* _name; NSString* _productName; @@ -40,26 +38,22 @@ @property(nonatomic, strong) NSString* productName; @property(nonatomic, strong, readonly) NSString* productReference; -+ (XCTarget*)targetWithProject:(XCProject*)project key:(NSString*)key name:(NSString*)name productName:(NSString*)productName - productReference:(NSString*)productReference; - -- (id)initWithProject:(XCProject*)project key:(NSString*)key name:(NSString*)name productName:(NSString*)productName - productReference:(NSString*)productReference; ++ (instancetype)targetWithProject:(SXCProject*)project + key:(NSString*)key + name:(NSString*)name + productName:(NSString*)productName + productReference:(NSString*)productReference; - (NSArray*)resources; - (NSArray*)members; - (NSDictionary*)configurations; +- (SXCProjectBuildConfig *)configurationWithName:(NSString*)name; +- (SXCProjectBuildConfig *)defaultConfiguration; -- (XCProjectBuildConfig *)configurationWithName:(NSString*)name; - -- (XCProjectBuildConfig *)defaultConfiguration; - -- (void)addMember:(XCSourceFile*)member; - +- (void)addMember:(SXCSourceFile*)member; - (void)removeMemberWithKey:(NSString*)key; - - (void)removeMembersWithKeys:(NSArray*)keys; - (void)addDependency:(NSString*)key; @@ -67,4 +61,3 @@ - (instancetype)duplicateWithTargetName:(NSString*)targetName productName:(NSString*)productName; @end - diff --git a/Source/SXCTarget.m b/Source/SXCTarget.m new file mode 100755 index 0000000..e742f72 --- /dev/null +++ b/Source/SXCTarget.m @@ -0,0 +1,375 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import "SXCTarget.h" + +#import "SXCGroup.h" +#import "SXCKeyBuilder.h" +#import "SXCProject.h" +#import "SXCProjectBuildConfig.h" +#import "SXCSourceFile.h" + +@interface SXCTarget () + +@property(nonatomic, strong, readonly) NSMutableDictionary* targetObject; + +@end + +@implementation SXCTarget + +/* ================================================================================================================== */ +#pragma mark - Class Methods + ++ (instancetype)targetWithProject:(SXCProject*)project + key:(NSString*)key + name:(NSString*)name + productName:(NSString*)productName + productReference:(NSString*)productReference +{ + return [[self alloc] initWithProject:project + key:key + name:name + productName:productName + productReference:productReference]; +} + + +/* ================================================================================================================== */ +#pragma mark - Initialization & Destruction + +- (instancetype)initWithProject:(SXCProject*)project + key:(NSString*)key + name:(NSString*)name + productName:(NSString*)productName + productReference:(NSString*)productReference +{ + self = [super init]; + if (self) { + _project = project; + _key = [key copy]; + _name = [name copy]; + _productName = [productName copy]; + _productReference = [productReference copy]; + } + return self; +} + +/* ================================================================================================================== */ +#pragma mark - Interface Methods + +- (NSArray*)resources +{ + if (_resources == nil) { + _resources = [[NSMutableArray alloc] init]; + NSDictionary* objects = _project.objects; + for (NSString* buildPhaseKey in objects[_key][@"buildPhases"]) { + NSDictionary* buildPhase = objects[buildPhaseKey]; + if ([buildPhase[@"isa"] sxc_hasResourcesBuildPhaseType]) { + for (NSString* buildFileKey in buildPhase[@"files"]) { + SXCSourceFile* targetMember = [self buildFileWithKey:buildFileKey]; + if (targetMember) { + [_resources addObject:targetMember]; + } + } + } + } + } + + return [_resources copy]; +} + +- (NSDictionary*)configurations +{ + if (_configurations == nil) { + NSDictionary* objects = _project.objects; + NSString* buildConfigurationRootSectionKey = objects[_key][@"buildConfigurationList"]; + NSDictionary* buildConfigurationDictionary = objects[buildConfigurationRootSectionKey]; + _configurations = + [[SXCProjectBuildConfig buildConfigurationsFromArray:buildConfigurationDictionary[@"buildConfigurations"] + inProject:_project] mutableCopy]; + _defaultConfigurationName = [buildConfigurationDictionary[@"defaultConfigurationName"] copy]; + } + + return [_configurations copy]; +} + +- (SXCProjectBuildConfig *)defaultConfiguration +{ + return [self configurations][_defaultConfigurationName]; +} + +- (SXCProjectBuildConfig *)configurationWithName:(NSString*)name +{ + return [self configurations][name]; +} + +- (NSArray*)members +{ + if (_members == nil) { + _members = [[NSMutableArray alloc] init]; + NSDictionary* objects = _project.objects; + for (NSString* buildPhaseKey in objects[_key][@"buildPhases"]) { + NSDictionary* buildPhase = objects[buildPhaseKey]; + if ([buildPhase[@"isa"] sxc_hasSourcesOrFrameworksBuildPhaseType]) { + for (NSString* buildFileKey in buildPhase[@"files"]) { + SXCSourceFile* targetMember = [self buildFileWithKey:buildFileKey]; + if (targetMember) { + [_members addObject:[_project fileWithKey:targetMember.key]]; + } + } + } + } + } + return _members; +} + +- (void)addMember:(SXCSourceFile*)member +{ + [member becomeBuildFile]; + NSDictionary* objects = _project.objects; + NSDictionary* target = objects[_key]; + + for (NSString* buildPhaseKey in target[@"buildPhases"]) { + NSMutableDictionary* buildPhase = objects[buildPhaseKey]; + if ([buildPhase[@"isa"] sxc_asMemberType] == [member buildPhase]) { + NSMutableArray* files = buildPhase[@"files"]; + NSString* buildFileKey = [member buildFileKey]; + if (![files containsObject:buildFileKey]) { + [files addObject:buildFileKey]; + } + + buildPhase[@"files"] = files; + } + } + [self flagMembersAsDirty]; +} + +- (NSDictionary*)buildRefWithFileRefKey +{ + NSMutableDictionary* buildRefWithFileRefDict = [[NSMutableDictionary alloc] init]; + NSDictionary* objects = _project.objects; + + for (NSString* key in [objects keyEnumerator]) { + NSDictionary* obj = objects[key]; + if ([obj[@"isa"] sxc_hasBuildFileType]) { + NSString* fileRef = obj[@"fileRef"]; + if (fileRef) { + buildRefWithFileRefDict[fileRef] = key; + } + } + } + return [buildRefWithFileRefDict copy]; +} + +- (void)removeMemberWithKey:(NSString*)key +{ + NSDictionary* buildRefWithFileRef = [self buildRefWithFileRefKey]; + NSDictionary* objects = _project.objects; + NSDictionary* target = objects[_key]; + NSString* buildRef = buildRefWithFileRef[key]; + if (!buildRef) { + return; + } + + for (NSString* buildPhaseKey in target[@"buildPhases"]) { + NSMutableDictionary* buildPhase = objects[buildPhaseKey]; + NSMutableArray* files = buildPhase[@"files"]; + + [files removeObjectIdenticalTo:buildRef]; + buildPhase[@"files"] = files; + } + [self flagMembersAsDirty]; +} + +- (void)removeMembersWithKeys:(NSArray*)keys +{ + for (NSString* key in keys) { + [self removeMemberWithKey:key]; + } +} + +- (void)addDependency:(NSString*)key +{ + NSMutableArray* dependencies = self.targetObject[@"dependencies"]; + // add only if not already there + BOOL found = NO; + for (NSString* dependency in dependencies) { + if ([dependency isEqualToString:key]) { + found = YES; + break; + } + } + if (!found) { + [dependencies addObject:key]; + } +} + +- (instancetype)duplicateWithTargetName:(NSString*)targetName productName:(NSString*)productName +{ + NSMutableDictionary* dupTargetObj = [self.targetObject mutableCopy]; + + dupTargetObj[@"name"] = targetName; + dupTargetObj[@"productName"] = productName; + + NSString* buildConfigurationListKey = dupTargetObj[@"buildConfigurationList"]; + + void(^visitor)(NSMutableDictionary*) = ^(NSMutableDictionary* buildConfiguration) { + buildConfiguration[@"buildSettings"][@"PRODUCT_NAME"] = productName; + }; + + dupTargetObj[@"buildConfigurationList"] = + [SXCProjectBuildConfig duplicatedBuildConfigurationListWithKey:buildConfigurationListKey + inProject:_project + withBuildConfigurationVisitor:visitor]; + + [self duplicateProductReferenceForTargetObject:dupTargetObj withProductName:productName]; + + [self duplicateBuildPhasesForTargetObject:dupTargetObj]; + + [self addReferenceToProductsGroupForTargetObject:dupTargetObj]; + + NSString* dupTargetObjKey = [self addTargetToRootObjectTargets:dupTargetObj]; + + [_project dropCache]; + + return [[SXCTarget alloc] initWithProject:_project + key:dupTargetObjKey + name:targetName + productName:productName + productReference:dupTargetObj[@"productReference"]]; +} + +/* ================================================================================================================== */ +#pragma mark - Overridden Methods + +- (void)setName:(NSString*)name +{ + _name = name; + self.targetObject[@"name"] = _name; +} + +- (void)setProductName:(NSString*)productName +{ + _productName = productName; + self.targetObject[@"productName"] = _productName; +} + +/* ================================================================================================================== */ +#pragma mark - Utility Methods + +- (NSString*)description +{ + return [NSString stringWithFormat:@"Target: name=%@, files=%@", _name, _members]; +} + +/* ================================================================================================================== */ +#pragma mark - Private Methods + +- (NSMutableDictionary*)targetObject { + return _project.objects[_key]; +} + +- (SXCSourceFile*)buildFileWithKey:(NSString*)theKey +{ + NSDictionary* obj = _project.objects[theKey]; + if (obj) { + if ([obj[@"isa"] sxc_hasBuildFileType]) { + return [_project fileWithKey:obj[@"fileRef"]]; + } + } + return nil; +} + +- (void)flagMembersAsDirty +{ + _members = nil; +} + +- (void)duplicateProductReferenceForTargetObject:(NSMutableDictionary*)dupTargetObj + withProductName:(NSString*)productName +{ + NSMutableDictionary* objects = _project.objects; + NSString* productReferenceKey = dupTargetObj[@"productReference"]; + NSMutableDictionary* dupProductReference = [objects[productReferenceKey] mutableCopy]; + + NSString* path = dupProductReference[@"path"]; + NSString* dupPath = [path stringByDeletingLastPathComponent]; + dupPath = [dupPath stringByAppendingPathComponent:productName]; + dupPath = [dupPath stringByAppendingPathExtension:@"app"]; + dupProductReference[@"path"] = dupPath; + + NSString* dupProductReferenceKey = [[SXCKeyBuilder createUnique] build]; + + objects[dupProductReferenceKey] = dupProductReference; + dupTargetObj[@"productReference"] = dupProductReferenceKey; +} + +- (void)duplicateBuildPhasesForTargetObject:(NSMutableDictionary*)dupTargetObj +{ + NSMutableArray* buildPhases = [NSMutableArray array]; + NSMutableDictionary* objects = _project.objects; + + for (NSString* buildPhaseKey in dupTargetObj[@"buildPhases"]) { + NSMutableDictionary* dupBuildPhase = [objects[buildPhaseKey] mutableCopy]; + NSMutableArray* dupFiles = [NSMutableArray array]; + + for (NSString* fileKey in dupBuildPhase[@"files"]) { + NSMutableDictionary* dupFile = [objects[fileKey] mutableCopy]; + NSString* dupFileKey = [[SXCKeyBuilder createUnique] build]; + + objects[dupFileKey] = dupFile; + [dupFiles addObject:dupFileKey]; + } + + dupBuildPhase[@"files"] = dupFiles; + + NSString* dupBuildPhaseKey = [[SXCKeyBuilder createUnique] build]; + objects[dupBuildPhaseKey] = dupBuildPhase; + [buildPhases addObject:dupBuildPhaseKey]; + } + + dupTargetObj[@"buildPhases"] = buildPhases; +} + +- (void)addReferenceToProductsGroupForTargetObject:(NSMutableDictionary*)dupTargetObj +{ + SXCGroup* mainGroup = nil; + NSPredicate* productsPredicate = [NSPredicate predicateWithFormat:@"displayName == 'Products'"]; + NSArray* filteredGroups = [_project.groups filteredArrayUsingPredicate:productsPredicate]; + + if (filteredGroups.count > 0) { + mainGroup = filteredGroups[0]; + NSMutableDictionary* mainGroupDictionary = _project.objects[mainGroup.key]; + NSMutableArray* children = [mainGroupDictionary[@"children"] mutableCopy]; + [children addObject:dupTargetObj[@"productReference"]]; + mainGroupDictionary[@"children"] = children; + } +} + +- (NSString*)addTargetToRootObjectTargets:(NSMutableDictionary*)dupTargetObj +{ + NSString* dupTargetObjKey = [[SXCKeyBuilder createUnique] build]; + NSMutableDictionary* objects = _project.objects; + + objects[dupTargetObjKey] = dupTargetObj; + + NSString* rootObjKey = _project.dataStore[@"rootObject"]; + NSMutableDictionary* rootObj = [objects[rootObjKey] mutableCopy]; + NSMutableArray* rootObjTargets = [rootObj[@"targets"] mutableCopy]; + [rootObjTargets addObject:dupTargetObjKey]; + + rootObj[@"targets"] = rootObjTargets; + objects[rootObjKey] = rootObj; + + return dupTargetObjKey; +} + +@end diff --git a/Source/XcodeEditor.h b/Source/SXCXcodeEditor.h similarity index 99% rename from Source/XcodeEditor.h rename to Source/SXCXcodeEditor.h index c524269..2084ae3 100644 --- a/Source/XcodeEditor.h +++ b/Source/SXCXcodeEditor.h @@ -9,12 +9,11 @@ // //////////////////////////////////////////////////////////////////////////////// - #import "XCAbstractDefinition.h" -#import "XCGroup.h" #import "XCClassDefinition.h" #import "XCFileOperationQueue.h" #import "XCFrameworkDefinition.h" +#import "XCGroup.h" #import "XCProject.h" #import "XCSourceFile.h" #import "XCSourceFileDefinition.h" diff --git a/Source/SXCXcodeFileType.h b/Source/SXCXcodeFileType.h new file mode 100755 index 0000000..a797318 --- /dev/null +++ b/Source/SXCXcodeFileType.h @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import + +typedef NS_OPTIONS(NSInteger, SXCXcodeFileType) +{ + SXCXcodeFileTypeNil = 0, // Unknown filetype + SXCXcodeFileTypeFramework = 1, // .framework + SXCXcodeFileTypePropertyList = 2, // .plist + SXCXcodeFileTypeSourceCodeHeader = 3, // .h + SXCXcodeFileTypeSourceCodeObjC = 4, // .m + SXCXcodeFileTypeSourceCodeObjCPlusPlus = 5, // .mm + SXCXcodeFileTypeSourceCodeCPlusPlus = 6, // .cpp + SXCXcodeFileTypeXibFile = 7, // .xib + SXCXcodeFileTypeImageResourcePNG = 8, // .png + SXCXcodeFileTypeBundle = 9, // .bundle .octet + SXCXcodeFileTypeArchive = 10, // .a files + SXCXcodeFileTypeHTML = 11, // HTML file + SXCXcodeFileTypeTEXT = 12, // Some text file + SXCXcodeFileTypeXcodeProject = 13, // .xcodeproj + SXCXcodeFileTypeFolder = 14 // a Folder reference +}; + +NSString* SXCNSStringFromSXCXcodeFileType(SXCXcodeFileType type); + +SXCXcodeFileType SXCXcodeFileTypeFromStringRepresentation(NSString* string); + +SXCXcodeFileType SXCXcodeFileTypeFromFileName(NSString* fileName); diff --git a/Source/SXCXcodeFileType.m b/Source/SXCXcodeFileType.m new file mode 100755 index 0000000..de3774b --- /dev/null +++ b/Source/SXCXcodeFileType.m @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import "SXCXcodeFileType.h" + +static NSDictionary* SXCNSDictionaryWithXCFileReferenceTypes() +{ + static NSDictionary* dictionary; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + dictionary = @{ + @"sourcecode.c.h" : @(SXCXcodeFileTypeSourceCodeHeader), + @"sourcecode.c.objc" : @(SXCXcodeFileTypeSourceCodeObjC), + @"wrapper.framework" : @(SXCXcodeFileTypeFramework), + @"text.plist.strings" : @(SXCXcodeFileTypePropertyList), + @"sourcecode.cpp.objcpp" : @(SXCXcodeFileTypeSourceCodeObjCPlusPlus), + @"sourcecode.cpp.cpp" : @(SXCXcodeFileTypeSourceCodeCPlusPlus), + @"file.xib" : @(SXCXcodeFileTypeXibFile), + @"image.png" : @(SXCXcodeFileTypeImageResourcePNG), + @"wrapper.cfbundle" : @(SXCXcodeFileTypeBundle), + @"archive.ar" : @(SXCXcodeFileTypeArchive), + @"text.html" : @(SXCXcodeFileTypeHTML), + @"text" : @(SXCXcodeFileTypeTEXT), + @"wrapper.pb-project" : @(SXCXcodeFileTypeXcodeProject), + @"folder" : @(SXCXcodeFileTypeFolder) + }; + }); + + return dictionary; +} + +NSString* SXCNSStringFromSXCXcodeFileType(SXCXcodeFileType type) +{ + return [[SXCNSDictionaryWithXCFileReferenceTypes() allKeysForObject:@(type)] firstObject]; +} + +SXCXcodeFileType SXCXcodeFileTypeFromStringRepresentation(NSString* string) +{ + NSDictionary* typeStrings = SXCNSDictionaryWithXCFileReferenceTypes(); + NSNumber* typeValue = typeStrings[string]; + + if (typeValue) { + return (SXCXcodeFileType) [typeValue intValue]; + } else { + return SXCXcodeFileTypeNil; + } +} + +SXCXcodeFileType SXCXcodeFileTypeFromFileName(NSString* fileName) +{ + if ([fileName hasSuffix:@".h"] || + [fileName hasSuffix:@".hh"] || + [fileName hasSuffix:@".hpp"] || + [fileName hasSuffix:@".hxx"]) { + return SXCXcodeFileTypeSourceCodeHeader; + } + + if ([fileName hasSuffix:@".c"] || + [fileName hasSuffix:@".m"]) { + return SXCXcodeFileTypeSourceCodeObjC; + } + + if ([fileName hasSuffix:@".mm"]) { + return SXCXcodeFileTypeSourceCodeObjCPlusPlus; + } + + if ([fileName hasSuffix:@".cpp"]) { + return SXCXcodeFileTypeSourceCodeCPlusPlus; + } + + return SXCXcodeFileTypeNil; +} diff --git a/Source/XcodeGroupMember.h b/Source/SXCXcodeGroupMember.h similarity index 79% rename from Source/XcodeGroupMember.h rename to Source/SXCXcodeGroupMember.h index e38b12b..a29448b 100755 --- a/Source/XcodeGroupMember.h +++ b/Source/SXCXcodeGroupMember.h @@ -9,11 +9,11 @@ // //////////////////////////////////////////////////////////////////////////////// +#import +#import "SXCXcodeMemberType.h" -#import "XcodeMemberType.h" - -@protocol XcodeGroupMember +@protocol SXCXcodeGroupMember - (NSString*)key; @@ -24,5 +24,6 @@ /** * Group members can either be other groups (PBXGroup) or source files (PBXFileReference). */ -- (XcodeMemberType)groupMemberType; -@end \ No newline at end of file +- (SXCXcodeMemberType)groupMemberType; + +@end diff --git a/Source/SXCXcodeMemberType.h b/Source/SXCXcodeMemberType.h new file mode 100755 index 0000000..94a7eb2 --- /dev/null +++ b/Source/SXCXcodeMemberType.h @@ -0,0 +1,52 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import + +typedef enum +{ + SXCXcodeMemberTypePBXNil, + SXCXcodeMemberTypePBXBuildFile, + SXCXcodeMemberTypePBXContainerItemProxy, + SXCXcodeMemberTypePBXCopyFilesBuildPhase, + SXCXcodeMemberTypePBXFileReference, + SXCXcodeMemberTypePBXFrameworksBuildPhase, + SXCXcodeMemberTypePBXGroup, + SXCXcodeMemberTypePBXNativeTarget, + SXCXcodeMemberTypePBXProject, + SXCXcodeMemberTypePBXReferenceProxy, + SXCXcodeMemberTypePBXResourcesBuildPhase, + SXCXcodeMemberTypePBXSourcesBuildPhase, + SXCXcodeMemberTypePBXTargetDependency, + SXCXcodeMemberTypePBXVariantGroup, + SXCXcodeMemberTypeXCBuildConfiguration, + SXCXcodeMemberTypeXCConfigurationList +} SXCXcodeMemberType; + +@interface NSString (SXCXcodeMemberType) + ++ (NSString*)sxc_stringFromMemberType:(SXCXcodeMemberType)nodeType; + +- (SXCXcodeMemberType)sxc_asMemberType; + +- (BOOL)sxc_hasFileReferenceType; +- (BOOL)sxc_hasFileReferenceOrReferenceProxyType; +- (BOOL)sxc_hasReferenceProxyType; +- (BOOL)sxc_hasGroupType; +- (BOOL)sxc_hasProjectType; +- (BOOL)sxc_hasNativeTargetType; +- (BOOL)sxc_hasBuildFileType; +- (BOOL)sxc_hasBuildConfigurationType; +- (BOOL)sxc_hasContainerItemProxyType; +- (BOOL)sxc_hasResourcesBuildPhaseType; +- (BOOL)sxc_hasSourcesOrFrameworksBuildPhaseType; + +@end diff --git a/Source/SXCXcodeMemberType.m b/Source/SXCXcodeMemberType.m new file mode 100755 index 0000000..51fe2a7 --- /dev/null +++ b/Source/SXCXcodeMemberType.m @@ -0,0 +1,123 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import "SXCXcodeMemberType.h" + +static NSString* const kSXCXcodeMemberTypePBXNil = @"PBXNilType"; +static NSString* const kSXCXcodeMemberTypePBXBuildFile = @"PBXBuildFile"; +static NSString* const kSXCXcodeMemberTypePBXContainerItemProxy = @"PBXContainerItemProxy"; +static NSString* const kSXCXcodeMemberTypePBXCopyFilesBuildPhase = @"PBXCopyFilesBuildPhase"; +static NSString* const kSXCXcodeMemberTypePBXFileReference = @"PBXFileReference"; +static NSString* const kSXCXcodeMemberTypePBXFrameworksBuildPhase = @"PBXFrameworksBuildPhase"; +static NSString* const kSXCXcodeMemberTypePBXGroup = @"PBXGroup"; +static NSString* const kSXCXcodeMemberTypePBXNativeTarget = @"PBXNativeTarget"; +static NSString* const kSXCXcodeMemberTypePBXProject = @"PBXProject"; +static NSString* const kSXCXcodeMemberTypePBXReferenceProxy = @"PBXReferenceProxy"; +static NSString* const kSXCXcodeMemberTypePBXResourcesBuildPhase = @"PBXResourcesBuildPhase"; +static NSString* const kSXCXcodeMemberTypePBXSourcesBuildPhase = @"PBXSourcesBuildPhase"; +static NSString* const kSXCXcodeMemberTypePBXTargetDependency = @"PBXTargetDependency"; +static NSString* const kSXCXcodeMemberTypePBXVariantGroup = @"PBXVariantGroup"; +static NSString* const kSXCXcodeMemberTypeXCBuildConfiguration = @"XCBuildConfiguration"; +static NSString* const kSXCXcodeMemberTypeXCConfigurationList = @"XCConfigurationList"; + +static NSDictionary* DictionaryWithProjectNodeTypesAsStrings() { + // This is the most vital operation on adding 500+ files + // So, we caching this dictionary + static NSDictionary* _projectNodeTypesAsStrings; + if (_projectNodeTypesAsStrings) { + return _projectNodeTypesAsStrings; + } + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _projectNodeTypesAsStrings = @{ + kSXCXcodeMemberTypePBXNil : @(SXCXcodeMemberTypePBXNil), + kSXCXcodeMemberTypePBXBuildFile : @(SXCXcodeMemberTypePBXBuildFile), + kSXCXcodeMemberTypePBXContainerItemProxy : @(SXCXcodeMemberTypePBXContainerItemProxy), + kSXCXcodeMemberTypePBXCopyFilesBuildPhase : @(SXCXcodeMemberTypePBXCopyFilesBuildPhase), + kSXCXcodeMemberTypePBXFileReference : @(SXCXcodeMemberTypePBXFileReference), + kSXCXcodeMemberTypePBXFrameworksBuildPhase : @(SXCXcodeMemberTypePBXFrameworksBuildPhase), + kSXCXcodeMemberTypePBXGroup : @(SXCXcodeMemberTypePBXGroup), + kSXCXcodeMemberTypePBXNativeTarget : @(SXCXcodeMemberTypePBXNativeTarget), + kSXCXcodeMemberTypePBXProject : @(SXCXcodeMemberTypePBXProject), + kSXCXcodeMemberTypePBXReferenceProxy : @(SXCXcodeMemberTypePBXReferenceProxy), + kSXCXcodeMemberTypePBXResourcesBuildPhase : @(SXCXcodeMemberTypePBXResourcesBuildPhase), + kSXCXcodeMemberTypePBXSourcesBuildPhase : @(SXCXcodeMemberTypePBXSourcesBuildPhase), + kSXCXcodeMemberTypePBXTargetDependency : @(SXCXcodeMemberTypePBXTargetDependency), + kSXCXcodeMemberTypePBXVariantGroup : @(SXCXcodeMemberTypePBXVariantGroup), + kSXCXcodeMemberTypeXCBuildConfiguration : @(SXCXcodeMemberTypeXCBuildConfiguration), + kSXCXcodeMemberTypeXCConfigurationList : @(SXCXcodeMemberTypeXCConfigurationList), + }; + }); + return _projectNodeTypesAsStrings; +} + +@implementation NSString (SXCXcodeMemberType) + ++ (NSString*)sxc_stringFromMemberType:(SXCXcodeMemberType)nodeType { + NSDictionary* nodeTypesToString = DictionaryWithProjectNodeTypesAsStrings(); + return [[nodeTypesToString allKeysForObject:@(nodeType)] firstObject]; +} + + +- (SXCXcodeMemberType)sxc_asMemberType { + NSDictionary* nodeTypesToString = DictionaryWithProjectNodeTypesAsStrings(); + return (SXCXcodeMemberType) [[nodeTypesToString objectForKey:self] intValue]; +} + +- (BOOL)sxc_hasFileReferenceType { + return [self isEqualToString:kSXCXcodeMemberTypePBXFileReference]; +} + +- (BOOL)sxc_hasFileReferenceOrReferenceProxyType { + return [self isEqualToString:kSXCXcodeMemberTypePBXFileReference] || + [self isEqualToString:kSXCXcodeMemberTypePBXReferenceProxy]; +} + +- (BOOL)sxc_hasReferenceProxyType { + return [self isEqualToString:kSXCXcodeMemberTypePBXReferenceProxy]; +} + +- (BOOL)sxc_hasGroupType { + return [self isEqualToString:kSXCXcodeMemberTypePBXGroup] || + [self isEqualToString:kSXCXcodeMemberTypePBXVariantGroup]; +} + +- (BOOL)sxc_hasProjectType { + return [self isEqualToString:kSXCXcodeMemberTypePBXProject]; +} + +- (BOOL)sxc_hasNativeTargetType { + return [self isEqualToString:kSXCXcodeMemberTypePBXNativeTarget]; +} + +- (BOOL)sxc_hasBuildFileType { + return [self isEqualToString:kSXCXcodeMemberTypePBXBuildFile]; +} + +- (BOOL)sxc_hasBuildConfigurationType { + return [self isEqualToString:kSXCXcodeMemberTypeXCBuildConfiguration]; +} + +- (BOOL)sxc_hasContainerItemProxyType { + return [self isEqualToString:kSXCXcodeMemberTypePBXContainerItemProxy]; +} + +- (BOOL)sxc_hasResourcesBuildPhaseType { + return [self isEqualToString:kSXCXcodeMemberTypePBXResourcesBuildPhase]; +} + +- (BOOL)sxc_hasSourcesOrFrameworksBuildPhaseType { + return [self isEqualToString:kSXCXcodeMemberTypePBXSourcesBuildPhase] || + [self isEqualToString:kSXCXcodeMemberTypePBXFrameworksBuildPhase]; +} + +@end diff --git a/Source/XCXibDefinition.h b/Source/SXCXibDefinition.h similarity index 65% rename from Source/XCXibDefinition.h rename to Source/SXCXibDefinition.h index d7018a8..f7fe803 100755 --- a/Source/XCXibDefinition.h +++ b/Source/SXCXibDefinition.h @@ -9,27 +9,21 @@ // //////////////////////////////////////////////////////////////////////////////// - - #import -#import "XCAbstractDefinition.h" +#import "SXCAbstractDefinition.h" -@interface XCXibDefinition : XCAbstractDefinition +@interface SXCXibDefinition : SXCAbstractDefinition { NSString* _name; NSString* _content; } + @property(nonatomic, strong, readonly) NSString* name; @property(nonatomic, strong) NSString* content; -+ (XCXibDefinition*)xibDefinitionWithName:(NSString*)name; - -+ (XCXibDefinition*)xibDefinitionWithName:(NSString*)name content:(NSString*)content; - -- (id)initWithName:(NSString*)name; - -- (id)initWithName:(NSString*)name content:(NSString*)content; ++ (instancetype)xibDefinitionWithName:(NSString*)name; ++ (instancetype)xibDefinitionWithName:(NSString*)name content:(NSString*)content; - (NSString*)xibFileName; diff --git a/Source/XCXibDefinition.m b/Source/SXCXibDefinition.m similarity index 61% rename from Source/XCXibDefinition.m rename to Source/SXCXibDefinition.m index 27a9c7c..7d31350 100755 --- a/Source/XCXibDefinition.m +++ b/Source/SXCXibDefinition.m @@ -9,38 +9,35 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCXibDefinition.h" -#import "XCXibDefinition.h" - -@implementation XCXibDefinition +@implementation SXCXibDefinition @synthesize name = _name; @synthesize content = _content; -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Class Methods -+ (XCXibDefinition*)xibDefinitionWithName:(NSString*)name ++ (instancetype)xibDefinitionWithName:(NSString*)name { - return [[XCXibDefinition alloc] initWithName:name]; + return [[self alloc] initWithName:name]; } -+ (XCXibDefinition*)xibDefinitionWithName:(NSString*)name content:(NSString*)content ++ (instancetype)xibDefinitionWithName:(NSString*)name content:(NSString*)content { - return [[XCXibDefinition alloc] initWithName:name content:content]; + return [[self alloc] initWithName:name content:content]; } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Initialization & Destruction -- (id)initWithName:(NSString*)name +- (instancetype)initWithName:(NSString*)name { return [self initWithName:name content:nil]; } - -- (id)initWithName:(NSString*)name content:(NSString*)content +- (instancetype)initWithName:(NSString*)name content:(NSString*)content { self = [super init]; if (self) @@ -51,8 +48,7 @@ - (id)initWithName:(NSString*)name content:(NSString*)content return self; } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Interface Methods - (NSString*)xibFileName @@ -60,4 +56,4 @@ - (NSString*)xibFileName return [_name stringByAppendingString:@".xib"]; } -@end \ No newline at end of file +@end diff --git a/Source/Utils/XCKeyBuilder.h b/Source/Utils/SXCKeyBuilder.h similarity index 53% rename from Source/Utils/XCKeyBuilder.h rename to Source/Utils/SXCKeyBuilder.h index 1183308..05d86d1 100755 --- a/Source/Utils/XCKeyBuilder.h +++ b/Source/Utils/SXCKeyBuilder.h @@ -9,30 +9,15 @@ // //////////////////////////////////////////////////////////////////////////////// - #import -#import - -#define HASH_VALUE_STORAGE_SIZE 48 - -typedef struct -{ - char value[CC_MD5_DIGEST_LENGTH]; -} HashValueMD5Hash; +@interface SXCKeyBuilder : NSObject -@interface XCKeyBuilder : NSObject -{ - unsigned char _value[HASH_VALUE_STORAGE_SIZE]; -} ++ (instancetype)forItemNamed:(NSString*)name; ++ (instancetype)createUnique; -+ (XCKeyBuilder*)forItemNamed:(NSString*)name; - -+ (XCKeyBuilder*)createUnique; - -- (id)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length; +- (instancetype)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length; - (NSString*)build; @end - diff --git a/Source/Utils/XCKeyBuilder.m b/Source/Utils/SXCKeyBuilder.m similarity index 67% rename from Source/Utils/XCKeyBuilder.m rename to Source/Utils/SXCKeyBuilder.m index 77476a5..8ad089e 100755 --- a/Source/Utils/XCKeyBuilder.m +++ b/Source/Utils/SXCKeyBuilder.m @@ -9,29 +9,40 @@ // //////////////////////////////////////////////////////////////////////////////// -#import "XCKeyBuilder.h" +#import "SXCKeyBuilder.h" -@implementation XCKeyBuilder +#import + +#define HASH_VALUE_STORAGE_SIZE 48 + +typedef struct +{ + char value[CC_MD5_DIGEST_LENGTH]; +} SXCHashValueMD5Hash; + +@implementation SXCKeyBuilder +{ + unsigned char _value[HASH_VALUE_STORAGE_SIZE]; +} /* ================================================= Class Methods ================================================== */ -+ (XCKeyBuilder*)forItemNamed:(NSString*)name ++ (instancetype)forItemNamed:(NSString*)name { NSData* data = [name dataUsingEncoding:NSUTF8StringEncoding]; - return [[XCKeyBuilder alloc] initHashValueMD5HashWithBytes:[data bytes] length:[data length]]; - + return [[SXCKeyBuilder alloc] initHashValueMD5HashWithBytes:[data bytes] length:[data length]]; } -+ (XCKeyBuilder*)createUnique ++ (instancetype)createUnique { CFUUIDRef theUUID = CFUUIDCreate(NULL); CFUUIDBytes bytes = CFUUIDGetUUIDBytes(theUUID); CFRelease(theUUID); - return [[XCKeyBuilder alloc] initHashValueMD5HashWithBytes:&bytes length:sizeof(bytes)]; + return [[SXCKeyBuilder alloc] initHashValueMD5HashWithBytes:&bytes length:sizeof(bytes)]; } /* ================================================== Initializers ================================================== */ -- (id)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length +- (instancetype)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length { self = [super init]; if (self != nil) @@ -44,7 +55,7 @@ - (id)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length /* ================================================ Interface Methods =============================================== */ - (NSString*)build { - NSInteger byteLength = sizeof(HashValueMD5Hash); + NSInteger byteLength = sizeof(SXCHashValueMD5Hash); NSMutableString* stringValue = [NSMutableString stringWithCapacity:byteLength * 2]; NSInteger i; for (i = 0; i < byteLength; i++) @@ -54,5 +65,4 @@ - (NSString*)build return [[stringValue substringToIndex:24] uppercaseString]; } - @end diff --git a/Source/XCClassDefinition.m b/Source/XCClassDefinition.m deleted file mode 100755 index 6cd795d..0000000 --- a/Source/XCClassDefinition.m +++ /dev/null @@ -1,105 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 - 2013 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - - - - - -#import "XCClassDefinition.h" - -@implementation XCClassDefinition - - -@synthesize className = _className; -@synthesize header = _header; -@synthesize source = _source; - -/* ====================================================================================================================================== */ -#pragma mark - Class Methods - -+ (XCClassDefinition*)classDefinitionWithName:(NSString*)fileName -{ - return [[XCClassDefinition alloc] initWithName:fileName]; -} - -+ (XCClassDefinition*)classDefinitionWithName:(NSString*)className language:(ClassDefinitionLanguage)language -{ - return [[XCClassDefinition alloc] initWithName:className language:language]; -} - -/* ====================================================================================================================================== */ -#pragma mark - Initialization & Destruction - -- (id)initWithName:(NSString*)className -{ - return [self initWithName:className language:ObjectiveC]; -} - -- (id)initWithName:(NSString*)className language:(ClassDefinitionLanguage)language -{ - self = [super init]; - if (self) - { - _className = [className copy]; - if (!(language == ObjectiveC || language == ObjectiveCPlusPlus || language == CPlusPlus)) - { - [NSException raise:NSInvalidArgumentException format:@"Language must be one of ObjectiveC, ObjectiveCPlusPlus"]; - } - _language = language; - } - return self; -} - - -/* ====================================================================================================================================== */ -#pragma mark - Interface Methods - -- (BOOL)isObjectiveC -{ - return _language == ObjectiveC; -} - -- (BOOL)isObjectiveCPlusPlus -{ - return _language == ObjectiveCPlusPlus; -} - -- (BOOL)isCPlusPlus -{ - return _language == CPlusPlus; -} - -- (NSString*)headerFileName -{ - return [_className stringByAppendingString:@".h"]; - -} - -- (NSString*)sourceFileName -{ - NSString* sourceFileName = nil; - if ([self isObjectiveC]) - { - sourceFileName = [_className stringByAppendingString:@".m"]; - } - else if ([self isObjectiveCPlusPlus]) - { - sourceFileName = [_className stringByAppendingString:@".mm"]; - } - else if ([self isCPlusPlus]) - { - sourceFileName = [_className stringByAppendingString:@".cpp"]; - } - return sourceFileName; -} - - -@end \ No newline at end of file diff --git a/Source/XCProject.m b/Source/XCProject.m deleted file mode 100755 index 964a0c0..0000000 --- a/Source/XCProject.m +++ /dev/null @@ -1,386 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 - 2013 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - - -#import "XCProject.h" -#import "XCGroup.h" -#import "XCSourceFile.h" -#import "XCTarget.h" -#import "XCFileOperationQueue.h" -#import "XCProjectBuildConfig.h" - - -@implementation XCProject - - -@synthesize fileOperationQueue = _fileOperationQueue; - -//------------------------------------------------------------------------------------------- -#pragma mark - Class Methods -//------------------------------------------------------------------------------------------- - -+ (XCProject*)projectWithFilePath:(NSString*)filePath -{ - return [[XCProject alloc] initWithFilePath:filePath]; -} - - -//------------------------------------------------------------------------------------------- -#pragma mark - Initialization & Destruction -//------------------------------------------------------------------------------------------- - -- (id)initWithFilePath:(NSString*)filePath -{ - if ((self = [super init])) - { - _filePath = [filePath copy]; - _dataStore = [[NSMutableDictionary alloc] initWithContentsOfFile:[_filePath stringByAppendingPathComponent:@"project.pbxproj"]]; - - if (!_dataStore) - { - [NSException raise:XCProjectNotFoundException format:@"Project file not found at file path %@", _filePath]; - } - - _fileOperationQueue = [[XCFileOperationQueue alloc] initWithBaseDirectory:[_filePath stringByDeletingLastPathComponent]]; - - } - return self; -} - -//------------------------------------------------------------------------------------------- -#pragma mark - Interface Methods -//------------------------------------------------------------------------------------------- - -#pragma mark Files - -- (NSArray*)files -{ - NSMutableArray* results = [NSMutableArray array]; - [[self objects] enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSDictionary* obj, BOOL* stop) - { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXFileReferenceType) - { - XcodeSourceFileType fileType = XCSourceFileTypeFromStringRepresentation([obj valueForKey:@"lastKnownFileType"]); - NSString* path = [obj valueForKey:@"path"]; - NSString* sourceTree = [obj valueForKey:@"sourceTree"]; - [results addObject:[XCSourceFile sourceFileWithProject:self key:key type:fileType name:path - sourceTree:(sourceTree ? sourceTree : @"") path:nil]]; - } - }]; - return results; -} - -- (XCSourceFile*)fileWithKey:(NSString*)key -{ - NSDictionary* obj = [[self objects] valueForKey:key]; - if (obj && ([[obj valueForKey:@"isa"] asMemberType] == PBXFileReferenceType || [[obj valueForKey:@"isa"] asMemberType] == - PBXReferenceProxyType)) - { - XcodeSourceFileType fileType = XCSourceFileTypeFromStringRepresentation([obj valueForKey:@"lastKnownFileType"]); - - NSString* name = [obj valueForKey:@"name"]; - NSString* sourceTree = [obj valueForKey:@"sourceTree"]; - - if (name == nil) - { - name = [obj valueForKey:@"path"]; - } - return [XCSourceFile sourceFileWithProject:self key:key type:fileType name:name sourceTree:(sourceTree ? sourceTree : @"") - path:[obj valueForKey:@"path"]]; - } - return nil; -} - -- (XCSourceFile*)fileWithName:(NSString*)name -{ - for (XCSourceFile* projectFile in [self files]) - { - if ([[projectFile name] isEqualToString:name]) - { - return projectFile; - } - } - return nil; -} - - -- (NSArray*)headerFiles -{ - return [self projectFilesOfType:SourceCodeHeader]; -} - -- (NSArray*)objectiveCFiles -{ - return [self projectFilesOfType:SourceCodeObjC]; -} - -- (NSArray*)objectiveCPlusPlusFiles -{ - return [self projectFilesOfType:SourceCodeObjCPlusPlus]; -} - - -- (NSArray*)xibFiles -{ - return [self projectFilesOfType:XibFile]; -} - -- (NSArray*)imagePNGFiles -{ - return [self projectFilesOfType:ImageResourcePNG]; -} - -// need this value to construct relative path in XcodeprojDefinition -- (NSString*)filePath -{ - return _filePath; -} - -//------------------------------------------------------------------------------------------- -#pragma mark Groups -//------------------------------------------------------------------------------------------- - -- (NSArray*)groups -{ - - NSMutableArray* results = [[NSMutableArray alloc] init]; - [[_dataStore objectForKey:@"objects"] enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSDictionary* obj, BOOL* stop) - { - - if ([[obj valueForKey:@"isa"] asMemberType] == PBXGroupType || [[obj valueForKeyPath:@"isa"] asMemberType] == PBXVariantGroupType) - { - [results addObject:[self groupWithKey:key]]; - } - }]; - return results; -} - -//TODO: Optimize this implementation. -- (XCGroup*)rootGroup -{ - for (XCGroup* group in [self groups]) - { - if ([group isRootGroup]) - { - return group; - } - } - return nil; -} - -- (NSArray*)rootGroups -{ - XCGroup* group = [self rootGroup]; - if (group) - { - return [NSArray arrayWithObject:group]; - } - - NSMutableArray* results = [NSMutableArray array]; - for (XCGroup* group in [self groups]) - { - if ([group parentGroup] == nil) - { - [results addObject:group]; - } - } - - return [results copy]; -} - -- (XCGroup*)groupWithKey:(NSString*)key -{ - XCGroup* group = [_groups objectForKey:key]; - if (group) - { - return group; - } - - NSDictionary* obj = [[self objects] objectForKey:key]; - if (obj && ([[obj valueForKey:@"isa"] asMemberType] == PBXGroupType || [[obj valueForKey:@"isa"] asMemberType] == PBXVariantGroupType)) - { - - NSString* name = [obj valueForKey:@"name"]; - NSString* path = [obj valueForKey:@"path"]; - NSArray* children = [obj valueForKey:@"children"]; - XCGroup* group = [XCGroup groupWithProject:self key:key alias:name path:path children:children]; - - [_groups setObject:group forKey:key]; - - return group; - } - return nil; -} - -- (XCGroup*)groupForGroupMemberWithKey:(NSString*)key -{ - for (XCGroup* group in [self groups]) - { - if ([group memberWithKey:key]) - { - return group; - } - } - return nil; -} - -- (XCGroup*)groupWithSourceFile:(XCSourceFile*)sourceFile -{ - for (XCGroup* group in [self groups]) - { - for (id member in [group members]) - { - if ([member isKindOfClass:[XCSourceFile class]] && [[sourceFile key] isEqualToString:[member key]]) - { - return group; - } - } - } - return nil; -} - -//TODO: This could fail if the path attribute on a given group is more than one directory. Start with candidates and -//TODO: search backwards. -- (XCGroup*)groupWithPathFromRoot:(NSString*)path -{ - NSArray* pathItems = [path componentsSeparatedByString:@"/"]; - XCGroup* currentGroup = [self rootGroup]; - for (NSString* pathItem in pathItems) - { - id group = [currentGroup memberWithDisplayName:pathItem]; - if ([group isKindOfClass:[XCGroup class]]) - { - currentGroup = group; - } - else - { - return nil; - } - } - return currentGroup; -} - - -//------------------------------------------------------------------------------------------- -#pragma mark targets -//------------------------------------------------------------------------------------------- - -- (NSArray*)targets -{ - if (_targets == nil) - { - _targets = [[NSMutableArray alloc] init]; - [[self objects] enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSDictionary* obj, BOOL* stop) - { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXNativeTargetType) - { - XCTarget* target = - [XCTarget targetWithProject:self key:key name:[obj valueForKey:@"name"] productName:[obj valueForKey:@"productName"] - productReference:[obj valueForKey:@"productReference"]]; - [_targets addObject:target]; - } - }]; - } - return _targets; -} - -- (XCTarget*)targetWithName:(NSString*)name -{ - for (XCTarget* target in [self targets]) - { - if ([[target name] isEqualToString:name]) - { - return target; - } - } - return nil; -} - -- (void)save -{ - [_fileOperationQueue commitFileOperations]; - [_dataStore writeToFile:[_filePath stringByAppendingPathComponent:@"project.pbxproj"] atomically:YES]; - - NSLog(@"Saved project"); -} - -- (NSMutableDictionary*)objects -{ - return [_dataStore objectForKey:@"objects"]; -} - -- (NSMutableDictionary*)dataStore -{ - return _dataStore; -} - -- (void)dropCache -{ - _targets = nil; - _configurations = nil; - _rootObjectKey = nil; -} - - -- (NSDictionary*)configurations -{ - if (_configurations == nil) - { - NSString* buildConfigurationRootSectionKey = - [[[self objects] objectForKey:[self rootObjectKey]] objectForKey:@"buildConfigurationList"]; - NSDictionary* buildConfigurationDictionary = [[self objects] objectForKey:buildConfigurationRootSectionKey]; - _configurations = - [[XCProjectBuildConfig buildConfigurationsFromArray:[buildConfigurationDictionary objectForKey:@"buildConfigurations"] - inProject:self] mutableCopy]; - _defaultConfigurationName = [[buildConfigurationDictionary objectForKey:@"defaultConfigurationName"] copy]; - } - - return [_configurations copy]; -} - -- (NSDictionary*)configurationWithName:(NSString*)name -{ - return [[self configurations] objectForKey:name]; -} - -- (XCProjectBuildConfig *)defaultConfiguration -{ - return [[self configurations] objectForKey:_defaultConfigurationName]; -} - -//------------------------------------------------------------------------------------------- -#pragma mark Private -//------------------------------------------------------------------------------------------- - -- (NSString*)rootObjectKey -{ - if (_rootObjectKey == nil) - { - _rootObjectKey = [[_dataStore objectForKey:@"rootObject"] copy];; - } - - return _rootObjectKey; -} - -- (NSArray*)projectFilesOfType:(XcodeSourceFileType)projectFileType -{ - NSMutableArray* results = [NSMutableArray array]; - for (XCSourceFile* file in [self files]) - { - if ([file type] == projectFileType) - { - [results addObject:file]; - } - } - return results; -} - -@end \ No newline at end of file diff --git a/Source/XCSourceFileDefinition.h b/Source/XCSourceFileDefinition.h deleted file mode 100644 index 0444f5d..0000000 --- a/Source/XCSourceFileDefinition.h +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - - - -#import -#import "XCAbstractDefinition.h" -#import "XcodeSourceFileType.h" - -@interface XCSourceFileDefinition : XCAbstractDefinition -{ - - NSString* _sourceFileName; - XcodeSourceFileType _type; - NSData* _data; - -} - -@property(nonatomic, strong, readonly) NSString* sourceFileName; -@property(nonatomic, strong, readonly) NSData* data; -@property(nonatomic, readonly) XcodeSourceFileType type; - -+ (XCSourceFileDefinition*)sourceDefinitionWithName:(NSString*)name text:(NSString*)text type:(XcodeSourceFileType)type; - -+ (XCSourceFileDefinition*)sourceDefinitionWithName:(NSString*)name data:(NSData*)data type:(XcodeSourceFileType)type; - -- (id)initWithName:(NSString*)name text:(NSString*)text type:(XcodeSourceFileType)type; - -- (id)initWithName:(NSString*)name data:(NSData*)data type:(XcodeSourceFileType)type; - - -@end diff --git a/Source/XCTarget.m b/Source/XCTarget.m deleted file mode 100755 index 741b6fb..0000000 --- a/Source/XCTarget.m +++ /dev/null @@ -1,392 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - -#import "XCGroup.h" -#import "XCKeyBuilder.h" -#import "XCTarget.h" -#import "XCSourceFile.h" -#import "XCProject.h" -#import "XCProjectBuildConfig.h" - -@implementation XCTarget - -/* ====================================================================================================================================== */ -#pragma mark - Class Methods - -+ (XCTarget*)targetWithProject:(XCProject*)project key:(NSString*)key name:(NSString*)name productName:(NSString*)productName - productReference:(NSString*)productReference -{ - return [[XCTarget alloc] initWithProject:project key:key name:name productName:productName productReference:productReference]; -} - - -/* ====================================================================================================================================== */ -#pragma mark - Initialization & Destruction - -- (id)initWithProject:(XCProject*)project key:(NSString*)key name:(NSString*)name productName:(NSString*)productName - productReference:(NSString*)productReference -{ - self = [super init]; - if (self) - { - _project = project; - _key = [key copy]; - _name = [name copy]; - _productName = [productName copy]; - _productReference = [productReference copy]; - } - return self; -} - -/* ====================================================================================================================================== */ -#pragma mark - Interface Methods - -- (NSArray*)resources -{ - if (_resources == nil) - { - _resources = [[NSMutableArray alloc] init]; - for (NSString* buildPhaseKey in [[[_project objects] objectForKey:_key] objectForKey:@"buildPhases"]) - { - NSDictionary* buildPhase = [[_project objects] objectForKey:buildPhaseKey]; - if ([[buildPhase valueForKey:@"isa"] asMemberType] == PBXResourcesBuildPhaseType) - { - for (NSString* buildFileKey in [buildPhase objectForKey:@"files"]) - { - XCSourceFile* targetMember = [self buildFileWithKey:buildFileKey]; - if (targetMember) - { - [_resources addObject:[self buildFileWithKey:buildFileKey]]; - } - } - } - } - } - - return _resources; -} - -- (NSDictionary*)configurations -{ - if (_configurations == nil) - { - NSString* buildConfigurationRootSectionKey = [[[_project objects] objectForKey:_key] objectForKey:@"buildConfigurationList"]; - NSDictionary* buildConfigurationDictionary = [[_project objects] objectForKey:buildConfigurationRootSectionKey]; - _configurations = - [[XCProjectBuildConfig buildConfigurationsFromArray:[buildConfigurationDictionary objectForKey:@"buildConfigurations"] - inProject:_project] mutableCopy]; - _defaultConfigurationName = [[buildConfigurationDictionary objectForKey:@"defaultConfigurationName"] copy]; - } - - return _configurations; -} - -- (XCProjectBuildConfig *)defaultConfiguration -{ - return [[self configurations] objectForKey:_defaultConfigurationName]; -} - -- (XCProjectBuildConfig *)configurationWithName:(NSString*)name -{ - return [[self configurations] objectForKey:name]; -} - -- (NSArray*)members -{ - if (_members == nil) - { - _members = [[NSMutableArray alloc] init]; - for (NSString* buildPhaseKey in [[[_project objects] objectForKey:_key] objectForKey:@"buildPhases"]) - { - NSDictionary* buildPhase = [[_project objects] objectForKey:buildPhaseKey]; - if ([[buildPhase valueForKey:@"isa"] asMemberType] == PBXSourcesBuildPhaseType || - [[buildPhase valueForKey:@"isa"] asMemberType] == PBXFrameworksBuildPhaseType) - { - for (NSString* buildFileKey in [buildPhase objectForKey:@"files"]) - { - XCSourceFile* targetMember = [self buildFileWithKey:buildFileKey]; - if (targetMember) - { - [_members addObject:[_project fileWithKey:targetMember.key]]; - } - } - } - } - } - return _members; -} - -- (void)addMember:(XCSourceFile*)member -{ - [member becomeBuildFile]; - NSDictionary* target = [[_project objects] objectForKey:_key]; - - for (NSString* buildPhaseKey in [target objectForKey:@"buildPhases"]) - { - NSMutableDictionary* buildPhase = [[_project objects] objectForKey:buildPhaseKey]; - if ([[buildPhase valueForKey:@"isa"] asMemberType] == [member buildPhase]) - { - - NSMutableArray* files = [buildPhase objectForKey:@"files"]; - if (![files containsObject:[member buildFileKey]]) - { - [files addObject:[member buildFileKey]]; - } - - [buildPhase setObject:files forKey:@"files"]; - } - } - [self flagMembersAsDirty]; -} - -- (NSDictionary*)buildRefWithFileRefKey -{ - NSMutableDictionary* buildRefWithFileRefDict = [NSMutableDictionary dictionary]; - NSDictionary* allObjects = [_project objects]; - NSArray* keys = [allObjects allKeys]; - - for (NSString* key in keys) - { - NSDictionary* dictionaryInfo = [allObjects objectForKey:key]; - - NSString* type = [dictionaryInfo objectForKey:@"isa"]; - if (type) - { - if ([type isEqualToString:@"PBXBuildFile"]) - { - NSString* fileRef = [dictionaryInfo objectForKey:@"fileRef"]; - - if (fileRef) - { - [buildRefWithFileRefDict setObject:key forKey:fileRef]; - } - } - } - } - return buildRefWithFileRefDict; -} - -- (void)removeMemberWithKey:(NSString*)key -{ - - NSDictionary* buildRefWithFileRef = [self buildRefWithFileRefKey]; - NSDictionary* target = [[_project objects] objectForKey:_key]; - NSString* buildRef = [buildRefWithFileRef objectForKey:key]; - - if (!buildRef) - { - return; - } - - for (NSString* buildPhaseKey in [target objectForKey:@"buildPhases"]) - { - NSMutableDictionary* buildPhase = [[_project objects] objectForKey:buildPhaseKey]; - NSMutableArray* files = [buildPhase objectForKey:@"files"]; - - [files removeObjectIdenticalTo:buildRef]; - [buildPhase setObject:files forKey:@"files"]; - } - [self flagMembersAsDirty]; -} - -- (void)removeMembersWithKeys:(NSArray*)keys -{ - for (NSString* key in keys) - { - [self removeMemberWithKey:key]; - } -} - -- (void)addDependency:(NSString*)key -{ - NSDictionary* targetObj = [[_project objects] objectForKey:_key]; - NSMutableArray* dependencies = [targetObj valueForKey:@"dependencies"]; - // add only if not already there - BOOL found = NO; - for (NSString* dependency in dependencies) - { - if ([dependency isEqualToString:key]) - { - found = YES; - break; - } - } - if (!found) - { - [dependencies addObject:key]; - } -} - -- (instancetype)duplicateWithTargetName:(NSString*)targetName productName:(NSString*)productName -{ - - NSDictionary* targetObj = _project.objects[_key]; - NSMutableDictionary* dupTargetObj = [targetObj mutableCopy]; - - dupTargetObj[@"name"] = targetName; - dupTargetObj[@"productName"] = productName; - - NSString* buildConfigurationListKey = dupTargetObj[@"buildConfigurationList"]; - - void(^visitor)(NSMutableDictionary*) = ^(NSMutableDictionary* buildConfiguration) - { - buildConfiguration[@"buildSettings"][@"PRODUCT_NAME"] = productName; - }; - - dupTargetObj[@"buildConfigurationList"] = - [XCProjectBuildConfig duplicatedBuildConfigurationListWithKey:buildConfigurationListKey inProject:_project - withBuildConfigurationVisitor:visitor]; - - [self duplicateProductReferenceForTargetObject:dupTargetObj withProductName:productName]; - - [self duplicateBuildPhasesForTargetObject:dupTargetObj]; - - [self addReferenceToProductsGroupForTargetObject:dupTargetObj]; - - NSString* dupTargetObjKey = [self addTargetToRootObjectTargets:dupTargetObj]; - - [_project dropCache]; - - return [[XCTarget alloc] initWithProject:_project key:dupTargetObjKey name:targetName productName:productName - productReference:dupTargetObj[@"productReference"]]; -} - -/* ====================================================================================================================================== */ -#pragma mark - Overridden Methods - -- (void)setName:(NSString*)name -{ - _name = name; - NSDictionary* dictionary = [_project.objects objectForKey:_key]; - [dictionary setValue:_name forKey:@"name"]; -} - -- (void)setProductName:(NSString*)productName -{ - _productName = productName; - NSDictionary* dictionary = [_project.objects objectForKey:_key]; - [dictionary setValue:_productName forKey:@"productName"]; -} - - - -/* ====================================================================================================================================== */ -#pragma mark - Utility Methods - -- (NSString*)description -{ - return [NSString stringWithFormat:@"Target: name=%@, files=%@", _name, _members]; -} - -/* ====================================================================================================================================== */ -#pragma mark - Private Methods - -- (XCSourceFile*)buildFileWithKey:(NSString*)theKey -{ - NSDictionary* obj = [[_project objects] valueForKey:theKey]; - if (obj) - { - if ([[obj valueForKey:@"isa"] asMemberType] == PBXBuildFileType) - { - return [_project fileWithKey:[obj valueForKey:@"fileRef"]]; - } - } - return nil; -} - -- (void)flagMembersAsDirty -{ - _members = nil; -} - -- (void)duplicateProductReferenceForTargetObject:(NSMutableDictionary*)dupTargetObj withProductName:(NSString*)productName -{ - - NSString* productReferenceKey = dupTargetObj[@"productReference"]; - NSMutableDictionary* dupProductReference = [_project.objects[productReferenceKey] mutableCopy]; - - NSString* path = dupProductReference[@"path"]; - NSString* dupPath = [path stringByDeletingLastPathComponent]; - dupPath = [dupPath stringByAppendingPathComponent:productName]; - dupPath = [dupPath stringByAppendingPathExtension:@"app"]; - dupProductReference[@"path"] = dupPath; - - NSString* dupProductReferenceKey = [[XCKeyBuilder createUnique] build]; - - _project.objects[dupProductReferenceKey] = dupProductReference; - dupTargetObj[@"productReference"] = dupProductReferenceKey; -} - -- (void)duplicateBuildPhasesForTargetObject:(NSMutableDictionary*)dupTargetObj -{ - - NSMutableArray* buildPhases = [NSMutableArray array]; - - for (NSString* buildPhaseKey in dupTargetObj[@"buildPhases"]) - { - - NSMutableDictionary* dupBuildPhase = [_project.objects[buildPhaseKey] mutableCopy]; - NSMutableArray* dupFiles = [NSMutableArray array]; - - for (NSString* fileKey in dupBuildPhase[@"files"]) - { - - NSMutableDictionary* dupFile = [_project.objects[fileKey] mutableCopy]; - NSString* dupFileKey = [[XCKeyBuilder createUnique] build]; - - _project.objects[dupFileKey] = dupFile; - [dupFiles addObject:dupFileKey]; - } - - dupBuildPhase[@"files"] = dupFiles; - - NSString* dupBuildPhaseKey = [[XCKeyBuilder createUnique] build]; - _project.objects[dupBuildPhaseKey] = dupBuildPhase; - [buildPhases addObject:dupBuildPhaseKey]; - } - - dupTargetObj[@"buildPhases"] = buildPhases; -} - -- (void)addReferenceToProductsGroupForTargetObject:(NSMutableDictionary*)dupTargetObj -{ - - XCGroup* mainGroup = nil; - NSPredicate* productsPredicate = [NSPredicate predicateWithFormat:@"displayName == 'Products'"]; - NSArray* filteredGroups = [_project.groups filteredArrayUsingPredicate:productsPredicate]; - - if (filteredGroups.count > 0) - { - mainGroup = filteredGroups[0]; - NSMutableArray* children = [_project.objects[mainGroup.key][@"children"] mutableCopy]; - [children addObject:dupTargetObj[@"productReference"]]; - _project.objects[mainGroup.key][@"children"] = children; - } -} - -- (NSString*)addTargetToRootObjectTargets:(NSMutableDictionary*)dupTargetObj -{ - NSString* dupTargetObjKey = [[XCKeyBuilder createUnique] build]; - - _project.objects[dupTargetObjKey] = dupTargetObj; - - NSString* rootObjKey = _project.dataStore[@"rootObject"]; - NSMutableDictionary* rootObj = [_project.objects[rootObjKey] mutableCopy]; - NSMutableArray* rootObjTargets = [rootObj[@"targets"] mutableCopy]; - [rootObjTargets addObject:dupTargetObjKey]; - - rootObj[@"targets"] = rootObjTargets; - _project.objects[rootObjKey] = rootObj; - - return dupTargetObjKey; -} - -@end diff --git a/Source/XcodeMemberType.h b/Source/XcodeMemberType.h deleted file mode 100755 index 205a9c1..0000000 --- a/Source/XcodeMemberType.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - - - -typedef enum -{ - PBXNilType, - PBXBuildFileType, - PBXContainerItemProxyType, - PBXCopyFilesBuildPhaseType, - PBXFileReferenceType, - PBXFrameworksBuildPhaseType, - PBXGroupType, - PBXNativeTargetType, - PBXProjectType, - PBXReferenceProxyType, - PBXResourcesBuildPhaseType, - PBXSourcesBuildPhaseType, - PBXTargetDependencyType, - PBXVariantGroupType, - XCBuildConfigurationType, - XCConfigurationListType -} XcodeMemberType; - -@interface NSString (XcodeMemberTypeExtensions) - -+ (NSString*)stringFromMemberType:(XcodeMemberType)nodeType; - -- (XcodeMemberType)asMemberType; - -@end - - diff --git a/Source/XcodeMemberType.m b/Source/XcodeMemberType.m deleted file mode 100755 index bd46bf6..0000000 --- a/Source/XcodeMemberType.m +++ /dev/null @@ -1,68 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - - - - -#import "XcodeMemberType.h" - - -@implementation NSDictionary (XcodeMemberType) - - -+ (NSDictionary*)dictionaryWithProjectNodeTypesAsStrings -{ - // This is the most vital operation on adding 500+ files - // So, we caching this dictionary - static NSDictionary* _projectNodeTypesAsStrings; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^ - { - _projectNodeTypesAsStrings = - [[NSDictionary alloc] initWithObjectsAndKeys:@(PBXNilType), @"PBXNilType", - @(PBXBuildFileType), @"PBXBuildFile", - @(PBXContainerItemProxyType), @"PBXContainerItemProxy", - @(PBXCopyFilesBuildPhaseType), @"PBXCopyFilesBuildPhase", - @(PBXFileReferenceType), @"PBXFileReference", - @(PBXFrameworksBuildPhaseType), @"PBXFrameworksBuildPhase", - @(PBXGroupType), @"PBXGroup", - @(PBXNativeTargetType), @"PBXNativeTarget", - @(PBXProjectType), @"PBXProject", - @(PBXReferenceProxyType), @"PBXReferenceProxy", - @(PBXResourcesBuildPhaseType), @"PBXResourcesBuildPhase", - @(PBXSourcesBuildPhaseType), @"PBXSourcesBuildPhase", - @(PBXTargetDependencyType), @"PBXTargetDependency", - @(PBXVariantGroupType), @"PBXVariantGroup", - @(XCBuildConfigurationType), @"XCBuildConfiguration", - @(XCConfigurationListType), @"XCConfigurationList", nil]; - }); - return _projectNodeTypesAsStrings; -} - -@end - -@implementation NSString (XcodeMemberTypeExtensions) - -+ (NSString*)stringFromMemberType:(XcodeMemberType)nodeType -{ - NSDictionary* nodeTypesToString = [NSDictionary dictionaryWithProjectNodeTypesAsStrings]; - return [[nodeTypesToString allKeysForObject:@(nodeType)] objectAtIndex:0]; -} - - -- (XcodeMemberType)asMemberType -{ - NSDictionary* nodeTypesToString = [NSDictionary dictionaryWithProjectNodeTypesAsStrings]; - return (XcodeMemberType) [[nodeTypesToString objectForKey:self] intValue]; -} - - -@end \ No newline at end of file diff --git a/Source/XcodeSourceFileType.h b/Source/XcodeSourceFileType.h deleted file mode 100755 index 8102d98..0000000 --- a/Source/XcodeSourceFileType.h +++ /dev/null @@ -1,38 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - -#import - -typedef NS_OPTIONS(NSInteger, XcodeSourceFileType) -{ - FileTypeNil = 0, // Unknown filetype - Framework = 1, // .framework - PropertyList = 2, // .plist - SourceCodeHeader = 3, // .h - SourceCodeObjC = 4, // .m - SourceCodeObjCPlusPlus = 5, // .mm - SourceCodeCPlusPlus = 6, // .cpp - XibFile = 7, // .xib - ImageResourcePNG = 8, // .png - Bundle = 9, // .bundle .octet - Archive = 10, // .a files - HTML = 11, // HTML file - TEXT = 12, // Some text file - XcodeProject = 13, // .xcodeproj - Folder = 14 // a Folder reference -}; - -NSString* NSStringFromXCSourceFileType(XcodeSourceFileType type); - -XcodeSourceFileType XCSourceFileTypeFromStringRepresentation(NSString* string); - -XcodeSourceFileType XCSourceFileTypeFromFileName(NSString* fileName); - diff --git a/Source/XcodeSourceFileType.m b/Source/XcodeSourceFileType.m deleted file mode 100755 index 39fdc7a..0000000 --- a/Source/XcodeSourceFileType.m +++ /dev/null @@ -1,83 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - - - -#import "XcodeSourceFileType.h" - -static NSDictionary* NSDictionaryWithXCFileReferenceTypes() -{ - static NSDictionary* dictionary; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^ - { - dictionary = @{ - @"sourcecode.c.h" : @(SourceCodeHeader), - @"sourcecode.c.objc" : @(SourceCodeObjC), - @"wrapper.framework" : @(Framework), - @"text.plist.strings" : @(PropertyList), - @"sourcecode.cpp.objcpp" : @(SourceCodeObjCPlusPlus), - @"sourcecode.cpp.cpp" : @(SourceCodeCPlusPlus), - @"file.xib" : @(XibFile), - @"image.png" : @(ImageResourcePNG), - @"wrapper.cfbundle" : @(Bundle), - @"archive.ar" : @(Archive), - @"text.html" : @(HTML), - @"text" : @(TEXT), - @"wrapper.pb-project" : @(XcodeProject), - @"folder" : @(Folder) - }; - }); - - return dictionary; -} - -NSString* NSStringFromXCSourceFileType(XcodeSourceFileType type) -{ - return [[NSDictionaryWithXCFileReferenceTypes() allKeysForObject:@(type)] objectAtIndex:0]; -} - -XcodeSourceFileType XCSourceFileTypeFromStringRepresentation(NSString* string) -{ - NSDictionary* typeStrings = NSDictionaryWithXCFileReferenceTypes(); - - if (typeStrings[string]) - { - return (XcodeSourceFileType) [typeStrings[string] intValue]; - } - else - { - return FileTypeNil; - } -} - - -XcodeSourceFileType XCSourceFileTypeFromFileName(NSString* fileName) -{ - if ([fileName hasSuffix:@".h"] || [fileName hasSuffix:@".hh"] || [fileName hasSuffix:@".hpp"] || [fileName hasSuffix:@".hxx"]) - { - return SourceCodeHeader; - } - if ([fileName hasSuffix:@".c"] || [fileName hasSuffix:@".m"]) - { - return SourceCodeObjC; - } - if ([fileName hasSuffix:@".mm"]) - { - return SourceCodeObjCPlusPlus; - } - if ([fileName hasSuffix:@".cpp"]) - { - return SourceCodeCPlusPlus; - } - return FileTypeNil; -} - diff --git a/XcodeEditor.podspec b/XcodeEditor.podspec index 3c9844e..ea0776e 100644 --- a/XcodeEditor.podspec +++ b/XcodeEditor.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'XcodeEditor' - s.version = '1.6.2' + s.version = '2.0.0' s.license = 'Apache2.0' s.summary = 'An API for manipulating Xcode Projects using objective-C.' - s.homepage = 'https://github.com/jasperblues/XcodeEditor' + s.homepage = 'https://github.com/StoneSpb/XcodeEditor' s.author = { 'Jasper Blues' => 'jasper@appsquick.ly' } - s.source = { :git => 'https://github.com/jasperblues/XcodeEditor.git', :tag => 'v1.6.2' } + s.source = { :git => 'https://github.com/StoneSpb/XcodeEditor.git', :tag => 'v2.0.0' } s.platform = :osx s.source_files = 'Source/*.{h,m}', 'Source/Utils/*.{h,m}' s.requires_arc = true diff --git a/XcodeEditorTests/Resources/project.pbxproj b/XcodeEditorTests/Resources/project.pbxproj index 076c905..9d4a054 100644 --- a/XcodeEditorTests/Resources/project.pbxproj +++ b/XcodeEditorTests/Resources/project.pbxproj @@ -63,7 +63,7 @@ 6BC101871477A42F0055CF03 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 12; - dstPath = /tmp; + dstPath = /tmp/XcodeEditorTests; dstSubfolderSpec = 0; files = ( 6B783C0714AD8DF20087E522 /* ESA_Sales_Calc_ViewController.h in CopyFiles */, diff --git a/XcodeEditorTests/XCClassDefinitionTests.m b/XcodeEditorTests/SXCClassDefinitionTests.m similarity index 61% rename from XcodeEditorTests/XCClassDefinitionTests.m rename to XcodeEditorTests/SXCClassDefinitionTests.m index 2a5e95b..ba1fe7b 100644 --- a/XcodeEditorTests/XCClassDefinitionTests.m +++ b/XcodeEditorTests/SXCClassDefinitionTests.m @@ -9,25 +9,24 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCClassDefinition.h" + #import -#import "XCClassDefinition.h" -@interface XCClassDefinitionTests : XCTestCase +@interface SXCClassDefinitionTests : XCTestCase @end -@implementation XCClassDefinitionTests +@implementation SXCClassDefinitionTests { - XCClassDefinition* classDefinition; + SXCClassDefinition* classDefinition; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Object creation - - - (void)test_allows_initialization_with_a_fileName_attribute { - classDefinition = [[XCClassDefinition alloc] initWithName:@"ESA_Sales_Browse_ViewController"]; + classDefinition = [SXCClassDefinition classDefinitionWithName:@"ESA_Sales_Browse_ViewController"]; XCTAssertNotNil(classDefinition.className); XCTAssertEqualObjects(classDefinition.className, @"ESA_Sales_Browse_ViewController"); @@ -36,7 +35,8 @@ - (void)test_allows_initialization_with_a_fileName_attribute - (void)test_allow_initialization_with_a_filename_and_language_attribute { - classDefinition = [[XCClassDefinition alloc] initWithName:@"ESA_Sales_Browse_ViewController" language:ObjectiveCPlusPlus]; + classDefinition = [SXCClassDefinition classDefinitionWithName:@"ESA_Sales_Browse_ViewController" + language:SXCClassDefinitionLanguageObjectiveCPlusPlus]; XCTAssertTrue([classDefinition isObjectiveCPlusPlus]); } @@ -44,7 +44,8 @@ - (void)test_it_throws_an_exception_if_one_of_the_above_languages_is_not_specifi { @try { - classDefinition = [[XCClassDefinition alloc] initWithName:@"ESA_Sales_Browse_ViewController" language:999]; + classDefinition = [SXCClassDefinition classDefinitionWithName:@"ESA_Sales_Browse_ViewController" + language:999]; [NSException raise:@"Test fails." format:@"Expected exception to be thrown"]; } @catch (NSException* e) @@ -53,24 +54,23 @@ - (void)test_it_throws_an_exception_if_one_of_the_above_languages_is_not_specifi } } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - File-names - - (void)test_it_returns_the_conventional_file_names_for_objective_c_classes { - classDefinition = [[XCClassDefinition alloc] initWithName:@"MyClass" language:ObjectiveC]; + classDefinition = [SXCClassDefinition classDefinitionWithName:@"MyClass" + language:SXCClassDefinitionLanguageObjectiveC]; XCTAssertEqualObjects([classDefinition headerFileName], @"MyClass.h"); XCTAssertEqualObjects([classDefinition sourceFileName], @"MyClass.m"); } - (void)test_it_returns_the_conventional_file_names_for_objective_cPlusPlus_classes { - classDefinition = [[XCClassDefinition alloc] initWithName:@"MyClass" language:ObjectiveCPlusPlus]; + classDefinition = [SXCClassDefinition classDefinitionWithName:@"MyClass" + language:SXCClassDefinitionLanguageObjectiveCPlusPlus]; XCTAssertEqualObjects([classDefinition headerFileName], @"MyClass.h"); XCTAssertEqualObjects([classDefinition sourceFileName], @"MyClass.mm"); } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/XCGroupTests.m b/XcodeEditorTests/SXCGroupTests.m similarity index 52% rename from XcodeEditorTests/XCGroupTests.m rename to XcodeEditorTests/SXCGroupTests.m index bf4f703..4952edc 100644 --- a/XcodeEditorTests/XCGroupTests.m +++ b/XcodeEditorTests/SXCGroupTests.m @@ -9,26 +9,27 @@ // //////////////////////////////////////////////////////////////////////////////// - +#import "SXCGroup.h" #import -#import "XCProject.h" -#import "XCGroup.h" -#import "XCSubProjectDefinition.h" -#import "XCClassDefinition.h" -#import "XCSourceFile.h" -#import "XCXibDefinition.h" -#import "XCTarget.h" -#import "XCFrameworkDefinition.h" -#import "XCSourceFileDefinition.h" -#import "NSString+TestResource.h" - -@interface XCFrameworkPath : NSObject + +#import "NSString+SXCTestResource.h" +#import "SXCClassDefinition.h" +#import "SXCFrameworkDefinition.h" +#import "SXCProject.h" +#import "SXCSourceFile.h" +#import "SXCSourceFileDefinition.h" +#import "SXCSubProjectDefinition.h" +#import "SXCTarget.h" +#import "SXCXibDefinition.h" + +@interface SXCFrameworkPath : NSObject @end -@implementation XCFrameworkPath +@implementation SXCFrameworkPath -static const NSString* SDK_PATH = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk"; +static const NSString* SDK_PATH = + @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk"; + (NSString*)eventKitUIPath { @@ -42,19 +43,18 @@ + (NSString*)coreMidiPath @end -@interface XCGroupTests : XCTestCase +@interface SXCGroupTests : XCTestCase @end -@implementation XCGroupTests +@implementation SXCGroupTests { - XCProject* project; - XCGroup* group; + SXCProject* project; + SXCGroup* group; } - - (void)setUp { - project = [[XCProject alloc] initWithFilePath:@"/tmp/expanz-iOS-SDK/expanz-iOS-SDK.xcodeproj"]; + project = [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/expanz-iOS-SDK/expanz-iOS-SDK.xcodeproj"]; group = [project groupWithPathFromRoot:@"Source/Main"]; XCTAssertNotNil(group); } @@ -64,7 +64,11 @@ - (void)setUp - (void)test_allows_initialization_with { - XCGroup* aGroup = [XCGroup groupWithProject:project key:@"abcd1234" alias:@"Main" path:@"Source/Main" children:nil]; + SXCGroup* aGroup = [SXCGroup groupWithProject:project + key:@"abcd1234" + alias:@"Main" + path:@"Source/Main" + children:nil]; XCTAssertNotNil(aGroup); XCTAssertEqualObjects([aGroup key], @"abcd1234"); @@ -73,8 +77,6 @@ - (void)test_allows_initialization_with XCTAssertTrue([[aGroup members] count] == 0); } - - /* ================================================================================================================== */ #pragma mark - Properties . . . @@ -93,22 +95,21 @@ - (void)test_able_to_return_its_full_path_relative_to_the_project_base_directory - (void)test_allows_adding_a_source_file { + SXCClassDefinition* classDefinition = [SXCClassDefinition classDefinitionWithName:@"MyViewController"]; - XCClassDefinition* classDefinition = [XCClassDefinition classDefinitionWithName:@"MyViewController"]; - - [classDefinition setHeader:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; - [classDefinition setSource:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; + [classDefinition setHeader:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; + [classDefinition setSource:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; NSLog(@"Class definition: %@", classDefinition); [group addClass:classDefinition]; [project save]; - XCSourceFile* fileResource = [project fileWithName:@"MyViewController.m"]; + SXCSourceFile* fileResource = [project fileWithName:@"MyViewController.m"]; XCTAssertNotNil(fileResource); XCTAssertEqualObjects([fileResource pathRelativeToProjectRoot], @"Source/Main/MyViewController.m"); - XCTarget* examples = [project targetWithName:@"Examples"]; + SXCTarget* examples = [project targetWithName:@"Examples"]; XCTAssertNotNil(examples); [examples addMember:fileResource]; @@ -121,105 +122,90 @@ - (void)test_allows_adding_a_source_file - (void)test_provides_a_convenience_method_to_add_a_source_file_and_specify_targets { + SXCClassDefinition* classDefinition = [SXCClassDefinition classDefinitionWithName:@"AnotherClassAdded"]; - XCClassDefinition* classDefinition = [XCClassDefinition classDefinitionWithName:@"AnotherClassAdded"]; - - [classDefinition setHeader:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; - [classDefinition setSource:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; + [classDefinition setHeader:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; + [classDefinition setSource:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; [group addClass:classDefinition toTargets:[project targets]]; [project save]; - } - (void)test_returns_a_warning_if_an_existing_class_is_overwritten { - - XCClassDefinition* classDefinition = [XCClassDefinition classDefinitionWithName:@"AddedTwice"]; - [classDefinition setHeader:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; - [classDefinition setSource:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; + SXCClassDefinition* classDefinition = [SXCClassDefinition classDefinitionWithName:@"AddedTwice"]; + [classDefinition setHeader:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; + [classDefinition setSource:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; [group addClass:classDefinition toTargets:[project targets]]; [project save]; - classDefinition = [XCClassDefinition classDefinitionWithName:@"AddedTwice"]; - [classDefinition setHeader:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; - [classDefinition setSource:[NSString stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; + classDefinition = [SXCClassDefinition classDefinitionWithName:@"AddedTwice"]; + [classDefinition setHeader:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.header"]]; + [classDefinition setSource:[NSString sxc_stringWithTestResource:@"ESA_Sales_Foobar_ViewController.impl"]]; [group addClass:classDefinition toTargets:[project targets]]; [project save]; - } - (void)test_allows_creating_a_reference_only_without_writing_to_disk { - - XCClassDefinition* classDefinition = [XCClassDefinition classDefinitionWithName:@"ClassWithoutSourceFileYet"]; - [classDefinition setFileOperationType:XCFileOperationTypeReferenceOnly]; + SXCClassDefinition* classDefinition = [SXCClassDefinition classDefinitionWithName:@"ClassWithoutSourceFileYet"]; + [classDefinition setFileOperationType:SXCFileOperationTypeReferenceOnly]; [group addClass:classDefinition toTargets:[project targets]]; [project save]; - } - - - /* ================================================================================================================== */ #pragma mark - adding objective-c++ files - - (void)test_allows_adding_files_of_type_obc_cPlusPlus { + SXCProject* anotherProject = + [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/HelloBoxy/HelloBoxy.xcodeproj"]; + SXCGroup* anotherGroup = [anotherProject groupWithPathFromRoot:@"Source"]; - XCProject* anotherProject = [XCProject projectWithFilePath:@"/tmp/HelloBoxy/HelloBoxy.xcodeproj"]; - XCGroup* anotherGroup = [anotherProject groupWithPathFromRoot:@"Source"]; - - XCClassDefinition* classDefinition = [XCClassDefinition classDefinitionWithName:@"HelloWorldLayer" language:ObjectiveCPlusPlus]; + SXCClassDefinition* classDefinition = + [SXCClassDefinition classDefinitionWithName:@"HelloWorldLayer" + language:SXCClassDefinitionLanguageObjectiveCPlusPlus]; - [classDefinition setHeader:[NSString stringWithTestResource:@"HelloWorldLayer.header"]]; - [classDefinition setSource:[NSString stringWithTestResource:@"HelloWorldLayer.impl"]]; + [classDefinition setHeader:[NSString sxc_stringWithTestResource:@"HelloWorldLayer.header"]]; + [classDefinition setSource:[NSString sxc_stringWithTestResource:@"HelloWorldLayer.impl"]]; [anotherGroup addClass:classDefinition toTargets:[anotherProject targets]]; [anotherProject save]; - } - - - /* ================================================================================================================== */ #pragma mark - Adding CPP files - (void)test__allows_using_a_class_definition_to_add_cpp_files { + SXCProject* anotherProject = + [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/HelloBoxy/HelloBoxy.xcodeproj"]; + SXCGroup* anotherGroup = [anotherProject groupWithPathFromRoot:@"Source"]; - XCProject* anotherProject = [XCProject projectWithFilePath:@"/tmp/HelloBoxy/HelloBoxy.xcodeproj"]; - XCGroup* anotherGroup = [anotherProject groupWithPathFromRoot:@"Source"]; - - XCClassDefinition* definition = [XCClassDefinition classDefinitionWithName:@"Person" language:CPlusPlus]; - [definition setSource:[NSString stringWithTestResource:@"Person.impl"]]; + SXCClassDefinition* definition = + [SXCClassDefinition classDefinitionWithName:@"Person" language:SXCClassDefinitionLanguageCPlusPlus]; + [definition setSource:[NSString sxc_stringWithTestResource:@"Person.impl"]]; [anotherGroup addClass:definition toTargets:[anotherProject targets]]; [anotherProject save]; - } - - /* ================================================================================================================== */ #pragma mark - adding xib files. - (void)test_should_allow_adding_a_xib_file { - - NSString* xibText = [NSString stringWithTestResource:@"ESA.Sales.Foobar.xib"]; - XCXibDefinition* xibDefinition = [XCXibDefinition xibDefinitionWithName:@"AddedXibFile" content:xibText]; + NSString* xibText = [NSString sxc_stringWithTestResource:@"ESA.Sales.Foobar.xib"]; + SXCXibDefinition* xibDefinition = [SXCXibDefinition xibDefinitionWithName:@"AddedXibFile" content:xibText]; [group addXib:xibDefinition]; [project save]; - XCSourceFile* xibFile = [project fileWithName:@"AddedXibFile.xib"]; + SXCSourceFile* xibFile = [project fileWithName:@"AddedXibFile.xib"]; XCTAssertNotNil(xibFile); - XCTarget* examples = [project targetWithName:@"Examples"]; + SXCTarget* examples = [project targetWithName:@"Examples"]; XCTAssertNotNil(examples); [examples addMember:xibFile]; @@ -228,54 +214,46 @@ - (void)test_should_allow_adding_a_xib_file [project save]; NSLog(@"Done adding xib file."); - } - (void)test_provides_a_convenience_method_to_add_a_xib_file_and_specify_targets { - - NSString* xibText = [NSString stringWithTestResource:@"ESA.Sales.Foobar.xib"]; - XCXibDefinition* xibDefinition = [XCXibDefinition xibDefinitionWithName:@"AnotherAddedXibFile" content:xibText]; + NSString* xibText = [NSString sxc_stringWithTestResource:@"ESA.Sales.Foobar.xib"]; + SXCXibDefinition* xibDefinition = [SXCXibDefinition xibDefinitionWithName:@"AnotherAddedXibFile" content:xibText]; [group addXib:xibDefinition toTargets:[project targets]]; [project save]; - } - (void)test_provides_an_option_to_accept_the_existing_file_if_it_exists { - NSString* newXibText = @"Don't blow away my contents if I already exists"; - XCXibDefinition* xibDefinition = [XCXibDefinition xibDefinitionWithName:@"AddedXibFile" content:newXibText]; - [xibDefinition setFileOperationType:XCFileOperationTypeAcceptExisting]; + SXCXibDefinition* xibDefinition = [SXCXibDefinition xibDefinitionWithName:@"AddedXibFile" content:newXibText]; + [xibDefinition setFileOperationType:SXCFileOperationTypeAcceptExisting]; [group addXib:xibDefinition toTargets:[project targets]]; [project save]; - NSString* xibContent = [NSString stringWithTestResource:@"expanz-iOS-SDK/Source/Main/AddedXibFile.xib"]; + NSString* xibContent = [NSString sxc_stringWithTestResource:@"expanz-iOS-SDK/Source/Main/AddedXibFile.xib"]; NSLog(@"Xib content: %@", xibContent); XCTAssertNotEqualObjects(xibContent, newXibText); - } - /* ================================================================================================================== */ #pragma mark - adding frameworks - (void)test_allows_adding_a_framework_on_the_system_volume { - - XCFrameworkDefinition* frameworkDefinition = - [XCFrameworkDefinition frameworkDefinitionWithFilePath:[XCFrameworkPath eventKitUIPath] copyToDestination:NO]; + SXCFrameworkDefinition* frameworkDefinition = + [SXCFrameworkDefinition frameworkDefinitionWithFilePath:[SXCFrameworkPath eventKitUIPath] copyToDestination:NO]; [group addFramework:frameworkDefinition toTargets:[project targets]]; [project save]; - } - (void)test_allows_adding_a_framework_copying_it_to_the_destination_folder { - XCFrameworkDefinition* frameworkDefinition = - [XCFrameworkDefinition frameworkDefinitionWithFilePath:[XCFrameworkPath coreMidiPath] copyToDestination:YES]; + SXCFrameworkDefinition* frameworkDefinition = + [SXCFrameworkDefinition frameworkDefinitionWithFilePath:[SXCFrameworkPath coreMidiPath] copyToDestination:YES]; [group addFramework:frameworkDefinition toTargets:[project targets]]; [project save]; } @@ -285,8 +263,10 @@ - (void)test_allows_adding_a_framework_copying_it_to_the_destination_folder - (void)test_allows_adding_a_xcodeproj_file { - - XCSubProjectDefinition* projectDefinition = [XCSubProjectDefinition withName:@"HelloBoxy" path:@"/tmp/HelloBoxy" parentProject:project]; + SXCSubProjectDefinition* projectDefinition = + [SXCSubProjectDefinition subProjectDefinitionWithName:@"HelloBoxy" + path:@"/tmp/XcodeEditorTests/HelloBoxy" + parentProject:project]; [group addSubProject:projectDefinition]; [project save]; @@ -295,120 +275,104 @@ - (void)test_allows_adding_a_xcodeproj_file - (void)test_provides_a_convenience_method_to_add_a_xcodeproj_file_and_specify_targets { - - XCSubProjectDefinition - * xcodeprojDefinition = [XCSubProjectDefinition withName:@"ArchiveProj" path:@"/tmp/ArchiveProj" parentProject:project]; + SXCSubProjectDefinition* xcodeprojDefinition = + [SXCSubProjectDefinition subProjectDefinitionWithName:@"ArchiveProj" + path:@"/tmp/XcodeEditorTests/ArchiveProj" + parentProject:project]; [group addSubProject:xcodeprojDefinition toTargets:[project targets]]; [project save]; - } - - #pragma mark - removing xcodeproj files - (void)test_allows_removing_an_xcodeproj_file { - -// XCSubProjectDefinition -// * xcodeprojDefinition = [XCSubProjectDefinition withName:@"HelloBoxy" path:@"/tmp/HelloBoxy" parentProject:project]; +// XCSubProjectDefinition* xcodeprojDefinition = +// [XCSubProjectDefinition withName:@"HelloBoxy" path:@"/tmp/XcodeEditorTests/HelloBoxy" parentProject:project]; // // [group removeSubProject:xcodeprojDefinition]; // [project save]; - } - - (void)test_allows_removing_an_xcodeproj_file_and_specify_targets { -// XCSubProjectDefinition -// * xcodeprojDefinition = [XCSubProjectDefinition withName:@"ArchiveProj" path:@"/tmp/ArchiveProj" parentProject:project]; +// XCSubProjectDefinition* xcodeprojDefinition = +// [XCSubProjectDefinition withName:@"ArchiveProj" +// path:@"/tmp/XcodeEditorTests/ArchiveProj" +// parentProject:project]; // // [group addSubProject:xcodeprojDefinition toTargets:[project targets]]; // [project save]; // -// -// xcodeprojDefinition = [XCSubProjectDefinition withName:@"ArchiveProj" path:@"/tmp/ArchiveProj" parentProject:project]; +// xcodeprojDefinition = [XCSubProjectDefinition withName:@"ArchiveProj" +// path:@"/tmp/XcodeEditorTests/ArchiveProj" +// parentProject:project]; // // [group removeSubProject:xcodeprojDefinition fromTargets:[project targets]]; // // [project save]; - } - - /* ================================================================================================================== */ #pragma mark - Adding other types - (void)test_allows_adding_a_group { - [group addGroupWithPath:@"TestGroup"]; [project save]; } - (void)test_should_allows_adding_a_header { - - XCSourceFileDefinition* header = - [[XCSourceFileDefinition alloc] initWithName:@"SomeHeader.h" text:@"@protocol Foobar @end" type:SourceCodeHeader]; + SXCSourceFileDefinition* header = + [SXCSourceFileDefinition sourceDefinitionWithName:@"SomeHeader.h" + text:@"@protocol Foobar @end" + type:SXCXcodeFileTypeSourceCodeHeader]; [group addSourceFile:header]; [project save]; - } - (void)test_allows_adding_an_image_file { - - XCSourceFileDefinition* sourceFileDefinition = [[XCSourceFileDefinition alloc] - initWithName:@"MyImageFile.png" data:[NSData dataWithContentsOfFile:@"/tmp/goat-funny.png"] type:ImageResourcePNG]; + NSData* data = [NSData dataWithContentsOfFile:@"/tmp/XcodeEditorTests/goat-funny.png"]; + SXCSourceFileDefinition* sourceFileDefinition = + [SXCSourceFileDefinition sourceDefinitionWithName:@"MyImageFile.png" + data:data + type:SXCXcodeFileTypeImageResourcePNG]; [group addSourceFile:sourceFileDefinition]; [project save]; - } - /* ================================================================================================================== */ #pragma mark - Listing members - (void)test_able_to_provide_a_sorted_list_of_its_children { - NSArray* children = [group members]; NSLog(@"Group children: %@", children); XCTAssertFalse([children count] == 0); - } - - (void)test_able_to_return_a_member_by_its_name { - XCGroup* anotherGroup = [project groupWithPathFromRoot:@"Source/Main/Core/Model"]; - XCSourceFile* member = [anotherGroup memberWithDisplayName:@"expanz_model_AppSite.m"]; + SXCGroup* anotherGroup = [project groupWithPathFromRoot:@"Source/Main/Core/Model"]; + SXCSourceFile* member = [anotherGroup memberWithDisplayName:@"expanz_model_AppSite.m"]; XCTAssertNotNil(member); - } - (void)test_able_to_list_all_of_its_members_recursively { - NSLog(@"Let's get recursive members!!!!"); NSArray* recursiveMembers = [group recursiveMembers]; NSLog(@"$$$$$$$$$$$$$$$**********$*$*$*$*$*$* recursive members: %@", recursiveMembers); - } - - - /* ================================================================================================================== */ #pragma mark - Deleting - (void)test_allows_deleting_a_group_optionally_removing_also_the_contents { - - XCGroup* aGroup = [project groupWithPathFromRoot:@"Source/Main/UserInterface/Components"]; + SXCGroup* aGroup = [project groupWithPathFromRoot:@"Source/Main/UserInterface/Components"]; NSArray* groups = [project groups]; NSLog(@"Groups now: %@", groups); @@ -419,10 +383,8 @@ - (void)test_allows_deleting_a_group_optionally_removing_also_the_contents groups = [project groups]; NSLog(@"Groups now: %@", groups); - XCGroup* deleted = [project groupWithPathFromRoot:@"Source/Main/UserInterface/Components"]; + SXCGroup* deleted = [project groupWithPathFromRoot:@"Source/Main/UserInterface/Components"]; XCTAssertNil(deleted); - } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/XCKeyBuilderTests.m b/XcodeEditorTests/SXCKeyBuilderTests.m similarity index 75% rename from XcodeEditorTests/XCKeyBuilderTests.m rename to XcodeEditorTests/SXCKeyBuilderTests.m index 4617237..66c8562 100644 --- a/XcodeEditorTests/XCKeyBuilderTests.m +++ b/XcodeEditorTests/SXCKeyBuilderTests.m @@ -9,30 +9,28 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCKeyBuilder.h" #import -#import "XCKeyBuilder.h" -@interface XCKeyBuilderTests : XCTestCase +@interface SXCKeyBuilderTests : XCTestCase @end -@implementation XCKeyBuilderTests +@implementation SXCKeyBuilderTests -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - md5sum hash - (void)test_returns_an_md5_hash_for_an_NSData_instance { - NSString* requiresKey = @"ESA_Sales_Customer_Browse_ViewController.h"; - XCKeyBuilder* builtKey = [XCKeyBuilder forItemNamed:requiresKey]; + SXCKeyBuilder* builtKey = [SXCKeyBuilder forItemNamed:requiresKey]; NSString* key = [builtKey build]; NSLog(@"Key: %@", key); XCTAssertNotNil(key); XCTAssertEqual(key.length, 24); } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/XCProjectTests.m b/XcodeEditorTests/SXCProjectTests.m similarity index 74% rename from XcodeEditorTests/XCProjectTests.m rename to XcodeEditorTests/SXCProjectTests.m index 0227ad4..e3b3a61 100644 --- a/XcodeEditorTests/XCProjectTests.m +++ b/XcodeEditorTests/SXCProjectTests.m @@ -9,51 +9,46 @@ // //////////////////////////////////////////////////////////////////////////////// - - - +#import "SXCProject.h" #import -#import "XCProject.h" -#import "XCSourceFile.h" -#import "XCTarget.h" -#import "XCGroup.h" -@interface XCProjectTests : XCTestCase +#import "SXCGroup.h" +#import "SXCSourceFile.h" +#import "SXCTarget.h" + +@interface SXCProjectTests : XCTestCase @end -@implementation XCProjectTests +@implementation SXCProjectTests { - __block XCProject* project; + __block SXCProject* project; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ - (void)setUp { - project = [[XCProject alloc] initWithFilePath:@"/tmp"]; + project = [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests"]; } -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Listing files - (void)test_able_to_list_all_the_header_files_in_a_project { - NSArray* headerFiles = [project headerFiles]; NSLog(@"Headers: %@", headerFiles); XCTAssertTrue([headerFiles count] == 18); - for (XCSourceFile* file in headerFiles) + for (SXCSourceFile* file in headerFiles) { NSLog(@"File: %@", [file description]); } - } - (void)test_able_to_list_all_the_obj_c_files_in_a_project { - NSArray* objcFiles = [project objectiveCFiles]; NSLog(@"Implementation Files: %@", objcFiles); @@ -71,24 +66,22 @@ - (void)test_able_to_list_all_the_obj_cPlusPlus_files_in_a_project - (void)test_be_able_to_list_all_the_xib_files_in_a_project { - NSArray* xibFiles = [project xibFiles]; NSLog(@"Xib Files: %@", xibFiles); XCTAssertTrue([xibFiles count] == 2); } - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Groups - (void)test_able_to_list_all_of_the_groups_in_a_project { NSArray* groups = [project groups]; - for (XCGroup* group in groups) + for (SXCGroup* group in groups) { NSLog(@"Name: %@, full path: %@", [group displayName], [group pathRelativeToProjectRoot]); - for (id member in [group members]) + for (id member in [group members]) { NSLog(@"\t%@", [member displayName]); } @@ -100,47 +93,36 @@ - (void)test_able_to_list_all_of_the_groups_in_a_project - (void)test_provides_access_to_the_root_top_level_group { - - XCGroup* rootGroup = [project rootGroup]; + SXCGroup* rootGroup = [project rootGroup]; NSLog(@"Here the group: %@", rootGroup); XCTAssertFalse([rootGroup.members count] == 0); - - } - (void)test_provides_a_way_to_locate_a_group_from_its_path_to_the_root_group { - - XCGroup* group = [project groupWithPathFromRoot:@"Source/Main/Assembly"]; + SXCGroup* group = [project groupWithPathFromRoot:@"Source/Main/Assembly"]; XCTAssertNotNil(group); NSLog(@"Group: %@", group); - } - - - -/* ====================================================================================================================================== */ +/* ================================================================================================================== */ #pragma mark - Targets - (void)test_able_to_list_the_targets_in_an_xcode_project { - NSArray* targets = [project targets]; - for (XCTarget* target in [project targets]) + for (SXCTarget* target in [project targets]) { NSLog(@"%@", target); } XCTAssertNotNil(targets); XCTAssertFalse([targets count] == 0); - for (XCTarget* target in targets) + for (SXCTarget* target in targets) { NSArray* members = [target members]; NSLog(@"Members: %@", members); } - } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/SXCSourceFileTypeTests.m b/XcodeEditorTests/SXCSourceFileTypeTests.m new file mode 100644 index 0000000..019b59f --- /dev/null +++ b/XcodeEditorTests/SXCSourceFileTypeTests.m @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// JASPER BLUES +// Copyright 2012 Jasper Blues +// All Rights Reserved. +// +// NOTICE: Jasper Blues permits you to use, modify, and distribute this file +// in accordance with the terms of the license agreement accompanying it. +// +//////////////////////////////////////////////////////////////////////////////// + +#import "SXCXcodeFileType.h" + +#import + +@interface SXCXcodeFileTypeTests : XCTestCase +@end + +@implementation SXCXcodeFileTypeTests + +- (void)test_return_a_file_reference_type_from_a_string +{ + XCTAssertTrue(SXCXcodeFileTypeFromStringRepresentation(@"sourcecode.c.h") == SXCXcodeFileTypeSourceCodeHeader); + XCTAssertTrue(SXCXcodeFileTypeFromStringRepresentation(@"sourcecode.c.objc") == SXCXcodeFileTypeSourceCodeObjC); +} + +- (void)test_creates_a_string_from_a_file_reference_type +{ + XCTAssertEqualObjects(SXCNSStringFromSXCXcodeFileType(SXCXcodeFileTypeSourceCodeHeader), @"sourcecode.c.h"); + XCTAssertEqualObjects(SXCNSStringFromSXCXcodeFileType(SXCXcodeFileTypeSourceCodeObjC), @"sourcecode.c.objc"); +} + +- (void)test_returns_file_type_from_file_name +{ + XCTAssertEqual(SXCXcodeFileTypeFromFileName(@"foobar.c"), SXCXcodeFileTypeSourceCodeObjC); + XCTAssertEqual(SXCXcodeFileTypeFromFileName(@"foobar.m"), SXCXcodeFileTypeSourceCodeObjC); + XCTAssertEqual(SXCXcodeFileTypeFromFileName(@"foobar.mm"), SXCXcodeFileTypeSourceCodeObjCPlusPlus); + XCTAssertEqual(SXCXcodeFileTypeFromFileName(@"foobar.cpp"), SXCXcodeFileTypeSourceCodeCPlusPlus); +} + +@end \ No newline at end of file diff --git a/XcodeEditorTests/XCSubProjectDefinitionTests.m b/XcodeEditorTests/SXCSubProjectDefinitionTests.m similarity index 51% rename from XcodeEditorTests/XCSubProjectDefinitionTests.m rename to XcodeEditorTests/SXCSubProjectDefinitionTests.m index 71491f4..c5651f4 100644 --- a/XcodeEditorTests/XCSubProjectDefinitionTests.m +++ b/XcodeEditorTests/SXCSubProjectDefinitionTests.m @@ -9,38 +9,36 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCSubProjectDefinition.h" #import -#import "XCProject.h" -#import "XCSubProjectDefinition.h" -@interface XCSubProjectDefinitionTests : XCTestCase +#import "SXCProject.h" + +@interface SXCSubProjectDefinitionTests : XCTestCase @end -@implementation XCSubProjectDefinitionTests +@implementation SXCSubProjectDefinitionTests { - XCProject* _project; + SXCProject* _project; } - - (void)setUp { - _project = [[XCProject alloc] initWithFilePath:@"/tmp/expanz-iOS-SDK/expanz-iOS-SDK.xcodeproj"]; + _project = [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/expanz-iOS-SDK/expanz-iOS-SDK.xcodeproj"]; } #pragma mark - object creation - (void)test_allows_initialization_with_name_and_path { - - XCSubProjectDefinition - * subProjectDefinition = [[XCSubProjectDefinition alloc] initWithName:@"HelloBoxy" path:@"/tmp/HelloBoxy" parentProject:_project]; + SXCSubProjectDefinition + * subProjectDefinition = [SXCSubProjectDefinition subProjectDefinitionWithName:@"HelloBoxy" + path:@"/tmp/XcodeEditorTests/HelloBoxy" + parentProject:_project]; XCTAssertNotNil(subProjectDefinition); XCTAssertEqualObjects(subProjectDefinition.projectFileName, @"HelloBoxy.xcodeproj"); - - } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/XCTargetTests.m b/XcodeEditorTests/SXCTargetTests.m similarity index 67% rename from XcodeEditorTests/XCTargetTests.m rename to XcodeEditorTests/SXCTargetTests.m index c34d69f..c186d6f 100644 --- a/XcodeEditorTests/XCTargetTests.m +++ b/XcodeEditorTests/SXCTargetTests.m @@ -9,55 +9,51 @@ // //////////////////////////////////////////////////////////////////////////////// +#import "SXCTarget.h" #import -#import "XCProject.h" -#import "XCTarget.h" -#import "XCProjectBuildConfig.h" -@interface XCTargetTests : XCTestCase +#import "SXCProject.h" +#import "SXCProjectBuildConfig.h" + +@interface SXCTargetTests : XCTestCase @end -@implementation XCTargetTests +@implementation SXCTargetTests { - XCProject* _project; + SXCProject* _project; } - - (void)setUp { - _project = [[XCProject alloc] initWithFilePath:@"/tmp/expanz-iOS-SDK/expanz-iOS-SDK.xcodeproj"]; + _project = [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/expanz-iOS-SDK/expanz-iOS-SDK.xcodeproj"]; NSLog(@"Targets: %@", [_project targets]); } - (void)test_allows_setting_name_and_product_name_target_properties { - XCTarget* target = [_project targetWithName:@"expanzCore"]; + SXCTarget* target = [_project targetWithName:@"expanzCore"]; [target setName:@"foobar"]; [target setProductName:@"foobar"]; [_project save]; } - //------------------------------------------------------------------------------------------- #pragma mark - Build configuration. . . - - (void)test_allows_setting_build_configurations { - XCProject* project = [[XCProject alloc] initWithFilePath:@"/tmp/HelloBoxy/HelloBoxy.xcodeproj"]; - XCTarget* target = [project targetWithName:@"HelloBoxy"]; + SXCProject* project = [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/HelloBoxy/HelloBoxy.xcodeproj"]; + SXCTarget* target = [project targetWithName:@"HelloBoxy"]; - XCProjectBuildConfig * configuration = [target configurationWithName:@"Debug"]; + SXCProjectBuildConfig * configuration = [target configurationWithName:@"Debug"]; NSLog(@"Here's the configuration: %@", configuration); id ldFlags = [configuration valueForKey:@"OTHER_LDFLAGS"]; NSLog(@"ldflags: %@, %@", ldFlags, [ldFlags class]); [configuration addOrReplaceSetting:@"-lz -lxml2" forKey:@"OTHER_LDFLAGS"]; [configuration addOrReplaceSetting:@[@"foo", @"bar"] forKey:@"HEADER_SEARCH_PATHS"]; - - configuration = [target configurationWithName:@"Release"]; NSLog(@"Here's the configuration: %@", configuration); ldFlags = [configuration valueForKey:@"OTHER_LDFLAGS"]; @@ -66,7 +62,6 @@ - (void)test_allows_setting_build_configurations [configuration addOrReplaceSetting:@[@"foo", @"bar"] forKey:@"HEADER_SEARCH_PATHS"]; [project save]; - } //------------------------------------------------------------------------------------------- @@ -74,12 +69,11 @@ - (void)test_allows_setting_build_configurations - (void)test_allows_duplicating_a_target { - XCProject* project = [[XCProject alloc] initWithFilePath:@"/tmp/HelloBoxy/HelloBoxy.xcodeproj"]; - XCTarget* target = [project targetWithName:@"HelloBoxy"]; + SXCProject* project = [SXCProject projectWithFilePath:@"/tmp/XcodeEditorTests/HelloBoxy/HelloBoxy.xcodeproj"]; + SXCTarget* target = [project targetWithName:@"HelloBoxy"]; - XCTarget* duplicated = [target duplicateWithTargetName:@"DuplicatedTarget" productName:@"NewProduct"]; + [target duplicateWithTargetName:@"DuplicatedTarget" productName:@"NewProduct"]; [project save]; } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/Tests-Prefix.pch b/XcodeEditorTests/Tests-Prefix.pch index 463b6f2..6830df1 100644 --- a/XcodeEditorTests/Tests-Prefix.pch +++ b/XcodeEditorTests/Tests-Prefix.pch @@ -10,6 +10,6 @@ #import -#import "NSString+TestResource.h" +#import "NSString+SXCTestResource.h" #endif diff --git a/XcodeEditorTests/Utils/NSString+TestResource.h b/XcodeEditorTests/Utils/NSString+SXCTestResource.h similarity index 80% rename from XcodeEditorTests/Utils/NSString+TestResource.h rename to XcodeEditorTests/Utils/NSString+SXCTestResource.h index a490c25..105d5e8 100644 --- a/XcodeEditorTests/Utils/NSString+TestResource.h +++ b/XcodeEditorTests/Utils/NSString+SXCTestResource.h @@ -9,11 +9,10 @@ // //////////////////////////////////////////////////////////////////////////////// - #import -@interface NSString (TestResource) +@interface NSString (SXCTestResource) -+ (NSString*)stringWithTestResource:(NSString*)resourceName; ++ (NSString*)sxc_stringWithTestResource:(NSString*)resourceName; -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/Utils/NSString+TestResource.m b/XcodeEditorTests/Utils/NSString+SXCTestResource.m similarity index 74% rename from XcodeEditorTests/Utils/NSString+TestResource.m rename to XcodeEditorTests/Utils/NSString+SXCTestResource.m index 2500726..767605c 100644 --- a/XcodeEditorTests/Utils/NSString+TestResource.m +++ b/XcodeEditorTests/Utils/NSString+SXCTestResource.m @@ -9,13 +9,13 @@ // //////////////////////////////////////////////////////////////////////////////// -#import "NSString+TestResource.h" +#import "NSString+SXCTestResource.h" -@implementation NSString (TestResource) +@implementation NSString (SXCTestResource) -+ (NSString*)stringWithTestResource:(NSString*)resourceName ++ (NSString*)sxc_stringWithTestResource:(NSString*)resourceName { - NSString* filePath = [@"/tmp" stringByAppendingPathComponent:resourceName]; + NSString* filePath = [@"/tmp/XcodeEditorTests" stringByAppendingPathComponent:resourceName]; NSError* error = nil; NSString* contents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error]; if (!contents) @@ -25,5 +25,4 @@ + (NSString*)stringWithTestResource:(NSString*)resourceName return contents; } - -@end \ No newline at end of file +@end diff --git a/XcodeEditorTests/XcodeFileReferenceTypeTests.m b/XcodeEditorTests/XcodeFileReferenceTypeTests.m deleted file mode 100644 index 5a6cf9e..0000000 --- a/XcodeEditorTests/XcodeFileReferenceTypeTests.m +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// JASPER BLUES -// Copyright 2012 Jasper Blues -// All Rights Reserved. -// -// NOTICE: Jasper Blues permits you to use, modify, and distribute this file -// in accordance with the terms of the license agreement accompanying it. -// -//////////////////////////////////////////////////////////////////////////////// - -#import "XcodeSourceFileType.h" -#import - -@interface XcodeFileReferenceTypeTests : XCTestCase -@end - -@implementation XcodeFileReferenceTypeTests - -- (void)test_return_a_file_reference_type_from_a_string -{ - - XCTAssertTrue(XCSourceFileTypeFromStringRepresentation(@"sourcecode.c.h") == SourceCodeHeader); - XCTAssertTrue(XCSourceFileTypeFromStringRepresentation(@"sourcecode.c.objc") == SourceCodeObjC); -} - -- (void)test_creates_a_string_from_a_file_reference_type -{ - XCTAssertEqualObjects(NSStringFromXCSourceFileType(SourceCodeHeader), @"sourcecode.c.h"); - XCTAssertEqualObjects(NSStringFromXCSourceFileType(SourceCodeObjC), @"sourcecode.c.objc"); -} - -- (void)test_returns_file_type_from_file_name -{ - XCTAssertEqual(XCSourceFileTypeFromFileName(@"foobar.c"), SourceCodeObjC); - XCTAssertEqual(XCSourceFileTypeFromFileName(@"foobar.m"), SourceCodeObjC); - XCTAssertEqual(XCSourceFileTypeFromFileName(@"foobar.mm"), SourceCodeObjCPlusPlus); - XCTAssertEqual(XCSourceFileTypeFromFileName(@"foobar.cpp"), SourceCodeCPlusPlus); -} - -@end \ No newline at end of file diff --git a/xcode-editor.xcodeproj/project.pbxproj b/xcode-editor.xcodeproj/project.pbxproj index 7e84822..0072072 100644 --- a/xcode-editor.xcodeproj/project.pbxproj +++ b/xcode-editor.xcodeproj/project.pbxproj @@ -19,48 +19,48 @@ 6BCED6F51A4A62760005596F /* ESA_Sales_Foobar_ViewController.header in Resources */ = {isa = PBXBuildFile; fileRef = BA798E7947765A032AB118BA /* ESA_Sales_Foobar_ViewController.header */; }; 6BCED6F61A4A62760005596F /* ESA_Sales_Foobar_ViewController.impl in Resources */ = {isa = PBXBuildFile; fileRef = BA798EC5D7AFB1BC79B1934E /* ESA_Sales_Foobar_ViewController.impl */; }; 6BCED6F71A4A62760005596F /* project.pbxproj in Resources */ = {isa = PBXBuildFile; fileRef = BA79897F0241177A8F8C932B /* project.pbxproj */; }; - 6BCED6FC1A4A628D0005596F /* XCGroupTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989499B6F59EEC2E1AA41 /* XCGroupTests.m */; }; - 6BCED6FD1A4A62910005596F /* XCTargetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798974A01772350D7C81BD /* XCTargetTests.m */; }; - 6BCED6FE1A4A62950005596F /* XcodeFileReferenceTypeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798D6F34B9A560E3D689B3 /* XcodeFileReferenceTypeTests.m */; }; - 6BCED6FF1A4A62970005596F /* XCSubProjectDefinitionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7983A401A60AA073A26789 /* XCSubProjectDefinitionTests.m */; }; - 6BCED7001A4A629D0005596F /* XCProjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798CFD524E5A3CF155C816 /* XCProjectTests.m */; }; - 6BCED7011A4A62A00005596F /* XCClassDefinitionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7984685319A7BB1B37DBE9 /* XCClassDefinitionTests.m */; }; - 6BCED7031A4A62B00005596F /* XCKeyBuilderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798BD3F30B4E39066F8108 /* XCKeyBuilderTests.m */; }; + 6BCED6FC1A4A628D0005596F /* SXCGroupTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989499B6F59EEC2E1AA41 /* SXCGroupTests.m */; }; + 6BCED6FD1A4A62910005596F /* SXCTargetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798974A01772350D7C81BD /* SXCTargetTests.m */; }; + 6BCED6FE1A4A62950005596F /* SXCSourceFileTypeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798D6F34B9A560E3D689B3 /* SXCSourceFileTypeTests.m */; }; + 6BCED6FF1A4A62970005596F /* SXCSubProjectDefinitionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7983A401A60AA073A26789 /* SXCSubProjectDefinitionTests.m */; }; + 6BCED7001A4A629D0005596F /* SXCProjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798CFD524E5A3CF155C816 /* SXCProjectTests.m */; }; + 6BCED7011A4A62A00005596F /* SXCClassDefinitionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7984685319A7BB1B37DBE9 /* SXCClassDefinitionTests.m */; }; + 6BCED7031A4A62B00005596F /* SXCKeyBuilderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798BD3F30B4E39066F8108 /* SXCKeyBuilderTests.m */; }; BA79809B196A253223139967 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BA798378F006ADD44A37C678 /* InfoPlist.strings */; }; - BA7980D47618535CEEE56C07 /* XcodeSourceFileType.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798CF27DA49D73EBE0FCB7 /* XcodeSourceFileType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA7981663E00E804C25FDA0D /* XCProject.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989AC9710D456572783C7 /* XCProject.m */; }; - BA7981A76C28C0D8FE7392E0 /* XCClassDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798A9F12459363332BFD04 /* XCClassDefinition.m */; }; - BA7981FC099C3D8C4BA8E511 /* XCSubProjectDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7987AE440FBAAC032785B1 /* XCSubProjectDefinition.m */; }; - BA7981FF93FAFD6320C739ED /* XCSourceFile.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798A848F553CE428B7CC74 /* XCSourceFile.m */; }; - BA79825A7D7CB5AD4EE31A6C /* XCGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7983FEC190BC062691EA39 /* XCGroup.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA7983A0DEE6E0B98286444A /* XCClassDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7983A0D40F7D264D8E6DF3 /* XCClassDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA79845D705566388D6A74F5 /* XCGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989F085BDB69CB462D203 /* XCGroup.m */; }; - BA79845EF211493263B4D0FC /* XCTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7982BE32BDDBBC9DA2FDC8 /* XCTarget.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA7984763E39F64955CFE6F5 /* XcodeMemberType.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798C11E473C251F07B0DAA /* XcodeMemberType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA7984F6EE4FA90717414543 /* XCProject+SubProject.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798C57D9B8610BFECB9528 /* XCProject+SubProject.m */; }; - BA79857B12A10B9BFBF3C929 /* XCAbstractDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798287F70884A45C9F3721 /* XCAbstractDefinition.m */; }; - BA7985C5136218B0D782F7F1 /* XCProject+SubProject.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7986459784ADE55A4B7CAC /* XCProject+SubProject.h */; }; - BA7985C665CCF83437B2231E /* XCProjectBuildConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798DCCBF81FADC37488A36 /* XCProjectBuildConfig.h */; }; - BA79861FCDBD84679CA89D9E /* XCKeyBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798DB7EBF603A22E7334BF /* XCKeyBuilder.m */; }; - BA79862308DF0F7F984AF86E /* XCProjectBuildConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79868C3DE682529FB4B76E /* XCProjectBuildConfig.m */; }; - BA798641126C8C9498C21843 /* XCSourceFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798B392E07F43F5E0E77FC /* XCSourceFile.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA79866BA1ACA2933B98F48C /* XCFrameworkDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79885862A8419969A4CC7A /* XCFrameworkDefinition.m */; }; - BA7986719FB605B7F7698E81 /* XcodeMemberType.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798C3E8F2CD550594E7231 /* XcodeMemberType.m */; }; - BA79868C0786BB13E5C324ED /* XCProject.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7988B8FA1C50DE6B1B54D2 /* XCProject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA79876598EF30F3EE513484 /* XCFileOperationQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798E32B62ACEF1B995F0D3 /* XCFileOperationQueue.m */; }; - BA7987C8FAAD4E3225D7DDC3 /* XCFileOperationQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798FDE9BAA7D87499853ED /* XCFileOperationQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA79881A93B24339436DF2FC /* XCXibDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7982A4051493BD524C3BBD /* XCXibDefinition.m */; }; - BA7988ABB09415FEE5070B38 /* XCXibDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798D221F1008AE859B76B8 /* XCXibDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA7988C3E49E2C17AACB9CDC /* XcodeSourceFileType.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7982A01773D8163E643FAA /* XcodeSourceFileType.m */; }; - BA7989692AF001BA1BBEACCF /* XCSourceFileDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798473A7694F9383712D07 /* XCSourceFileDefinition.m */; }; - BA798A3F4DCBD5DD024B1147 /* XcodeGroupMember.h in Headers */ = {isa = PBXBuildFile; fileRef = BA79840E5B88656BAAE1D8B5 /* XcodeGroupMember.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA798AD506D19B5D3FB6DE4E /* XCAbstractDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA79837129D1D730443959A2 /* XCAbstractDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA798AECC575AEE83D96D580 /* NSString+TestResource.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798233F677AB6DE9FB37FC /* NSString+TestResource.m */; }; - BA798BD3214388015EAFDDFB /* XCTarget.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798ABFC33DC1AE014D76D6 /* XCTarget.m */; }; - BA798BE4876F847D0F1BA266 /* XCSourceFileDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798C2F90A12BFEE77EFA5D /* XCSourceFileDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA798DC320D5F6F188C112B3 /* XCKeyBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798909AC4D1FCE033E64C5 /* XCKeyBuilder.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA798EFC5F24AC9FD857373C /* XCFrameworkDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7986BC9EE998925B797690 /* XCFrameworkDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BA798F131E3B0412BEE23CA3 /* XcodeEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = BA79888A08A5739C728633D2 /* XcodeEditor.h */; }; + BA7980D47618535CEEE56C07 /* SXCXcodeFileType.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798CF27DA49D73EBE0FCB7 /* SXCXcodeFileType.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA7981663E00E804C25FDA0D /* SXCProject.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989AC9710D456572783C7 /* SXCProject.m */; }; + BA7981A76C28C0D8FE7392E0 /* SXCClassDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798A9F12459363332BFD04 /* SXCClassDefinition.m */; }; + BA7981FC099C3D8C4BA8E511 /* SXCSubProjectDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7987AE440FBAAC032785B1 /* SXCSubProjectDefinition.m */; }; + BA7981FF93FAFD6320C739ED /* SXCSourceFile.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798A848F553CE428B7CC74 /* SXCSourceFile.m */; }; + BA79825A7D7CB5AD4EE31A6C /* SXCGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7983FEC190BC062691EA39 /* SXCGroup.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA7983A0DEE6E0B98286444A /* SXCClassDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7983A0D40F7D264D8E6DF3 /* SXCClassDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA79845D705566388D6A74F5 /* SXCGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989F085BDB69CB462D203 /* SXCGroup.m */; }; + BA79845EF211493263B4D0FC /* SXCTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7982BE32BDDBBC9DA2FDC8 /* SXCTarget.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA7984763E39F64955CFE6F5 /* SXCXcodeMemberType.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798C11E473C251F07B0DAA /* SXCXcodeMemberType.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA7984F6EE4FA90717414543 /* SXCProject+SubProject.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798C57D9B8610BFECB9528 /* SXCProject+SubProject.m */; }; + BA79857B12A10B9BFBF3C929 /* SXCAbstractDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798287F70884A45C9F3721 /* SXCAbstractDefinition.m */; }; + BA7985C5136218B0D782F7F1 /* SXCProject+SubProject.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7986459784ADE55A4B7CAC /* SXCProject+SubProject.h */; }; + BA7985C665CCF83437B2231E /* SXCProjectBuildConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798DCCBF81FADC37488A36 /* SXCProjectBuildConfig.h */; }; + BA79861FCDBD84679CA89D9E /* SXCKeyBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798DB7EBF603A22E7334BF /* SXCKeyBuilder.m */; }; + BA79862308DF0F7F984AF86E /* SXCProjectBuildConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79868C3DE682529FB4B76E /* SXCProjectBuildConfig.m */; }; + BA798641126C8C9498C21843 /* SXCSourceFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798B392E07F43F5E0E77FC /* SXCSourceFile.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA79866BA1ACA2933B98F48C /* SXCFrameworkDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79885862A8419969A4CC7A /* SXCFrameworkDefinition.m */; }; + BA7986719FB605B7F7698E81 /* SXCXcodeMemberType.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798C3E8F2CD550594E7231 /* SXCXcodeMemberType.m */; }; + BA79868C0786BB13E5C324ED /* SXCProject.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7988B8FA1C50DE6B1B54D2 /* SXCProject.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA79876598EF30F3EE513484 /* SXCFileOperationQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798E32B62ACEF1B995F0D3 /* SXCFileOperationQueue.m */; }; + BA7987C8FAAD4E3225D7DDC3 /* SXCFileOperationQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798FDE9BAA7D87499853ED /* SXCFileOperationQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA79881A93B24339436DF2FC /* SXCXibDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7982A4051493BD524C3BBD /* SXCXibDefinition.m */; }; + BA7988ABB09415FEE5070B38 /* SXCXibDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798D221F1008AE859B76B8 /* SXCXibDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA7988C3E49E2C17AACB9CDC /* SXCXcodeFileType.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7982A01773D8163E643FAA /* SXCXcodeFileType.m */; }; + BA7989692AF001BA1BBEACCF /* SXCSourceFileDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798473A7694F9383712D07 /* SXCSourceFileDefinition.m */; }; + BA798A3F4DCBD5DD024B1147 /* SXCXcodeGroupMember.h in Headers */ = {isa = PBXBuildFile; fileRef = BA79840E5B88656BAAE1D8B5 /* SXCXcodeGroupMember.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA798AD506D19B5D3FB6DE4E /* SXCAbstractDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA79837129D1D730443959A2 /* SXCAbstractDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA798AECC575AEE83D96D580 /* NSString+SXCTestResource.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798233F677AB6DE9FB37FC /* NSString+SXCTestResource.m */; }; + BA798BD3214388015EAFDDFB /* SXCTarget.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798ABFC33DC1AE014D76D6 /* SXCTarget.m */; }; + BA798BE4876F847D0F1BA266 /* SXCSourceFileDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798C2F90A12BFEE77EFA5D /* SXCSourceFileDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA798DC320D5F6F188C112B3 /* SXCKeyBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = BA798909AC4D1FCE033E64C5 /* SXCKeyBuilder.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA798EFC5F24AC9FD857373C /* SXCFrameworkDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BA7986BC9EE998925B797690 /* SXCFrameworkDefinition.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BA798F131E3B0412BEE23CA3 /* SXCXcodeEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = BA79888A08A5739C728633D2 /* SXCXcodeEditor.h */; }; BA798F6617C56888653CE018 /* XcodeEditor-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = BA798CECA2420D48B499842E /* XcodeEditor-Prefix.pch */; }; /* End PBXBuildFile section */ @@ -92,65 +92,65 @@ 6BCED6E21A4A61DC0005596F /* XcodeEditorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XcodeEditorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 6BCED6E51A4A61DC0005596F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6BD8982D14EA2441007875F4 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; - BA798233F677AB6DE9FB37FC /* NSString+TestResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+TestResource.m"; sourceTree = ""; }; + BA798233F677AB6DE9FB37FC /* NSString+SXCTestResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SXCTestResource.m"; sourceTree = ""; }; BA798257DC8C1D51244A87F2 /* expanz-iOS-SDK.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "expanz-iOS-SDK.zip"; sourceTree = ""; }; - BA798287F70884A45C9F3721 /* XCAbstractDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCAbstractDefinition.m; sourceTree = ""; }; - BA7982A01773D8163E643FAA /* XcodeSourceFileType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XcodeSourceFileType.m; sourceTree = ""; }; - BA7982A4051493BD524C3BBD /* XCXibDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCXibDefinition.m; sourceTree = ""; }; - BA7982BE32BDDBBC9DA2FDC8 /* XCTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCTarget.h; sourceTree = ""; }; + BA798287F70884A45C9F3721 /* SXCAbstractDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCAbstractDefinition.m; sourceTree = ""; }; + BA7982A01773D8163E643FAA /* SXCXcodeFileType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCXcodeFileType.m; sourceTree = ""; }; + BA7982A4051493BD524C3BBD /* SXCXibDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCXibDefinition.m; sourceTree = ""; }; + BA7982BE32BDDBBC9DA2FDC8 /* SXCTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCTarget.h; sourceTree = ""; }; BA7982C1A359AA930F934231 /* HelloWorldLayer.impl */ = {isa = PBXFileReference; lastKnownFileType = file.impl; path = HelloWorldLayer.impl; sourceTree = ""; }; - BA79837129D1D730443959A2 /* XCAbstractDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCAbstractDefinition.h; sourceTree = ""; }; - BA7983A0D40F7D264D8E6DF3 /* XCClassDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCClassDefinition.h; sourceTree = ""; }; - BA7983A401A60AA073A26789 /* XCSubProjectDefinitionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCSubProjectDefinitionTests.m; sourceTree = ""; }; + BA79837129D1D730443959A2 /* SXCAbstractDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCAbstractDefinition.h; sourceTree = ""; }; + BA7983A0D40F7D264D8E6DF3 /* SXCClassDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCClassDefinition.h; sourceTree = ""; }; + BA7983A401A60AA073A26789 /* SXCSubProjectDefinitionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCSubProjectDefinitionTests.m; sourceTree = ""; }; BA7983F13EF969BF5E4135BB /* XcodeEditor-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.info; path = "XcodeEditor-Info.plist"; sourceTree = ""; }; - BA7983FEC190BC062691EA39 /* XCGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCGroup.h; sourceTree = ""; }; - BA79840E5B88656BAAE1D8B5 /* XcodeGroupMember.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XcodeGroupMember.h; sourceTree = ""; }; - BA7984685319A7BB1B37DBE9 /* XCClassDefinitionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCClassDefinitionTests.m; sourceTree = ""; }; - BA798473A7694F9383712D07 /* XCSourceFileDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCSourceFileDefinition.m; sourceTree = ""; }; + BA7983FEC190BC062691EA39 /* SXCGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCGroup.h; sourceTree = ""; }; + BA79840E5B88656BAAE1D8B5 /* SXCXcodeGroupMember.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCXcodeGroupMember.h; sourceTree = ""; }; + BA7984685319A7BB1B37DBE9 /* SXCClassDefinitionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCClassDefinitionTests.m; sourceTree = ""; }; + BA798473A7694F9383712D07 /* SXCSourceFileDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCSourceFileDefinition.m; sourceTree = ""; }; BA79848C44BAD3669D8B787E /* Person.impl */ = {isa = PBXFileReference; lastKnownFileType = file.impl; path = Person.impl; sourceTree = ""; }; - BA798516EBADF7760937A8D6 /* XCSubProjectDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCSubProjectDefinition.h; sourceTree = ""; }; + BA798516EBADF7760937A8D6 /* SXCSubProjectDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCSubProjectDefinition.h; sourceTree = ""; }; BA79858C0B5035B3EB71E67C /* Tests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.info; path = "Tests-Info.plist"; sourceTree = ""; }; BA7985E1B4262B71CC38472A /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = Source/Tests/en.lproj/InfoPlist.strings; sourceTree = SOURCE_ROOT; }; - BA7986459784ADE55A4B7CAC /* XCProject+SubProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCProject+SubProject.h"; sourceTree = ""; }; - BA79868C3DE682529FB4B76E /* XCProjectBuildConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCProjectBuildConfig.m; sourceTree = ""; }; - BA7986BC9EE998925B797690 /* XCFrameworkDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCFrameworkDefinition.h; sourceTree = ""; }; - BA7987AE440FBAAC032785B1 /* XCSubProjectDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCSubProjectDefinition.m; sourceTree = ""; }; - BA79885862A8419969A4CC7A /* XCFrameworkDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCFrameworkDefinition.m; sourceTree = ""; }; - BA79888A08A5739C728633D2 /* XcodeEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XcodeEditor.h; sourceTree = ""; }; - BA7988B8FA1C50DE6B1B54D2 /* XCProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCProject.h; sourceTree = ""; }; + BA7986459784ADE55A4B7CAC /* SXCProject+SubProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SXCProject+SubProject.h"; sourceTree = ""; }; + BA79868C3DE682529FB4B76E /* SXCProjectBuildConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCProjectBuildConfig.m; sourceTree = ""; }; + BA7986BC9EE998925B797690 /* SXCFrameworkDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCFrameworkDefinition.h; sourceTree = ""; }; + BA7987AE440FBAAC032785B1 /* SXCSubProjectDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCSubProjectDefinition.m; sourceTree = ""; }; + BA79885862A8419969A4CC7A /* SXCFrameworkDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCFrameworkDefinition.m; sourceTree = ""; }; + BA79888A08A5739C728633D2 /* SXCXcodeEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCXcodeEditor.h; sourceTree = ""; }; + BA7988B8FA1C50DE6B1B54D2 /* SXCProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCProject.h; sourceTree = ""; }; BA798903FC8864C4CB08B7FF /* ESA.Sales.Foobar.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ESA.Sales.Foobar.xib; sourceTree = ""; }; - BA798909AC4D1FCE033E64C5 /* XCKeyBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCKeyBuilder.h; sourceTree = ""; }; + BA798909AC4D1FCE033E64C5 /* SXCKeyBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCKeyBuilder.h; sourceTree = ""; }; BA798924D39B66695026C637 /* goat-funny.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "goat-funny.png"; sourceTree = ""; }; BA798943BA7D1C740F0A098F /* HelloBoxy.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = HelloBoxy.zip; sourceTree = ""; }; - BA7989499B6F59EEC2E1AA41 /* XCGroupTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCGroupTests.m; sourceTree = ""; }; + BA7989499B6F59EEC2E1AA41 /* SXCGroupTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCGroupTests.m; sourceTree = ""; }; BA7989665353B4921A5D4671 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - BA798974A01772350D7C81BD /* XCTargetTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCTargetTests.m; sourceTree = ""; }; + BA798974A01772350D7C81BD /* SXCTargetTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCTargetTests.m; sourceTree = ""; }; BA79897F0241177A8F8C932B /* project.pbxproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.pbxproject; path = project.pbxproj; sourceTree = ""; }; - BA7989AC9710D456572783C7 /* XCProject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCProject.m; sourceTree = ""; }; - BA7989F085BDB69CB462D203 /* XCGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCGroup.m; sourceTree = ""; }; - BA798A848F553CE428B7CC74 /* XCSourceFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCSourceFile.m; sourceTree = ""; }; - BA798A9F12459363332BFD04 /* XCClassDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCClassDefinition.m; sourceTree = ""; }; - BA798ABFC33DC1AE014D76D6 /* XCTarget.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCTarget.m; sourceTree = ""; }; - BA798B07E98D7BCE4145F363 /* NSString+TestResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+TestResource.h"; sourceTree = ""; }; - BA798B392E07F43F5E0E77FC /* XCSourceFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCSourceFile.h; sourceTree = ""; }; - BA798BD3F30B4E39066F8108 /* XCKeyBuilderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCKeyBuilderTests.m; sourceTree = ""; }; - BA798C11E473C251F07B0DAA /* XcodeMemberType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XcodeMemberType.h; sourceTree = ""; }; - BA798C2F90A12BFEE77EFA5D /* XCSourceFileDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCSourceFileDefinition.h; sourceTree = ""; }; - BA798C3E8F2CD550594E7231 /* XcodeMemberType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XcodeMemberType.m; sourceTree = ""; }; - BA798C57D9B8610BFECB9528 /* XCProject+SubProject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCProject+SubProject.m"; sourceTree = ""; }; + BA7989AC9710D456572783C7 /* SXCProject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCProject.m; sourceTree = ""; }; + BA7989F085BDB69CB462D203 /* SXCGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCGroup.m; sourceTree = ""; }; + BA798A848F553CE428B7CC74 /* SXCSourceFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCSourceFile.m; sourceTree = ""; }; + BA798A9F12459363332BFD04 /* SXCClassDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCClassDefinition.m; sourceTree = ""; }; + BA798ABFC33DC1AE014D76D6 /* SXCTarget.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCTarget.m; sourceTree = ""; }; + BA798B07E98D7BCE4145F363 /* NSString+SXCTestResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SXCTestResource.h"; sourceTree = ""; }; + BA798B392E07F43F5E0E77FC /* SXCSourceFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCSourceFile.h; sourceTree = ""; }; + BA798BD3F30B4E39066F8108 /* SXCKeyBuilderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCKeyBuilderTests.m; sourceTree = ""; }; + BA798C11E473C251F07B0DAA /* SXCXcodeMemberType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCXcodeMemberType.h; sourceTree = ""; }; + BA798C2F90A12BFEE77EFA5D /* SXCSourceFileDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCSourceFileDefinition.h; sourceTree = ""; }; + BA798C3E8F2CD550594E7231 /* SXCXcodeMemberType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCXcodeMemberType.m; sourceTree = ""; }; + BA798C57D9B8610BFECB9528 /* SXCProject+SubProject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SXCProject+SubProject.m"; sourceTree = ""; }; BA798C8AB338121AFFE692F8 /* HelloWorldLayer.header */ = {isa = PBXFileReference; lastKnownFileType = file.header; path = HelloWorldLayer.header; sourceTree = ""; }; BA798CAEB3570762F71E2AF6 /* Tests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; BA798CECA2420D48B499842E /* XcodeEditor-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XcodeEditor-Prefix.pch"; sourceTree = ""; }; - BA798CF27DA49D73EBE0FCB7 /* XcodeSourceFileType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XcodeSourceFileType.h; sourceTree = ""; }; - BA798CFD524E5A3CF155C816 /* XCProjectTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCProjectTests.m; sourceTree = ""; }; - BA798D221F1008AE859B76B8 /* XCXibDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCXibDefinition.h; sourceTree = ""; }; - BA798D6F34B9A560E3D689B3 /* XcodeFileReferenceTypeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XcodeFileReferenceTypeTests.m; sourceTree = ""; }; - BA798DB7EBF603A22E7334BF /* XCKeyBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCKeyBuilder.m; sourceTree = ""; }; - BA798DCCBF81FADC37488A36 /* XCProjectBuildConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCProjectBuildConfig.h; sourceTree = ""; }; - BA798E32B62ACEF1B995F0D3 /* XCFileOperationQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCFileOperationQueue.m; sourceTree = ""; }; + BA798CF27DA49D73EBE0FCB7 /* SXCXcodeFileType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCXcodeFileType.h; sourceTree = ""; }; + BA798CFD524E5A3CF155C816 /* SXCProjectTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCProjectTests.m; sourceTree = ""; }; + BA798D221F1008AE859B76B8 /* SXCXibDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCXibDefinition.h; sourceTree = ""; }; + BA798D6F34B9A560E3D689B3 /* SXCSourceFileTypeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCSourceFileTypeTests.m; sourceTree = ""; }; + BA798DB7EBF603A22E7334BF /* SXCKeyBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCKeyBuilder.m; sourceTree = ""; }; + BA798DCCBF81FADC37488A36 /* SXCProjectBuildConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCProjectBuildConfig.h; sourceTree = ""; }; + BA798E32B62ACEF1B995F0D3 /* SXCFileOperationQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SXCFileOperationQueue.m; sourceTree = ""; }; BA798E7947765A032AB118BA /* ESA_Sales_Foobar_ViewController.header */ = {isa = PBXFileReference; lastKnownFileType = file.header; path = ESA_Sales_Foobar_ViewController.header; sourceTree = ""; }; BA798EC5D7AFB1BC79B1934E /* ESA_Sales_Foobar_ViewController.impl */ = {isa = PBXFileReference; lastKnownFileType = file.impl; path = ESA_Sales_Foobar_ViewController.impl; sourceTree = ""; }; - BA798FDE9BAA7D87499853ED /* XCFileOperationQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCFileOperationQueue.h; sourceTree = ""; }; + BA798FDE9BAA7D87499853ED /* SXCFileOperationQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SXCFileOperationQueue.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -224,19 +224,17 @@ 6BCED6E31A4A61DC0005596F /* XcodeEditorTests */ = { isa = PBXGroup; children = ( + BA79834C0D69083DBB47F493 /* Resources */, 6BCED6E41A4A61DC0005596F /* Supporting Files */, - BA79864A6A2E695EBF74FDC1 /* InfoPlist.strings */, - BA7989499B6F59EEC2E1AA41 /* XCGroupTests.m */, BA79801CE5E6F16CB704E34E /* Utils */, - BA798974A01772350D7C81BD /* XCTargetTests.m */, - BA79858C0B5035B3EB71E67C /* Tests-Info.plist */, - BA798D6F34B9A560E3D689B3 /* XcodeFileReferenceTypeTests.m */, - BA7983A401A60AA073A26789 /* XCSubProjectDefinitionTests.m */, - BA79834C0D69083DBB47F493 /* Resources */, - BA798CFD524E5A3CF155C816 /* XCProjectTests.m */, - BA7984685319A7BB1B37DBE9 /* XCClassDefinitionTests.m */, + BA7984685319A7BB1B37DBE9 /* SXCClassDefinitionTests.m */, + BA7989499B6F59EEC2E1AA41 /* SXCGroupTests.m */, + BA798BD3F30B4E39066F8108 /* SXCKeyBuilderTests.m */, + BA798CFD524E5A3CF155C816 /* SXCProjectTests.m */, + BA798D6F34B9A560E3D689B3 /* SXCSourceFileTypeTests.m */, + BA7983A401A60AA073A26789 /* SXCSubProjectDefinitionTests.m */, + BA798974A01772350D7C81BD /* SXCTargetTests.m */, BA798CAEB3570762F71E2AF6 /* Tests-Prefix.pch */, - BA798BD3F30B4E39066F8108 /* XCKeyBuilderTests.m */, ); path = XcodeEditorTests; sourceTree = ""; @@ -244,6 +242,7 @@ 6BCED6E41A4A61DC0005596F /* Supporting Files */ = { isa = PBXGroup; children = ( + BA79858C0B5035B3EB71E67C /* Tests-Info.plist */, 6BCED6E51A4A61DC0005596F /* Info.plist */, ); name = "Supporting Files"; @@ -252,40 +251,40 @@ 6BE4B285147E6B610059E44D /* Source */ = { isa = PBXGroup; children = ( - BA798CF27DA49D73EBE0FCB7 /* XcodeSourceFileType.h */, - BA7989F085BDB69CB462D203 /* XCGroup.m */, - BA798287F70884A45C9F3721 /* XCAbstractDefinition.m */, - BA798ABC7CC2DB8B6994774C /* Utils */, - BA798A848F553CE428B7CC74 /* XCSourceFile.m */, - BA7983A0D40F7D264D8E6DF3 /* XCClassDefinition.h */, - BA798B392E07F43F5E0E77FC /* XCSourceFile.h */, BA79829560E06C6EF29DAB81 /* Resources */, - BA798C11E473C251F07B0DAA /* XcodeMemberType.h */, - BA798473A7694F9383712D07 /* XCSourceFileDefinition.m */, - BA7982A4051493BD524C3BBD /* XCXibDefinition.m */, - BA7982A01773D8163E643FAA /* XcodeSourceFileType.m */, - BA798516EBADF7760937A8D6 /* XCSubProjectDefinition.h */, - BA798ABFC33DC1AE014D76D6 /* XCTarget.m */, - BA7988B8FA1C50DE6B1B54D2 /* XCProject.h */, - BA79885862A8419969A4CC7A /* XCFrameworkDefinition.m */, - BA7987AE440FBAAC032785B1 /* XCSubProjectDefinition.m */, - BA7986BC9EE998925B797690 /* XCFrameworkDefinition.h */, - BA79868C3DE682529FB4B76E /* XCProjectBuildConfig.m */, - BA79840E5B88656BAAE1D8B5 /* XcodeGroupMember.h */, - BA798A9F12459363332BFD04 /* XCClassDefinition.m */, - BA79837129D1D730443959A2 /* XCAbstractDefinition.h */, - BA798E32B62ACEF1B995F0D3 /* XCFileOperationQueue.m */, - BA79888A08A5739C728633D2 /* XcodeEditor.h */, - BA7986459784ADE55A4B7CAC /* XCProject+SubProject.h */, - BA7983FEC190BC062691EA39 /* XCGroup.h */, - BA798C57D9B8610BFECB9528 /* XCProject+SubProject.m */, - BA7982BE32BDDBBC9DA2FDC8 /* XCTarget.h */, - BA798C2F90A12BFEE77EFA5D /* XCSourceFileDefinition.h */, - BA798C3E8F2CD550594E7231 /* XcodeMemberType.m */, - BA798DCCBF81FADC37488A36 /* XCProjectBuildConfig.h */, - BA7989AC9710D456572783C7 /* XCProject.m */, - BA798D221F1008AE859B76B8 /* XCXibDefinition.h */, - BA798FDE9BAA7D87499853ED /* XCFileOperationQueue.h */, + BA798ABC7CC2DB8B6994774C /* Utils */, + BA79837129D1D730443959A2 /* SXCAbstractDefinition.h */, + BA798287F70884A45C9F3721 /* SXCAbstractDefinition.m */, + BA7983A0D40F7D264D8E6DF3 /* SXCClassDefinition.h */, + BA798A9F12459363332BFD04 /* SXCClassDefinition.m */, + BA798FDE9BAA7D87499853ED /* SXCFileOperationQueue.h */, + BA798E32B62ACEF1B995F0D3 /* SXCFileOperationQueue.m */, + BA7986BC9EE998925B797690 /* SXCFrameworkDefinition.h */, + BA79885862A8419969A4CC7A /* SXCFrameworkDefinition.m */, + BA7983FEC190BC062691EA39 /* SXCGroup.h */, + BA7989F085BDB69CB462D203 /* SXCGroup.m */, + BA7986459784ADE55A4B7CAC /* SXCProject+SubProject.h */, + BA798C57D9B8610BFECB9528 /* SXCProject+SubProject.m */, + BA7988B8FA1C50DE6B1B54D2 /* SXCProject.h */, + BA7989AC9710D456572783C7 /* SXCProject.m */, + BA798DCCBF81FADC37488A36 /* SXCProjectBuildConfig.h */, + BA79868C3DE682529FB4B76E /* SXCProjectBuildConfig.m */, + BA798B392E07F43F5E0E77FC /* SXCSourceFile.h */, + BA798A848F553CE428B7CC74 /* SXCSourceFile.m */, + BA798C2F90A12BFEE77EFA5D /* SXCSourceFileDefinition.h */, + BA798473A7694F9383712D07 /* SXCSourceFileDefinition.m */, + BA798516EBADF7760937A8D6 /* SXCSubProjectDefinition.h */, + BA7987AE440FBAAC032785B1 /* SXCSubProjectDefinition.m */, + BA7982BE32BDDBBC9DA2FDC8 /* SXCTarget.h */, + BA798ABFC33DC1AE014D76D6 /* SXCTarget.m */, + BA798D221F1008AE859B76B8 /* SXCXibDefinition.h */, + BA7982A4051493BD524C3BBD /* SXCXibDefinition.m */, + BA79888A08A5739C728633D2 /* SXCXcodeEditor.h */, + BA79840E5B88656BAAE1D8B5 /* SXCXcodeGroupMember.h */, + BA798C11E473C251F07B0DAA /* SXCXcodeMemberType.h */, + BA798C3E8F2CD550594E7231 /* SXCXcodeMemberType.m */, + BA798CF27DA49D73EBE0FCB7 /* SXCXcodeFileType.h */, + BA7982A01773D8163E643FAA /* SXCXcodeFileType.m */, ); path = Source; sourceTree = ""; @@ -293,8 +292,8 @@ BA79801CE5E6F16CB704E34E /* Utils */ = { isa = PBXGroup; children = ( - BA798B07E98D7BCE4145F363 /* NSString+TestResource.h */, - BA798233F677AB6DE9FB37FC /* NSString+TestResource.m */, + BA798B07E98D7BCE4145F363 /* NSString+SXCTestResource.h */, + BA798233F677AB6DE9FB37FC /* NSString+SXCTestResource.m */, ); path = Utils; sourceTree = ""; @@ -312,6 +311,7 @@ BA79834C0D69083DBB47F493 /* Resources */ = { isa = PBXGroup; children = ( + BA79864A6A2E695EBF74FDC1 /* InfoPlist.strings */, BA79848C44BAD3669D8B787E /* Person.impl */, BA798924D39B66695026C637 /* goat-funny.png */, BA798943BA7D1C740F0A098F /* HelloBoxy.zip */, @@ -329,8 +329,8 @@ BA798ABC7CC2DB8B6994774C /* Utils */ = { isa = PBXGroup; children = ( - BA798DB7EBF603A22E7334BF /* XCKeyBuilder.m */, - BA798909AC4D1FCE033E64C5 /* XCKeyBuilder.h */, + BA798909AC4D1FCE033E64C5 /* SXCKeyBuilder.h */, + BA798DB7EBF603A22E7334BF /* SXCKeyBuilder.m */, ); path = Utils; sourceTree = ""; @@ -342,24 +342,24 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - BA7980D47618535CEEE56C07 /* XcodeSourceFileType.h in Headers */, - BA798DC320D5F6F188C112B3 /* XCKeyBuilder.h in Headers */, - BA7983A0DEE6E0B98286444A /* XCClassDefinition.h in Headers */, - BA798641126C8C9498C21843 /* XCSourceFile.h in Headers */, + BA7980D47618535CEEE56C07 /* SXCXcodeFileType.h in Headers */, + BA798DC320D5F6F188C112B3 /* SXCKeyBuilder.h in Headers */, + BA7983A0DEE6E0B98286444A /* SXCClassDefinition.h in Headers */, + BA798641126C8C9498C21843 /* SXCSourceFile.h in Headers */, BA798F6617C56888653CE018 /* XcodeEditor-Prefix.pch in Headers */, - BA7984763E39F64955CFE6F5 /* XcodeMemberType.h in Headers */, - BA79868C0786BB13E5C324ED /* XCProject.h in Headers */, - BA798EFC5F24AC9FD857373C /* XCFrameworkDefinition.h in Headers */, - BA798A3F4DCBD5DD024B1147 /* XcodeGroupMember.h in Headers */, - BA798AD506D19B5D3FB6DE4E /* XCAbstractDefinition.h in Headers */, - BA798F131E3B0412BEE23CA3 /* XcodeEditor.h in Headers */, - BA7985C5136218B0D782F7F1 /* XCProject+SubProject.h in Headers */, - BA79825A7D7CB5AD4EE31A6C /* XCGroup.h in Headers */, - BA79845EF211493263B4D0FC /* XCTarget.h in Headers */, - BA798BE4876F847D0F1BA266 /* XCSourceFileDefinition.h in Headers */, - BA7985C665CCF83437B2231E /* XCProjectBuildConfig.h in Headers */, - BA7988ABB09415FEE5070B38 /* XCXibDefinition.h in Headers */, - BA7987C8FAAD4E3225D7DDC3 /* XCFileOperationQueue.h in Headers */, + BA7984763E39F64955CFE6F5 /* SXCXcodeMemberType.h in Headers */, + BA79868C0786BB13E5C324ED /* SXCProject.h in Headers */, + BA798EFC5F24AC9FD857373C /* SXCFrameworkDefinition.h in Headers */, + BA798A3F4DCBD5DD024B1147 /* SXCXcodeGroupMember.h in Headers */, + BA798AD506D19B5D3FB6DE4E /* SXCAbstractDefinition.h in Headers */, + BA798F131E3B0412BEE23CA3 /* SXCXcodeEditor.h in Headers */, + BA7985C5136218B0D782F7F1 /* SXCProject+SubProject.h in Headers */, + BA79825A7D7CB5AD4EE31A6C /* SXCGroup.h in Headers */, + BA79845EF211493263B4D0FC /* SXCTarget.h in Headers */, + BA798BE4876F847D0F1BA266 /* SXCSourceFileDefinition.h in Headers */, + BA7985C665CCF83437B2231E /* SXCProjectBuildConfig.h in Headers */, + BA7988ABB09415FEE5070B38 /* SXCXibDefinition.h in Headers */, + BA7987C8FAAD4E3225D7DDC3 /* SXCFileOperationQueue.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -409,7 +409,7 @@ 6BC10157147775A40055CF03 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0430; + LastUpgradeCheck = 0630; ORGANIZATIONNAME = ""; TargetAttributes = { 6BCED6E11A4A61DC0005596F = { @@ -476,7 +476,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"-------------- EXTRACTING TEST RESOURCES --------------\"\n\nrm -fr /tmp/*\n\nunzip ${SRCROOT}/XcodeEditorTests/Resources/expanz-iOS-SDK.zip -d /tmp\nunzip ${SRCROOT}/XcodeEditorTests/Resources/ArchiveProj.zip -d /tmp\nunzip ${SRCROOT}/XcodeEditorTests/Resources/HelloBoxy.zip -d /tmp\ncp ${SRCROOT}/XcodeEditorTests/Resources/* /tmp"; + shellScript = "echo \"-------------- EXTRACTING TEST RESOURCES --------------\"\n\nrm -fr /tmp/XcodeEditorTests/*\n\nunzip ${SRCROOT}/XcodeEditorTests/Resources/expanz-iOS-SDK.zip -d /tmp/XcodeEditorTests\nunzip ${SRCROOT}/XcodeEditorTests/Resources/ArchiveProj.zip -d /tmp/XcodeEditorTests\nunzip ${SRCROOT}/XcodeEditorTests/Resources/HelloBoxy.zip -d /tmp/XcodeEditorTests\ncp ${SRCROOT}/XcodeEditorTests/Resources/* /tmp/XcodeEditorTests"; }; /* End PBXShellScriptBuildPhase section */ @@ -485,22 +485,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - BA79845D705566388D6A74F5 /* XCGroup.m in Sources */, - BA79857B12A10B9BFBF3C929 /* XCAbstractDefinition.m in Sources */, - BA79861FCDBD84679CA89D9E /* XCKeyBuilder.m in Sources */, - BA7981FF93FAFD6320C739ED /* XCSourceFile.m in Sources */, - BA7989692AF001BA1BBEACCF /* XCSourceFileDefinition.m in Sources */, - BA79881A93B24339436DF2FC /* XCXibDefinition.m in Sources */, - BA7988C3E49E2C17AACB9CDC /* XcodeSourceFileType.m in Sources */, - BA798BD3214388015EAFDDFB /* XCTarget.m in Sources */, - BA79866BA1ACA2933B98F48C /* XCFrameworkDefinition.m in Sources */, - BA7981FC099C3D8C4BA8E511 /* XCSubProjectDefinition.m in Sources */, - BA79862308DF0F7F984AF86E /* XCProjectBuildConfig.m in Sources */, - BA7981A76C28C0D8FE7392E0 /* XCClassDefinition.m in Sources */, - BA79876598EF30F3EE513484 /* XCFileOperationQueue.m in Sources */, - BA7984F6EE4FA90717414543 /* XCProject+SubProject.m in Sources */, - BA7986719FB605B7F7698E81 /* XcodeMemberType.m in Sources */, - BA7981663E00E804C25FDA0D /* XCProject.m in Sources */, + BA79845D705566388D6A74F5 /* SXCGroup.m in Sources */, + BA79857B12A10B9BFBF3C929 /* SXCAbstractDefinition.m in Sources */, + BA79861FCDBD84679CA89D9E /* SXCKeyBuilder.m in Sources */, + BA7981FF93FAFD6320C739ED /* SXCSourceFile.m in Sources */, + BA7989692AF001BA1BBEACCF /* SXCSourceFileDefinition.m in Sources */, + BA79881A93B24339436DF2FC /* SXCXibDefinition.m in Sources */, + BA7988C3E49E2C17AACB9CDC /* SXCXcodeFileType.m in Sources */, + BA798BD3214388015EAFDDFB /* SXCTarget.m in Sources */, + BA79866BA1ACA2933B98F48C /* SXCFrameworkDefinition.m in Sources */, + BA7981FC099C3D8C4BA8E511 /* SXCSubProjectDefinition.m in Sources */, + BA79862308DF0F7F984AF86E /* SXCProjectBuildConfig.m in Sources */, + BA7981A76C28C0D8FE7392E0 /* SXCClassDefinition.m in Sources */, + BA79876598EF30F3EE513484 /* SXCFileOperationQueue.m in Sources */, + BA7984F6EE4FA90717414543 /* SXCProject+SubProject.m in Sources */, + BA7986719FB605B7F7698E81 /* SXCXcodeMemberType.m in Sources */, + BA7981663E00E804C25FDA0D /* SXCProject.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -508,14 +508,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 6BCED7001A4A629D0005596F /* XCProjectTests.m in Sources */, - 6BCED6FC1A4A628D0005596F /* XCGroupTests.m in Sources */, - 6BCED7011A4A62A00005596F /* XCClassDefinitionTests.m in Sources */, - 6BCED6FD1A4A62910005596F /* XCTargetTests.m in Sources */, - 6BCED7031A4A62B00005596F /* XCKeyBuilderTests.m in Sources */, - 6BCED6FF1A4A62970005596F /* XCSubProjectDefinitionTests.m in Sources */, - 6BCED6FE1A4A62950005596F /* XcodeFileReferenceTypeTests.m in Sources */, - BA798AECC575AEE83D96D580 /* NSString+TestResource.m in Sources */, + 6BCED7001A4A629D0005596F /* SXCProjectTests.m in Sources */, + 6BCED6FC1A4A628D0005596F /* SXCGroupTests.m in Sources */, + 6BCED7011A4A62A00005596F /* SXCClassDefinitionTests.m in Sources */, + 6BCED6FD1A4A62910005596F /* SXCTargetTests.m in Sources */, + 6BCED7031A4A62B00005596F /* SXCKeyBuilderTests.m in Sources */, + 6BCED6FF1A4A62970005596F /* SXCSubProjectDefinitionTests.m in Sources */, + 6BCED6FE1A4A62950005596F /* SXCSourceFileTypeTests.m in Sources */, + BA798AECC575AEE83D96D580 /* NSString+SXCTestResource.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -544,6 +544,7 @@ BA7985E1B4262B71CC38472A /* en */, ); name = InfoPlist.strings; + path = ..; sourceTree = ""; }; /* End PBXVariantGroup section */ @@ -552,8 +553,8 @@ 6B3ACFED14F8A2FE00BCFE81 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + COMBINE_HIDPI_IMAGES = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( @@ -579,8 +580,8 @@ 6B3ACFEE14F8A2FE00BCFE81 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + COMBINE_HIDPI_IMAGES = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( @@ -605,11 +606,19 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -620,6 +629,9 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; @@ -630,15 +642,26 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.7; }; diff --git a/xcode-editor.xcodeproj/xcshareddata/xcschemes/XcodeEditor.xcscheme b/xcode-editor.xcodeproj/xcshareddata/xcschemes/XcodeEditor.xcscheme index 8219be1..a54a328 100644 --- a/xcode-editor.xcodeproj/xcshareddata/xcschemes/XcodeEditor.xcscheme +++ b/xcode-editor.xcodeproj/xcshareddata/xcschemes/XcodeEditor.xcscheme @@ -1,5 +1,6 @@