Skip to content

Commit 4e8f9e8

Browse files
author
man.li
committed
[1.2.9] Support CocoaDebug Auto Launch
1 parent 493073d commit 4e8f9e8

File tree

10 files changed

+111
-75
lines changed

10 files changed

+111
-75
lines changed

CocoaDebug.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
1010
s.frameworks = 'UIKit', 'Foundation'
1111
s.platform = :ios, "8.0"
1212
s.swift_version = '5.0'
13-
s.version = '1.2.8'
13+
s.version = '1.2.9'
1414
s.source = { :git => "https://github.com/CocoaDebug/CocoaDebug.git", :branch => 'master', :tag => s.version.to_s }
1515
s.requires_arc = false
1616
s.requires_arc =

CocoaDebug.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331
3809682B2414E0CD00382668 /* _Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 380966DC2414E0CB00382668 /* _Wrappers.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
332332
3809682C2414E0CD00382668 /* _GPBDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 380966DD2414E0CB00382668 /* _GPBDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
333333
3809682E2414E1DB00382668 /* CocoaDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 380965832414E0CB00382668 /* CocoaDebug.h */; settings = {ATTRIBUTES = (Public, ); }; };
334+
38C806A324ADD11D0074D3D6 /* CocoaDebugAutoLaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 38C806A224ADD11D0074D3D6 /* CocoaDebugAutoLaunch.m */; };
334335
/* End PBXBuildFile section */
335336

336337
/* Begin PBXFileReference section */
@@ -661,6 +662,7 @@
661662
380966DB2414E0CB00382668 /* _GPBDescriptor_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _GPBDescriptor_PackagePrivate.h; sourceTree = "<group>"; };
662663
380966DC2414E0CB00382668 /* _Wrappers.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _Wrappers.pbobjc.m; sourceTree = "<group>"; };
663664
380966DD2414E0CB00382668 /* _GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _GPBDictionary.h; sourceTree = "<group>"; };
665+
38C806A224ADD11D0074D3D6 /* CocoaDebugAutoLaunch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocoaDebugAutoLaunch.m; sourceTree = "<group>"; };
664666
/* End PBXFileReference section */
665667

666668
/* Begin PBXFrameworksBuildPhase section */
@@ -725,8 +727,9 @@
725727
children = (
726728
380965812414E0CB00382668 /* CocoaDebug.swift */,
727729
380965822414E0CB00382668 /* CocoaDebugSettings.swift */,
728-
380965832414E0CB00382668 /* CocoaDebug.h */,
729730
380965842414E0CB00382668 /* CocoaDebug+Extensions.swift */,
731+
380965832414E0CB00382668 /* CocoaDebug.h */,
732+
38C806A224ADD11D0074D3D6 /* CocoaDebugAutoLaunch.m */,
730733
);
731734
path = Core;
732735
sourceTree = "<group>";
@@ -1500,6 +1503,7 @@
15001503
380966E82414E0CB00382668 /* CrashListViewController.swift in Sources */,
15011504
380967B42414E0CC00382668 /* _LogHelper.swift in Sources */,
15021505
380967BD2414E0CC00382668 /* _OCLogModel.m in Sources */,
1506+
38C806A324ADD11D0074D3D6 /* CocoaDebugAutoLaunch.m in Sources */,
15031507
380967A82414E0CC00382668 /* NetworkDetailCell.swift in Sources */,
15041508
380967A32414E0CC00382668 /* NetworkCell.swift in Sources */,
15051509
380967D62414E0CC00382668 /* _Swizzling.m in Sources */,

