README.md 4.4 KB
Newer Older
Y
yixiang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
## DoraemonKit

<div  align="center">    
 <img src="https://javer.oss-cn-shanghai.aliyuncs.com/doraemon/openSource/doraemon.jpeg" width = "150" height = "100" alt="图片名称" align=left />
</div>

<br/>
<br/>
<br/>
<br/>
<br/>
<br/>


Y
yixiang 已提交
15
A collection of testing tools for iOS App development.
Y
yixiang 已提交
16

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

Y
yixiang 已提交
19 20
## Function List

Y
yixiang 已提交
21 22 23 24 25 26 27 28 29
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 已提交
30 31 32

## Function Show
<div  align="center">    
Y
readme  
yixiang 已提交
33
 <img src="https://javer.oss-cn-shanghai.aliyuncs.com/doraemon/openSource/github/DoraemonKit.png" width = "300" height = "565" alt="图片名称" align=center />
Y
yixiang 已提交
34
</div>
Y
yixiang 已提交
35
tips: Tools in the top two lines are user-defined. Others are built-in.
Y
yixiang 已提交
36 37 38 39 40 41 42 43

## 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 已提交
44
pod 'DoraemonKit/WithLogger', '~> 1.0.0'
Y
yixiang 已提交
45 46 47 48 49
```

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

```
Y
readme  
yixiang 已提交
50
pod 'DoraemonKit/Core', '~> 1.0.0'
Y
yixiang 已提交
51 52 53 54 55 56
```

The "Core" subspec is introduced by default.

Tip: Why do you want to partition the subspec?

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

### 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 已提交
74
  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 已提交
75
  
Y
yixiang 已提交
76 77
### 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 已提交
78

Y
yixiang 已提交
79
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 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

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 已提交
99 100
It in turn shows the title, icon, description, plugin name, and the module it belongs to.

Y
yixiang 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
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 已提交
121
[Chinese Readme](https://github.com/didi/DoraemonKit/blob/master/Doc/ChineseReadme.md)
Y
yixiang 已提交
122 123 124 125