-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Patrick-Kladek/xcode11
Carthage Support
- Loading branch information
Showing
86 changed files
with
2,803 additions
and
3,178 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
CocoaDebugKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
351 changes: 79 additions & 272 deletions
351
...S/CocoaDebugKit.xcodeproj/project.pbxproj → ...t/CocoaDebugKit.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
...ebugKit/CocoaDebugKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
File renamed without changes.
67 changes: 67 additions & 0 deletions
67
CocoaDebugKit/CocoaDebugKit.xcodeproj/xcshareddata/xcschemes/CocoaDebugKit.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1140" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "CD2761EA1B0E1C050000BB5D" | ||
BuildableName = "CocoaDebugKit.framework" | ||
BlueprintName = "CocoaDebugKit" | ||
ReferencedContainer = "container:CocoaDebugKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "CD2761EA1B0E1C050000BB5D" | ||
BuildableName = "CocoaDebugKit.framework" | ||
BlueprintName = "CocoaDebugKit" | ||
ReferencedContainer = "container:CocoaDebugKit.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
// | ||
// CocoaDebugDescription.m | ||
// CocoaDebugKit | ||
// | ||
// Created by Patrick Kladek on 19.04.16. | ||
// Copyright (c) 2016 Patrick Kladek. All rights reserved. | ||
// | ||
|
||
#import "CocoaDebugDescription.h" | ||
#import "CocoaPropertyEnumerator.h" | ||
#import "CocoaDebugSettings.h" | ||
#import "NSObject+CPAdditions.h" | ||
|
||
|
||
@interface CocoaDebugDescription () | ||
|
||
@property (nonatomic) CocoaPropertyEnumerator *propertyEnumerator; | ||
@property (nonatomic) NSMutableArray *lines; | ||
@property (nonatomic) NSInteger typeLenght; | ||
|
||
@end | ||
|
||
|
||
@implementation CocoaDebugDescription | ||
|
||
+ (CocoaDebugDescription *)debugDescription | ||
{ | ||
CocoaDebugDescription *description = [[self alloc] init]; | ||
return description; | ||
} | ||
|
||
+ (CocoaDebugDescription *)debugDescriptionForObject:(NSObject *)obj | ||
{ | ||
CocoaDebugDescription *description = [[self alloc] init]; | ||
[description addAllPropertiesFromObject:obj]; | ||
return description; | ||
} | ||
|
||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
_propertyEnumerator = [[CocoaPropertyEnumerator alloc] init]; | ||
_lines = [NSMutableArray array]; | ||
_typeLenght = 0; | ||
|
||
CocoaDebugSettings *settings = [CocoaDebugSettings sharedSettings]; | ||
|
||
self.dataMaxLenght = settings.maxDataLenght; | ||
self.save = settings.save; | ||
self.saveUrl = settings.saveUrl; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)addAllPropertiesFromObject:(NSObject *)obj | ||
{ | ||
_obj = obj; | ||
|
||
Class currentClass = [obj class]; | ||
|
||
while (currentClass != nil && currentClass != [NSObject class]) { | ||
[self.propertyEnumerator enumeratePropertiesFromClass:currentClass | ||
allowed:nil | ||
block:^(NSString *type, NSString *name) { | ||
[self addProperty:name type:type fromObject:obj]; | ||
}]; | ||
|
||
currentClass = [currentClass superclass]; | ||
} | ||
} | ||
|
||
- (void)addProperty:(NSString *)name type:(NSString *)type fromObject:(NSObject *)obj | ||
{ | ||
if (!_obj) { | ||
_obj = obj; | ||
} | ||
|
||
|
||
Class class = NSClassFromString(type); | ||
|
||
if ([class isSubclassOfClass:[NSData class]]) { | ||
NSData *data = [obj valueForKey:name]; | ||
|
||
// cut lenght to 100 byte | ||
if ([data length] > self.dataMaxLenght.integerValue) { | ||
data = [data subdataWithRange:NSMakeRange(0, self.dataMaxLenght.integerValue)]; | ||
} | ||
|
||
[self addDescriptionLine:[CocoaPropertyLine lineWithType:type name:name value:[data description]]]; | ||
return; | ||
} | ||
|
||
if ([class isSubclassOfClass:[CPImage class]]) { | ||
CPImage *image = [obj valueForKey:name]; | ||
NSString *imageDescription = [NSString stringWithFormat:@"size: %.0fx%.0f", image.size.width, image.size.height]; | ||
[self addDescriptionLine:[CocoaPropertyLine lineWithType:type name:name value:imageDescription]]; | ||
return; | ||
} | ||
|
||
|
||
id value = [obj valueForKey:name]; | ||
NSString *description = [[value description] stringByReplacingOccurrencesOfString:@"\n" withString:[NSString stringWithFormat:@"\n%@", [self _spaceFromLenght:4]]]; | ||
[self addDescriptionLine:[CocoaPropertyLine lineWithType:type name:name value:description]]; | ||
} | ||
|
||
- (NSString *)stringRepresentation | ||
{ | ||
NSMutableString *string = [NSMutableString stringWithFormat:@"<%p> %@ {\n", _obj, _obj.cp_className]; | ||
for (CocoaPropertyLine *line in self.lines) { | ||
NSInteger deltaLenght = self.typeLenght - (line.type.length + line.name.length); | ||
[string appendFormat:@"\t%@%@ %@ = %@\n", line.type, [self _spaceFromLenght:deltaLenght], line.name, line.value]; | ||
} | ||
|
||
[string appendString:@"}"]; | ||
return string; | ||
} | ||
|
||
- (void)saveDebugDescription | ||
{ | ||
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; | ||
NSString *appVersion = [infoDict objectForKey:@"CFBundleShortVersionString"];// example: 1.0.0 | ||
NSString *buildNumber = [infoDict objectForKey:@"CFBundleVersion"];// example: 42 | ||
|
||
NSURL *url = [_saveUrl URLByAppendingPathComponent:appVersion]; | ||
url = [url URLByAppendingPathComponent:buildNumber]; | ||
|
||
NSError *error; | ||
if (![[NSFileManager defaultManager] createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:&error]) { | ||
NSLog(@"%@", error); | ||
return; | ||
} | ||
|
||
NSString *className = [_obj cp_className]; | ||
|
||
NSDictionary *debuggedObjects = [[CocoaDebugSettings sharedSettings] debuggedObjects]; | ||
NSInteger debuggedCount = [[debuggedObjects valueForKey:className] integerValue]; | ||
debuggedCount++; | ||
[debuggedObjects setValue:[NSNumber numberWithInteger:debuggedCount] forKey:className]; | ||
url = [url URLByAppendingPathComponent:[NSString stringWithFormat:@"%@ %li.txt", className, (long) debuggedCount]]; | ||
|
||
[self saveDebugDescriptionToUrl:url error:nil]; | ||
} | ||
|
||
- (BOOL)saveDebugDescriptionToUrl:(NSURL *)url error:(NSError **)error | ||
{ | ||
return [[self stringRepresentation] writeToURL:url atomically:YES encoding:NSUTF8StringEncoding error:error]; | ||
} | ||
|
||
#pragma mark - Private | ||
|
||
- (NSString *)_spaceFromLenght:(NSInteger)lenght | ||
{ | ||
NSMutableString *string = [[NSMutableString alloc] initWithCapacity:lenght]; | ||
for (NSInteger i = 0; i < lenght; i++) { | ||
[string appendString:@" "]; | ||
} | ||
return string; | ||
} | ||
|
||
- (void)addDescriptionLine:(CocoaPropertyLine *)line | ||
{ | ||
if (line.type.length + line.name.length > self.typeLenght) { | ||
self.typeLenght = line.type.length + line.name.length; | ||
} | ||
|
||
[self.lines addObject:line]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.