Example_Objc.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
380965102414DF4E00382668 /* _Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 380964F72414DF4D00382668 /* _Wrappers.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
268268
3820FFBF21E635D9001CAB32 /* index2.html in Resources */ = {isa = PBXBuildFile; fileRef = 3820FFBD21E635D9001CAB32 /* index2.html */; };
269269
3820FFC021E635D9001CAB32 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 3820FFBE21E635D9001CAB32 /* index.html */; };
270+
38C8069D24ADBF4C0074D3D6 /* CocoaDebugAutoLaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 38C8069C24ADBF4C0074D3D6 /* CocoaDebugAutoLaunch.m */; };
270271
4B1210651F040F9F44B7A1F1 /* Pods_Example_Objc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F85B59B981887B01B909F66C /* Pods_Example_Objc.framework */; };
271272
7A2737D31A971E9C238BEC79 /* Pods_Example_ObjcTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B384C55C2BBC4F20D5023A8 /* Pods_Example_ObjcTests.framework */; };
272273
EA165F01204D2539001472C1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EA165F00204D2539001472C1 /* AppDelegate.m */; };
@@ -634,6 +635,7 @@
634635
380964F82414DF4D00382668 /* _GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _GPBDictionary.h; sourceTree = "<group>"; };
635636
3820FFBD21E635D9001CAB32 /* index2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index2.html; sourceTree = "<group>"; };
636637
3820FFBE21E635D9001CAB32 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; };
638+
38C8069C24ADBF4C0074D3D6 /* CocoaDebugAutoLaunch.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CocoaDebugAutoLaunch.m; sourceTree = "<group>"; };
637639
40F90F747240AEF38DAF2F66 /* Pods-Example_Objc.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example_Objc.debug.xcconfig"; path = "Target Support Files/Pods-Example_Objc/Pods-Example_Objc.debug.xcconfig"; sourceTree = "<group>"; };
638640
5B384C55C2BBC4F20D5023A8 /* Pods_Example_ObjcTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example_ObjcTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
639641
72E88BCC9E1515242D629AFF /* Pods-Example_ObjcTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example_ObjcTests.release.xcconfig"; path = "Target Support Files/Pods-Example_ObjcTests/Pods-Example_ObjcTests.release.xcconfig"; sourceTree = "<group>"; };
@@ -721,8 +723,9 @@
721723
children = (
722724
38095C822414C61900382668 /* CocoaDebug.swift */,
723725
38095C832414C61900382668 /* CocoaDebugSettings.swift */,
724-
38095C842414C61900382668 /* CocoaDebug.h */,
725726
38095C852414C61900382668 /* CocoaDebug+Extensions.swift */,
727+
38095C842414C61900382668 /* CocoaDebug.h */,
728+
38C8069C24ADBF4C0074D3D6 /* CocoaDebugAutoLaunch.m */,
726729
);
727730
path = Core;
728731
sourceTree = "<group>";
@@ -1628,6 +1631,7 @@
16281631
38095EC92414C61900382668 /* CocoaDebugTabBarController.swift in Sources */,
16291632
38095DEE2414C61900382668 /* Device.swift in Sources */,
16301633
38095EC52414C61900382668 /* Bubble.swift in Sources */,
1634+
38C8069D24ADBF4C0074D3D6 /* CocoaDebugAutoLaunch.m in Sources */,
16311635
38095ECA2414C61900382668 /* CocoaDebugWindow.swift in Sources */,
16321636
38095EAD2414C61900382668 /* _CacheStoragePolicy.m in Sources */,
16331637
38095DE32414C61900382668 /* CocoaDebugSettings.swift in Sources */,

Example_Objc/AppDelegate.m

+18-20
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,24 @@ @implementation AppDelegate
1818
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1919

