Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:expanz/xcode-editor

  • Loading branch information...
commit 51502372d585784eae17972b6e5b77714dfa5394 2 parents 419dd42 + 5f1ec64
@jasperblues jasperblues authored
View
1  README.md
@@ -155,6 +155,7 @@ JetBrains is not yet supported.
### With contributions from:
* Chris Ross of Hidden Memory (http://www.hiddenmemory.co.uk/)
+* Paul Taykalo
* Vladislav Alekseev
Thanks!
View
37 Source/Main/XcodeMemberType.m
@@ -15,22 +15,29 @@
@implementation NSDictionary (XcodeMemberType)
+static NSDictionary * _projectNodeTypesAsStrings;
+
+ (NSDictionary*) dictionaryWithProjectNodeTypesAsStrings {
- return [NSDictionary dictionaryWithObjectsAndKeys:boxEnum(PBXNilType), @"PBXNilType",
- boxEnum(PBXBuildFile), @"PBXBuildFile",
- boxEnum(PBXContainerItemProxy), @"PBXContainerItemProxy",
- boxEnum(PBXCopyFilesBuildPhase), @"PBXCopyFilesBuildPhase",
- boxEnum(PBXFileReference), @"PBXFileReference",
- boxEnum(PBXFrameworksBuildPhase), @"PBXFrameworksBuildPhase",
- boxEnum(PBXGroup), @"PBXGroup",
- boxEnum(PBXNativeTarget), @"PBXNativeTarget",
- boxEnum(PBXProject), @"PBXProject",
- boxEnum(PBXResourcesBuildPhase), @"PBXResourcesBuildPhase",
- boxEnum(PBXSourcesBuildPhase), @"PBXSourcesBuildPhase",
- boxEnum(PBXTargetDependency), @"PBXTargetDependency",
- boxEnum(PBXVariantGroup), @"PBXVariantGroup",
- boxEnum(XCBuildConfiguration), @"XCBuildConfiguration",
- boxEnum(XCConfigurationList), @"XCConfigurationList", nil];
+ // This is the most vital operation on adding 500+ files
+ // So, we caching this dictionary
+ if (!_projectNodeTypesAsStrings) {
+ _projectNodeTypesAsStrings = [NSDictionary dictionaryWithObjectsAndKeys:boxEnum(PBXNilType), @"PBXNilType",
+ boxEnum(PBXBuildFile), @"PBXBuildFile",
+ boxEnum(PBXContainerItemProxy), @"PBXContainerItemProxy",
+ boxEnum(PBXCopyFilesBuildPhase), @"PBXCopyFilesBuildPhase",
+ boxEnum(PBXFileReference), @"PBXFileReference",
+ boxEnum(PBXFrameworksBuildPhase), @"PBXFrameworksBuildPhase",
+ boxEnum(PBXGroup), @"PBXGroup",
+ boxEnum(PBXNativeTarget), @"PBXNativeTarget",
+ boxEnum(PBXProject), @"PBXProject",
+ boxEnum(PBXResourcesBuildPhase), @"PBXResourcesBuildPhase",
+ boxEnum(PBXSourcesBuildPhase), @"PBXSourcesBuildPhase",
+ boxEnum(PBXTargetDependency), @"PBXTargetDependency",
+ boxEnum(PBXVariantGroup), @"PBXVariantGroup",
+ boxEnum(XCBuildConfiguration), @"XCBuildConfiguration",
+ boxEnum(XCConfigurationList), @"XCConfigurationList", nil];
+ }
+ return _projectNodeTypesAsStrings;
}
@end
View
20 Source/Main/XcodeSourceFileType.h
@@ -10,14 +10,18 @@
////////////////////////////////////////////////////////////////////////////////
typedef enum {
- FileTypeNil,
- Framework,
- PropertyList,
- SourceCodeHeader,
- SourceCodeObjC,
- SourceCodeObjCPlusPlus,
- XibFile,
- ImageResourcePNG
+ FileTypeNil, // Unknown filetype
+ Framework, // .framework
+ PropertyList, // .plist
+ SourceCodeHeader, // .h
+ SourceCodeObjC, // .m
+ SourceCodeObjCPlusPlus, // .mm
+ XibFile, // .xib
+ ImageResourcePNG, // .png
+ Bundle, // .bundle .octet
+ Archive, // .a files
+ HTML, // HTML file
+ TEXT // Some text file
} XcodeSourceFileType;
@interface NSString (XCodeFileType)
View
9 Source/Main/XcodeSourceFileType.m
@@ -16,13 +16,18 @@
@implementation NSDictionary (XcodeFileType)
+ (NSDictionary*) dictionaryWithFileReferenceTypesAsStrings {
- return [NSDictionary dictionaryWithObjectsAndKeys:boxEnum(SourceCodeHeader), @"sourcecode.c.h",
+ return [NSDictionary dictionaryWithObjectsAndKeys:
+ boxEnum(SourceCodeHeader), @"sourcecode.c.h",
boxEnum(SourceCodeObjC), @"sourcecode.c.objc",
boxEnum(Framework), @"wrapper.framework",
boxEnum(PropertyList), @"text.plist.strings",
boxEnum(SourceCodeObjCPlusPlus), @"sourcecode.cpp.objcpp",
boxEnum(XibFile), @"file.xib",
boxEnum(ImageResourcePNG), @"image.png",
+ boxEnum(Bundle), @"wrapper.cfbundle",
+ boxEnum(Archive), @"archive.ar",
+ boxEnum(HTML), @"text.html",
+ boxEnum(TEXT), @"text",
nil];
}
@@ -37,7 +42,7 @@ + (NSString*) stringFromSourceFileType:(XcodeSourceFileType)type {
- (XcodeSourceFileType) asSourceFileType {
NSDictionary* typeStrings = [NSDictionary dictionaryWithFileReferenceTypesAsStrings];
-
+
if ([typeStrings objectForKey:self]) {
return (XcodeSourceFileType) [[typeStrings objectForKey:self] intValue];
}
View
6 Source/Main/xcode_Project.h
@@ -105,6 +105,12 @@
- (xcode_Group*) groupWithPathRelativeToParent:(NSString*)path;
/**
+ * Returns the group with the specified display name path - the directory relative to the root group. Eg Source/Main
+ */
+- (xcode_Group*) groupWithDisplayNamePathRelativeToParent:(NSString*)path;
+
+
+/**
* Returns the parent group for the group or file with the given key;
*/
- (xcode_Group*) groupForGroupMemberWithKey:(NSString*)key;
View
15 Source/Main/xcode_Project.m
@@ -177,6 +177,21 @@ - (Group*) groupWithPathRelativeToParent:(NSString*)path {
return nil;
}
+- (Group*) groupWithDisplayNamePathRelativeToParent:(NSString*)path {
+ NSArray * pathItems = [path componentsSeparatedByString:@"/"];
+ Group * currentGroup = [self rootGroup];
+ for (NSString * pathItem in pathItems) {
+ id<XcodeGroupMember> group = [currentGroup memberWithDisplayName:pathItem];
+ if ([group isKindOfClass:[Group class]]) {
+ currentGroup = group;
+ } else {
+ return nil;
+ }
+ }
+ return currentGroup;
+}
+
+
/* ================================================================================================================== */
#pragma mark Targets
View
2  Source/Main/xcode_SourceFile.m
@@ -64,7 +64,7 @@ - (BOOL) isBuildFile {
}
- (BOOL) canBecomeBuildFile {
- return _type == SourceCodeObjC || _type == SourceCodeObjCPlusPlus || _type == XibFile || _type == Framework;
+ return _type == SourceCodeObjC || _type == SourceCodeObjCPlusPlus || _type == XibFile || _type == Framework || _type == ImageResourcePNG || _type == HTML || _type == Bundle || _type == Archive;
}
View
7 Source/Main/xcode_Target.m
@@ -168,6 +168,13 @@ - (XcodeMemberType) buildPhaseFor:(SourceFile*)sourceFile {
else if (sourceFile.type == Framework) {
return PBXFrameworksBuildPhase;
}
+ else if (sourceFile.type == ImageResourcePNG || sourceFile.type == HTML || sourceFile.type == Bundle) {
+ return PBXResourcesBuildPhase;
+ }
+ else if (sourceFile.type == Archive) {
+ return PBXFrameworksBuildPhase;
+ }
+
else {
NSString* type = [NSString stringFromSourceFileType:[sourceFile type]];
[NSException raise:NSInternalInconsistencyException format:@"Type %@ cannot be added to a target.", type];
Please sign in to comment.
Something went wrong with that request. Please try again.