README.md 4.4 KB
Newer Older
Y
yixiang 已提交
1 2
<div  align="center">    
 <img src="https://javer.oss-cn-shanghai.aliyuncs.com/doraemon/github/DoraemonKit_github.png" width = "150" height = "150" alt="图片名称" align=left />
Y
yixiang 已提交
3 4 5 6 7 8 9
</div>

<br/>
<br/>
<br/>
<br/>
<br/>
Y
yixiang 已提交
10 11
<br/>
<br/>
Y
yixiang 已提交
12

Y
yixiang 已提交
13
A collection of testing tools for iOS App development.
Y
yixiang 已提交
14

Y
readme  
yixiang 已提交
15 16
[Chinese Readme](https://github.com/didi/DoraemonKit/blob/master/Doc/ChineseReadme.md)

Y
readme  
yixiang 已提交
17
## Feature List
Y
yixiang 已提交
18

Y
yixiang 已提交
19 20 21 22 23 24 25 26 27
1. Including an entrance to examine information of device, app and app's permissions.
2. Including a file browser, with a convenient way to transfer file through airDrop.
3. Including a tool for mocking GPS location.
4. Including a built-in web browser.
5. Including a log printer, with every log printed in app
6. Including profilers for App's FPS, CPU usage, memory usage and network traffic. All of them are shown in charts and can be saved for further analysis.
7. Including a color picker, obtaining color values of every pixel in an easy manner.
8. Including a UI viewer, obtaining properties, such as name, position, background color and font size, of every view.
9. Including a coordinate ruler, a useful tool to acquire screen coordinates and to check the alignment of views.
Y
yixiang 已提交
28

Y
readme  
yixiang 已提交
29
## Feature Demonstration
Y
yixiang 已提交
30
<div  align="center">    
Y
readme  
yixiang 已提交
31
 <img src="https://javer.oss-cn-shanghai.aliyuncs.com/doraemon/github/DoraemonPanel.jpeg" width = "300" height = "565" alt="图片名称" align=center />
Y
yixiang 已提交
32
</div>
Y
yixiang 已提交
33
tips: Tools in the top two lines are user-defined. Others are built-in.
Y
yixiang 已提交
34 35 36 37 38 39 40 41

## How To Use
### 1: Use Cocoapods to Get latest version of DoraemonKit

DoraemonKit contains two subspecs.
One is the "WithLogger" subspec that contains the log display  function based on ‘CocoaLumberjack’.

```
Y
readme  
yixiang 已提交
42
pod 'DoraemonKit/WithLogger'
Y
yixiang 已提交
43 44 45 46 47
```

The other one is the "Core" subspec that does not contain the log display function.

```
Y
readme  
yixiang 已提交
48
pod 'DoraemonKit/Core'
Y
yixiang 已提交
49 50 51 52 53 54
```

The "Core" subspec is introduced by default.

Tip: Why do you want to partition the subspec?

Y
yixiang 已提交
55
Because the log display module is based on the third-party library "CocoaLumberjack", if you don't need it, use "Core" subspec.
Y
yixiang 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

### 2: Access method using DoraemonKit's built-in toolset
Add code when the app starts.

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    #ifdef DEBUG
        [[DoraemonManager shareInstance] addH5DoorBlock:^(NSString *h5Url) {
              //Open this link with your H5 container
        }];

        [[DoraemonManager shareInstance] install];
    #endif
}
```

Y
yixiang 已提交
72
  Through the above steps you can use all of the built-in tools of DorameonKit. If you want to add some of your customized tools, see chapter 3.
Y
yixiang 已提交
73
  
Y
yixiang 已提交
74 75
### 3: Add a custom test module to the Doraemon panel (non-essential)
For example, we want to add an environment switch module to the Doraemon panel.
Y
yixiang 已提交
76

Y
yixiang 已提交
77
Step 1: create a new class, implement the pluginDidLoad method in the KDDoraemonPluginProtocol protocol, this method is to be called when the "Environment Switch" button is clicked.
Y
yixiang 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

Taking our app as an example, after clicking the button, it will enter the environment switching page.

```
@implementation KDDoraemonEnvPlugin
- (void)pluginDidLoad{
    [APP_INTERACOTR.rootNav openURL:@"KDSJ://KDDoraemonSFViewController"];
    [[DoraemonManager shareInstance] hiddenHomeWindow];
}
 @end
```
 
Step 2: Add the "Environment Switching" plugin added in the first step where Doraemon is initialized.


```
[[DoraemonManager shareInstance] addPluginWithTitle:@"环境切换" icon:@"qiehuang" desc:@"用于app内部环境切换功能" pluginName:@"KDDoraemonEnvPlugin" atModule:@"业务专区"];
```

Y
yixiang 已提交
97 98
It in turn shows the title, icon, description, plugin name, and the module it belongs to.

Y
yixiang 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
Take our App as an example:

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    #ifdef DEBUG
       [self configDoraemonKit];
    #endif
}
//Initialize the Doraemon toolset
- (void)configDoraemonKit{
    [[DoraemonManager shareInstance] addPluginWithTitle:@"环境切换" icon:@"qiehuang" desc:@"用于app内部环境切换功能" pluginName:@"KDDoraemonEnvPlugin" atModule:@"业务专区"];
    [[DoraemonManager shareInstance] addH5DoorBlock:^(NSString *h5Url) {
        [APP_INTERACOTR.rootNav openURL:@"KDSJ://KDWebViewController" withQuery:@{@"urlString":h5Url}];
    }];
    [[DoraemonManager shareInstance] install];
}
```

## Related documents

Y
readme  
yixiang 已提交
119
[Chinese Readme](https://github.com/didi/DoraemonKit/blob/master/Doc/ChineseReadme.md)
Y
yixiang 已提交
120 121 122 123