2020
#ifdef DEBUG
21-
/*
22-
//If Use Google's Protocol buffers
23-
CocoaDebug.protobufTransferMap = @{
24-
@"your_api_keywords_1": @"your_protobuf_className_1",
25-
@"your_api_keywords_2": @"your_protobuf_className_2",
26-
@"your_api_keywords_3": @"your_protobuf_className_3"
27-
};
28-
29-
//Custom CocoaDebug Settings
30-
CocoaDebug.serverURL = @"google.com";
31-
CocoaDebug.ignoredURLs = @[@"aaa.com", @"bbb.com"];
32-
CocoaDebug.onlyURLs = @[@"ccc.com", @"ddd.com"];
33-
CocoaDebug.tabBarControllers = @[[UIViewController new], [UIViewController new]];
34-
CocoaDebug.logMaxCount = 1000;
35-
CocoaDebug.emailToRecipients = @[@"[email protected]", @"[email protected]"];
36-
CocoaDebug.emailCcRecipients = @[@"[email protected]", @"[email protected]"];
37-
CocoaDebug.mainColor = @"#fd9727";
38-
*/
39-
40-
[CocoaDebug enable];
21+
/*
22+
//--- If Use Google's Protocol buffers ---
23+
CocoaDebug.protobufTransferMap = @{
24+
@"your_api_keywords_1": @[@"your_protobuf_className_1"],
25+
@"your_api_keywords_2": @[@"your_protobuf_className_2"],
26+
@"your_api_keywords_3": @[@"your_protobuf_className_3"]
27+
};
28+
29+
//--- If Want to Custom CocoaDebug Settings ---
30+
CocoaDebug.serverURL = @"google.com";
31+
CocoaDebug.ignoredURLs = @[@"aaa.com", @"bbb.com"];
32+
CocoaDebug.onlyURLs = @[@"ccc.com", @"ddd.com"];
33+
CocoaDebug.tabBarControllers = @[[UIViewController new], [UIViewController new]];
34+
CocoaDebug.logMaxCount = 1000;
35+
CocoaDebug.emailToRecipients = @[@"[email protected]", @"[email protected]"];
36+
CocoaDebug.emailCcRecipients = @[@"[email protected]", @"[email protected]"];
37+
CocoaDebug.mainColor = @"#fd9727";
38+
*/
4139
#endif
4240

4341
return YES;

Example_Swift.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
383CB06221E5F58500398720 /* index2.html in Resources */ = {isa = PBXBuildFile; fileRef = 383CB06121E5F58500398720 /* index2.html */; };
269269
3849FEA521E5E1DD00662E95 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 3849FEA421E5E1DD00662E95 /* index.html */; };
270270
3875C6FA228F1A4800F6B626 /* WKWebViewTestController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3875C6F9228F1A4800F6B626 /* WKWebViewTestController.swift */; };
271+
38C806A124ADCF350074D3D6 /* CocoaDebugAutoLaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 38C806A024ADCF350074D3D6 /* CocoaDebugAutoLaunch.m */; };
271272
EA1659D7204D1B14001472C1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1659D6204D1B14001472C1 /* AppDelegate.swift */; };
272273
EA1659D9204D1B14001472C1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1659D8204D1B14001472C1 /* ViewController.swift */; };
273274
EA1659DC204D1B14001472C1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EA1659DA204D1B14001472C1 /* Main.storyboard */; };
@@ -692,6 +693,7 @@
692693
3849FEA421E5E1DD00662E95 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; };
693694
3875C6F9228F1A4800F6B626 /* WKWebViewTestController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKWebViewTestController.swift; sourceTree = "<group>"; };
694695
38B5614D21CCC4CB00BB276A /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
696+
38C806A024ADCF350074D3D6 /* CocoaDebugAutoLaunch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocoaDebugAutoLaunch.m; sourceTree = "<group>"; };
695697
40B2F0D32DB860EF145358AC /* Pods_Example_Swift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example_Swift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
696698
506D66AD894FC6EC245D3A0C /* Pods_Example_SwiftTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example_SwiftTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
697699
66DEBA7E7D77775A307F16EE /* Pods_CocoaDebug.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CocoaDebug.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -842,8 +844,9 @@
842844
children = (
843845
38095A172414C5F300382668 /* CocoaDebug.swift */,
844846
38095A182414C5F300382668 /* CocoaDebugSettings.swift */,
845-
38095A192414C5F300382668 /* CocoaDebug.h */,
846847
38095A1A2414C5F300382668 /* CocoaDebug+Extensions.swift */,
848+
38095A192414C5F300382668 /* CocoaDebug.h */,
849+
38C806A024ADCF350074D3D6 /* CocoaDebugAutoLaunch.m */,
847850
);
848851
path = Core;
849852
sourceTree = "<group>";
@@ -1913,6 +1916,7 @@
19131916
380965612414DF9000382668 /* _GPBRootObject.m in Sources */,
19141917
38095C5C2414C5F400382668 /* CocoaDebugNavigationController.swift in Sources */,
19151918
38095C4E2414C5F400382668 /* _SandboxerHelper.m in Sources */,
1919+
38C806A124ADCF350074D3D6 /* CocoaDebugAutoLaunch.m in Sources */,
19161920
EAF58013204E73C3001CA56D /* Response.swift in Sources */,
19171921
EAF5800A204E73C3001CA56D /* MultipartFormData.swift in Sources */,
19181922
38095C382414C5F400382668 /* _HttpModel.m in Sources */,

