pod ipc 命令

Posted by Matt Reach on July 22, 2017

本篇博客介绍的是 pod ipc 命令,我们已经知道了 .podspec 文件是 ruby 格式的,在做自动化时,不容易去解析修改,因此可以通过 ipc 命令转为 json 格式,当然 cocoapods 也是支持 json 格式的 podspec 文件的。

pod ipc

先看下 ipc 二级命令支持了哪些参数吧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
➜  ~ pod ipc --help   
Usage:

    $ pod ipc COMMAND

      Inter-process communication

Commands:

    + list                  Lists the specifications known to CocoaPods
    + podfile               Converts a Podfile to YAML
    + podfile-json          Converts a Podfile to JSON
    + repl                  The repl listens to commands on standard input
    + spec                  Converts a podspec to JSON
    + update-search-index   Updates the search index

Options:

    --silent                Show nothing
    --verbose               Show more debugging information
    --no-ansi               Show output without ANSI codes
    --help                  Show help banner of specified command

可以看出共有 6 个命令,还可以加些可选参数,用于控制日志等

  • pod ipc spec

将 ruby 格式 的 podspec 文件转为 json 格式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pod ipc spec SCNetworkKit.podspec     
{
  "name": "SCNetworkKit",
  "version": "1.0.14",
  "summary": "SCNetworkKit is a simple but powerful iOS and OS X networking framework.",
  "description": "SCNetworkKit is a simple but powerful iOS and OS X networking framework,based on NSURLSession and NSURLSessionConfiguration, written by Objective-C, Support iOS 7+ ;",
  "homepage": "http://debugly.cn/SCNetworkKit/",
  "license": "MIT",
  "authors": {
    "qianlongxu": "qianlongxu@gmail.com"
  },
  "platforms": {
    "ios": "7.0",
    "osx": "10.10"
  },
  "source": {
    "git": "https://github.com/debugly/SCNetworkKit.git",
    "tag": "1.0.14"
  },
  "source_files": "SCNetworkKit/Classes/**/*.{h,m}",
  "requires_arc": true
}
  • pod ipc podfile

Podfile 转为 YAML 格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
✗ pod ipc podfile Podfile     
---
installation_method:
  name: cocoapods
  options:
    :generate_multiple_pod_projects: true
workspace: SHVideoPlayer.xcworkspace
sources:
  - "git@code.debugly.com:ifox/Pods_Specs.git"
  - https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
target_definitions:
  - abstract: true
    children:
      - dependencies:
          - KVOController_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - MRFoundation_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - VLCKit
        name: MRMoviePlayerKit
        user_project_path: MRMoviePlayerKit/MRMoviePlayerKit
      - dependencies:
          - MRFoundation_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SCHTTPServer_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SCJSONUtil_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SCNetworkKit_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
        name: LaunchHelper
        user_project_path: SHVideoPlayer/SHVideoPlayer.xcodeproj
      - dependencies:
          - Crashlytics
          - Fabric
          - GCDWebServer_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - KVOController_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - Masonry_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - MMKV_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - MRFoundation_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SAMKeychain_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SCJSONUtil_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SCNetworkKit_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SDWebImage_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - SSZipArchive_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
          - VLCKit
          - xxtea_B:
            - :path: "./Pods_Static_Agent/Pods_Spec"
        name: SHPlayer
        user_project_path: SHVideoPlayer/SHVideoPlayer.xcodeproj
    name: Pods
    platform:
      osx: '10.10'
    uses_frameworks: true
  • pod ipc podfile-json

Podfile 转为 JSON 格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
pod ipc podfile-json Podfile
{
    "target_definitions": [
        {
            "name": "Pods",
            "abstract": true,
            "platform": {
                "osx": "10.10"
            },
            "uses_frameworks": true,
            "children": [
                {
                    "name": "MRMoviePlayerKit",
                    "user_project_path": "MRMoviePlayerKit/MRMoviePlayerKit",
                    "dependencies": [
                        {
                            "KVOController_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        "VLCKit",
                        {
                            "MRFoundation_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "LaunchHelper",
                    "user_project_path": "SHVideoPlayer/SHVideoPlayer.xcodeproj",
                    "dependencies": [
                        {
                            "SCNetworkKit_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "SCJSONUtil_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "SCHTTPServer_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "MRFoundation_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "SHPlayer",
                    "user_project_path": "SHVideoPlayer/SHVideoPlayer.xcodeproj",
                    "dependencies": [
                        {
                            "SCNetworkKit_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "SCJSONUtil_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "SSZipArchive_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "SDWebImage_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "Masonry_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "GCDWebServer_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "MMKV_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "xxtea_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "KVOController_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        {
                            "SAMKeychain_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        },
                        "VLCKit",
                        "Fabric",
                        "Crashlytics",
                        {
                            "MRFoundation_B": [
                                {
                                    "path": "./Pods_Static_Agent/Pods_Spec"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "sources": [
        "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git",
        "git@code.debugly.com:ifox/Pods_Specs.git"
    ],
    "workspace": "SHVideoPlayer.xcworkspace",
    "installation_method": {
        "name": "cocoapods",
        "options": {
            "generate_multiple_pod_projects": true
        }
    }
}

参考