From 35c4a29858630dd673fe59e053dbb3dc3544b12f Mon Sep 17 00:00:00 2001 From: iosdevzone Date: Sun, 20 Sep 2015 04:20:36 -0700 Subject: [PATCH] Add Xcode 7 lightweight generics to make Swift use easier --- Source/XCGroup.h | 29 ++++++++++++++++------------- Source/XCGroup.m | 2 +- Source/XCProject+SubProject.h | 6 +++--- Source/XCProject.h | 31 ++++++++++++++++--------------- Source/XCProject.m | 2 +- Source/XCProjectBuildConfig.h | 2 +- Source/XCSubProjectDefinition.h | 2 +- Source/XCTarget.h | 8 ++++---- 8 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Source/XCGroup.h b/Source/XCGroup.h index 37b2835..1d8068c 100755 --- a/Source/XCGroup.h +++ b/Source/XCGroup.h @@ -21,6 +21,7 @@ @class XCFrameworkDefinition; @class XCSourceFileDefinition; @class XCSubProjectDefinition; +@class XCTarget; /** @@ -68,14 +69,14 @@ /** * An array containing the groups members as `XcodeGroupMember` types. */ -@property(nonatomic, strong, readonly) NSMutableArray* children; +@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; ++ (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; +- (id)initWithProject:(XCProject*)project key:(NSString*)key alias:(NSString*)alias path:(NSString*)path children:(NSArray>*)children; #pragma mark Parent group @@ -97,7 +98,7 @@ /** * Adds a class to the group, making it a member of the specified [targets](XCTarget). */ -- (void)addClass:(XCClassDefinition*)classDefinition toTargets:(NSArray*)targets; +- (void)addClass:(XCClassDefinition*)classDefinition toTargets:(NSArray*)targets; /** * Adds a framework to the group. If the group already contains the framework, the contents will be updated if the @@ -118,7 +119,7 @@ /** * Adds a framework to the group, making it a member of the specified targets. */ -- (void)addFramework:(XCFrameworkDefinition*)framework toTargets:(NSArray*)targets; +- (void)addFramework:(XCFrameworkDefinition*)framework toTargets:(NSArray*)targets; /** * Adds a source file of arbitrary type - image resource, header, etc. @@ -134,7 +135,7 @@ /** * Adds a xib to the group, making it a member of the specified [targets](XCTarget). */ -- (void)addXib:(XCXibDefinition*)xibDefinition toTargets:(NSArray*)targets; +- (void)addXib:(XCXibDefinition*)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 @@ -147,26 +148,28 @@ /** * Adds a sub-project to the group, making it a member of the specified [targets](XCTarget). */ -- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition toTargets:(NSArray*)targets; +- (void)addSubProject:(XCSubProjectDefinition*)projectDefinition toTargets:(NSArray*)targets; - (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition; -- (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets:(NSArray*)targets; +- (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets:(NSArray*)targets; #pragma mark Locating children /** * Instances of `XCSourceFile` and `XCGroup` returned as the type `XcodeGroupMember`. */ -- (NSArray*)members; +- (NSArray>*)members; /** -* Instances of `XCSourceFile` from this group and any child groups. +* Keys of members from this group and any child groups. */ -- (NSArray*)recursiveMembers; +- (NSArray*)recursiveMembers; - -- (NSArray*)buildFileKeys; +/** + * Keys of members from this group + */ +- (NSArray*)buildFileKeys; /** * Returns the child with the specified key, or nil. diff --git a/Source/XCGroup.m b/Source/XCGroup.m index 4fb9315..5300599 100755 --- a/Source/XCGroup.m +++ b/Source/XCGroup.m @@ -355,7 +355,7 @@ - (void)removeSubProject:(XCSubProjectDefinition*)projectDefinition fromTargets: //------------------------------------------------------------------------------------------- #pragma mark Members -- (NSArray*)members +- (NSArray>*)members { if (_members == nil) { diff --git a/Source/XCProject+SubProject.h b/Source/XCProject+SubProject.h index 5b304eb..ec4bf06 100644 --- a/Source/XCProject+SubProject.h +++ b/Source/XCProject+SubProject.h @@ -19,11 +19,11 @@ - (NSString *)referenceProxyKeyForName:(NSString *)name; -- (NSArray *)buildProductsForTargets:(NSString *)xcodeprojKey; +- (NSArray *)buildProductsForTargets:(NSString *)xcodeprojKey; -- (void)addAsTargetDependency:(XCSubProjectDefinition *)xcodeprojDefinition toTargets:(NSArray *)targets; +- (void)addAsTargetDependency:(XCSubProjectDefinition *)xcodeprojDefinition toTargets:(NSArray*)targets; -- (NSArray *)keysForProjectObjectsOfType:(XcodeMemberType)memberType withIdentifier:(NSString *)identifier +- (NSArray *)keysForProjectObjectsOfType:(XcodeMemberType)memberType withIdentifier:(NSString *)identifier singleton:(BOOL)singleton required:(BOOL)required; - (NSMutableDictionary *)PBXProjectDict; diff --git a/Source/XCProject.h b/Source/XCProject.h index 84e722d..2fe7a09 100755 --- a/Source/XCProject.h +++ b/Source/XCProject.h @@ -58,7 +58,7 @@ NSString* const XCProjectNotFoundException; /** * Returns all file resources in the project, as an array of `XCSourceFile` objects. */ -- (NSArray*)files; +- (NSArray*)files; /** * Returns the project file with the specified key, or nil. @@ -74,24 +74,24 @@ NSString* const XCProjectNotFoundException; /** * Returns all header files in the project, as an array of `XCSourceFile` objects. */ -- (NSArray*)headerFiles; +- (NSArray*)headerFiles; /** * Returns all implementation obj-c implementation files in the project, as an array of `XCSourceFile` objects. */ -- (NSArray*)objectiveCFiles; +- (NSArray*)objectiveCFiles; /** * Returns all implementation obj-c++ implementation files in the project, as an array of `XCSourceFile` objects. */ -- (NSArray*)objectiveCPlusPlusFiles; +- (NSArray*)objectiveCPlusPlusFiles; /** * Returns all the xib files in the project, as an array of `XCSourceFile` objects. */ -- (NSArray*)xibFiles; +- (NSArray*)xibFiles; -- (NSArray*)imagePNGFiles; +- (NSArray*)imagePNGFiles; - (NSString*)filePath; @@ -101,7 +101,7 @@ NSString* const XCProjectNotFoundException; /** * Lists the groups in an xcode project, returning an array of `XCGroup` objects. */ -- (NSArray*)groups; +- (NSArray*)groups; /** * Returns the root (top-level) group. @@ -111,7 +111,7 @@ NSString* const XCProjectNotFoundException; /** * Returns the root (top-level) groups, if there are multiple. An array of rootGroup if there is only one. */ -- (NSArray*)rootGroups; +- (NSArray*)rootGroups; /** * Returns the group with the given key, or nil. @@ -138,7 +138,7 @@ NSString* const XCProjectNotFoundException; /** * Lists the targets in an xcode project, returning an array of `XCTarget` objects. */ -- (NSArray*)targets; +- (NSArray*)targets; /** * Returns the target with the specified name, or nil. @@ -146,13 +146,14 @@ NSString* const XCProjectNotFoundException; - (XCTarget*)targetWithName:(NSString*)name; #pragma mark Configurations - /** -* Returns the target with the specified name, or nil. -*/ -- (NSDictionary*)configurations; - -- (NSDictionary*)configurationWithName:(NSString*)name; + * Lists the configurations in an xcode project. + */ +- (NSDictionary*)configurations; +/** + * Returns the configuration with the specified name, or nil. + */ +- (XCProjectBuildConfig*)configurationWithName:(NSString*)name; - (XCProjectBuildConfig *)defaultConfiguration; diff --git a/Source/XCProject.m b/Source/XCProject.m index 39faadb..ee7e2aa 100755 --- a/Source/XCProject.m +++ b/Source/XCProject.m @@ -365,7 +365,7 @@ - (NSDictionary*)configurations return [_configurations copy]; } -- (NSDictionary*)configurationWithName:(NSString*)name +- (XCProjectBuildConfig*)configurationWithName:(NSString*)name { return [[self configurations] objectForKey:name]; } diff --git a/Source/XCProjectBuildConfig.h b/Source/XCProjectBuildConfig.h index d57911e..60c5989 100644 --- a/Source/XCProjectBuildConfig.h +++ b/Source/XCProjectBuildConfig.h @@ -25,7 +25,7 @@ @property(nonatomic, readonly) NSDictionary* specifiedBuildSettings; -+ (NSDictionary*)buildConfigurationsFromArray:(NSArray*)array inProject:(XCProject*)project; ++ (NSDictionary*)buildConfigurationsFromArray:(NSArray*)array inProject:(XCProject*)project; - (instancetype)initWithProject:(XCProject*)project key:(NSString*)key; diff --git a/Source/XCSubProjectDefinition.h b/Source/XCSubProjectDefinition.h index c871a28..e397f0b 100644 --- a/Source/XCSubProjectDefinition.h +++ b/Source/XCSubProjectDefinition.h @@ -48,7 +48,7 @@ - (NSString *)fullPathName; -- (NSArray *)buildProductNames; +- (NSArray *)buildProductNames; - (NSString *)projectKey; diff --git a/Source/XCTarget.h b/Source/XCTarget.h index 7b6349e..b844fd6 100755 --- a/Source/XCTarget.h +++ b/Source/XCTarget.h @@ -46,11 +46,11 @@ - (id)initWithProject:(XCProject*)project key:(NSString*)key name:(NSString*)name productName:(NSString*)productName productReference:(NSString*)productReference; -- (NSArray*)resources; +- (NSArray*)resources; -- (NSArray*)members; +- (NSArray*)members; -- (NSDictionary*)configurations; +- (NSDictionary*)configurations; - (XCProjectBuildConfig *)configurationWithName:(NSString*)name; @@ -60,7 +60,7 @@ - (void)removeMemberWithKey:(NSString*)key; -- (void)removeMembersWithKeys:(NSArray*)keys; +- (void)removeMembersWithKeys:(NSArray*)keys; - (void)addDependency:(NSString*)key;