Example_Swift/AppDelegate.swift

+18-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1616
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1717

1818
#if DEBUG
19-
CocoaDebug.enable()
19+
/*
20+
//--- If Use Google's Protocol buffers ---
21+
CocoaDebug.protobufTransferMap = [
22+
"your_api_keywords_1": ["your_protobuf_className_1"],
23+
"your_api_keywords_2": ["your_protobuf_className_2"],
24+
"your_api_keywords_3": ["your_protobuf_className_3"]
25+
]
26+
27+
//--- If Want to Custom CocoaDebug Settings ---
28+
CocoaDebug.serverURL = "google.com"
29+
CocoaDebug.ignoredURLs = ["aaa.com", "bbb.com"]
30+
CocoaDebug.onlyURLs = ["ccc.com", "ddd.com"]
31+
CocoaDebug.tabBarControllers = [UIViewController.init(), UIViewController.init()]
32+
CocoaDebug.logMaxCount = 1000
33+
CocoaDebug.emailToRecipients = ["[email protected]", "[email protected]"]
34+
CocoaDebug.emailCcRecipients = ["[email protected]", "[email protected]"]
35+
CocoaDebug.mainColor = "#fd9727"
36+
*/
2037
#endif
2138

2239
return true

README.md

+10-48
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525

2626
- [x] Shake to hide or show the black bubble. (Support iPhone device and simulator)
2727

28-
- [x] List all `print()` and `NSLog()` messages which have been written by developer in Xcode.
29-
30-
- [x] List of all the network requests sent by the application. (Support `JSON` and Google's `Protocol buffers`)
31-
32-
- [x] List crash errors.
33-
3428
- [x] Share network details via email or copy to clipboard when you are in the *Network Details* page.
3529

3630
- [x] Copy logs. (Long press the text, then select all or select copy)
3731

3832
- [x] Search logs by keyword.
3933

34+
- [x] List crash errors.
35+
36+
- [x] List all `print()` and `NSLog()` messages which have been written by developer in Xcode.
37+
38+
- [x] List of all the network requests sent by the application. (Support `JSON` and Google's `Protocol buffers`)
39+
4040
- [x] List application and device informations, including: *version*, *build*, *bundle name*, *bundle id*, *screen resolution*, *device*, *iOS version*
4141

4242
- [x] List all sandbox folders and files, supporting to preview and edit.
@@ -68,49 +68,11 @@ github "CocoaDebug/CocoaDebug"
6868
6969
## Usage
7070

71-
### Swift
72-
73-
//AppDelegate.swift
74-
75-
#if DEBUG
76-
import CocoaDebug
77-
#endif
78-
79-
#if DEBUG
80-
//If Use Google's Protocol buffers
81-
CocoaDebug.protobufTransferMap = [
82-
"your_api_keywords_1": ["your_request_protobuf_className_1", "your_response_protobuf_className_1"],
83-
"your_api_keywords_2": ["your_request_protobuf_className_2", "your_response_protobuf_className_2"],
84-
"your_api_keywords_3": ["your_request_protobuf_className_3", "your_response_protobuf_className_3"]
85-
]
86-
CocoaDebug.enable()
87-
#endif
88-
89-
public func print<T>(file: String = #file, function: String = #function, line: Int = #line, _ message: T, color: UIColor = .white) {
90-
#if DEBUG
91-
swiftLog(file, function, line, message, color, false)
92-
#endif
93-
}
94-
95-
### Objective-C
96-
97-
//AppDelegate.m
98-
99-
#ifdef DEBUG
100-
@import CocoaDebug;
101-
#endif
102-
103-
#ifdef DEBUG
104-
//If Use Google's Protocol buffers
105-
CocoaDebug.protobufTransferMap = @{
106-
@"your_api_keywords_1": @[@"your_request_protobuf_className_1", @"your_response_protobuf_className_1"],
107-
@"your_api_keywords_2": @[@"your_request_protobuf_className_2", @"your_response_protobuf_className_2"],
108-
@"your_api_keywords_3": @[@"your_request_protobuf_className_3", @"your_response_protobuf_className_3"]
109-
};
110-
[CocoaDebug enable];
111-
#endif
71+
Launch application and debug with `CocoaDebug `.
72+
73+
Have Fun! 😀😀😀
11274

113-
### More
75+
### More Advanced Usage
11476

11577
#ifdef DEBUG
11678
[CocoaDebugTool logWithString:string];

Sources/App/AboutViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AboutViewController: UITableViewController {
2828
naviItem.titleView = naviItemTitleLabel
2929

3030

31-
let version = "1.2.8"
31+
let version = "1.2.9"
3232

3333
self.versionLabel.text = "CocoaDebug Version ".appending(version)
3434

Sources/Core/CocoaDebug.h

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Created by man.li on 11/11/2018.
66
// Copyright © 2020 man.li. All rights reserved.
77
//
8-
//
98

109
#import "CocoaDebug.h"
1110
#import "CocoaDebugTool.h"

Sources/Core/CocoaDebugAutoLaunch.m

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
https://developer.apple.com/forums/thread/61432
3+
4+
--- The Issue: ---
5+
6+
When user touch down on a view contains gestureRecognizers, abort will called:
7+
8+
Assertion failure in -[UIGestureGraphEdge initWithLabel:sourceNode:targetNode:directed:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3599.6/Source/GestureGraph/UIGestureGraphEdge.m:25
9+
10+
--- Reason: ---
11+
12+
If I create view and setup gestures in some class's +(void)load method, the issue will occur.
13+
14+
Since +(void)load method is called way before application finish launching,
15+
16+
I suspect this is due to the UIGestureRecognizer's global enviroment is not set up yet.
17+
18+
--- Solve: ---
19+
20+
Delay the creation of the view, such as put it in the applicationDidFinishLaunching callback.
21+
*/
22+
23+
#pragma GCC diagnostic push
24+
#pragma GCC diagnostic ignored "-Wundeclared-selector"
25+
26+
#import <Foundation/Foundation.h>
27+
#import <UIKit/UIKit.h>
28+
29+
@implementation NSObject (CocoaDebugAutoLaunch)
30+
31+
+ (void)load {
32+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidFinishLaunching) name:UIApplicationDidFinishLaunchingNotification object:nil];
33+
}
34+
35+
- (void)applicationDidFinishLaunching {
36+
Class CocoaDebug = [NSObject swiftClassFromString:(@"CocoaDebug")];
37+
[[CocoaDebug class] performSelector:@selector(enable)];
38+
}
39+
40+
- (Class)swiftClassFromString:(NSString *)className {
41+
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
42+
NSString *classStringName = [NSString stringWithFormat:@"_TtC%lu%@%lu%@", (unsigned long)appName.length, appName, (unsigned long)className.length, className];
43+
return NSClassFromString(classStringName);
44+
}
45+
46+
@end
47+
48+
#pragma GCC diagnostic pop

0 commit comments

Comments
 (0)