|
| 1 | +## cocoapods plugins |
| 2 | + |
| 3 | + |
| 4 | +> sudo gem update --system |
| 5 | +
|
| 6 | +> podfile : plugin 'plugin name' |
| 7 | +
|
| 8 | +> install:`$ sudo gem plugin name` |
| 9 | +
|
| 10 | +- binary |
| 11 | +- dependencies |
| 12 | +- cocoapods-user-defined-build-types |
| 13 | +- cocoapods-static-swift-framework |
| 14 | + |
| 15 | +### [cocoapods-binary ](https://github.com/leavez/cocoapods-binary/) |
| 16 | + |
| 17 | +- remote pod transfer to framework |
| 18 | + |
| 19 | +- sudo gem install cocoapods-binary |
| 20 | + |
| 21 | +### [cocoapods-pod-merge](https://github.com/grab/cocoapods-pod-merge) |
| 22 | + |
| 23 | +- group 业务拆分组合划分层 |
| 24 | + |
| 25 | +<details> |
| 26 | +<summary> 点击展开 </summary> |
| 27 | + |
| 28 | +> pod install 源码OK,二进制需要对应remote自身再桥接。 |
| 29 | +
|
| 30 | +- sudo gem install cocoapods-dependencies |
| 31 | + |
| 32 | +- This plugin requires a file called `MergeFile`. This is how it looks: |
| 33 | + - touch Gemfile |
| 34 | + - gem 'cocoapods-pod-merge' |
| 35 | + - bundle install |
| 36 | +- bundle exec pod install |
| 37 | + |
| 38 | +``` |
| 39 | +
|
| 40 | +group 'Networking' |
| 41 | + pod 'AFNetworking' |
| 42 | + pod 'SDWebImage' |
| 43 | +end |
| 44 | +
|
| 45 | +plugin 'cocoapods-pod-merge' |
| 46 | +
|
| 47 | +target 'MyApp' |
| 48 | + pod 'Networking', :path => 'MergedPods/Networking' |
| 49 | + pod 'UI', :path => 'MergedPods/UI' |
| 50 | +end |
| 51 | +
|
| 52 | +``` |
| 53 | +</details> |
| 54 | + |
| 55 | + |
| 56 | +### [pod-dependencies](https://github.com/segiddins/cocoapods-dependencies) |
| 57 | + |
| 58 | +> dependencies |
| 59 | +
|
| 60 | +- sudo gem install cocoapods-dependencies |
| 61 | + |
| 62 | + |
| 63 | +### [cocoapods-static-swift-framework](https://github.com/leavez/cocoapods-static-swift-framework) |
| 64 | + |
| 65 | +- sudo gem install cocoapods-static-swift-framework |
| 66 | + |
| 67 | +### [cocoapods-packager](https://github.com/CocoaPods/cocoapods-packager) |
| 68 | + |
| 69 | +> 只适用于远端库(本质从远端clone再处理) |
| 70 | +
|
| 71 | +- sudo gem install cocoapods-packager |
| 72 | + |
| 73 | +- your Gemfile:gem "cocoapods-packager" && bundle install |
| 74 | + |
| 75 | +- pod package name.podspec |
| 76 | + |
| 77 | +``` |
| 78 | +如果需要排除源码中依赖的第三方库,可以在打包命令中添加 --exclude-deps 选项。 |
| 79 | +//静态framework |
| 80 | +pod package name.podspec --force --no-mangle --embedded |
| 81 | +//静态.a |
| 82 | +pod package name.podspec --library --force |
| 83 | +// .a 调整 |
| 84 | +s.vendored_libraries = "Path/to/xxx.a" |
| 85 | +s.source_files = "xxx/**/*.h" |
| 86 | +
|
| 87 | +/强制覆盖之前已经生成过的二进制库 |
| 88 | +--force |
| 89 | +
|
| 90 | +//生成静态.framework |
| 91 | +--embedded |
| 92 | +
|
| 93 | +//生成静态.a |
| 94 | +--library |
| 95 | +
|
| 96 | +//生成动态.framework |
| 97 | +--dynamic |
| 98 | +
|
| 99 | +//动态.framework是需要签名的,所以只有生成动态库的时候需要这个BundleId |
| 100 | +--bundle-identifier |
| 101 | +
|
| 102 | +//不包含依赖的符号表,生成动态库的时候不能包含这个命令,动态库一定需要包含依赖的符号表。 |
| 103 | +--exclude-deps |
| 104 | +
|
| 105 | +//表示生成的库是debug还是release,默认是release。--configuration=Debug |
| 106 | +--configuration |
| 107 | +
|
| 108 | +--no-mangle |
| 109 | +//表示不使用name mangling技术,pod package默认是使用这个技术的。我们能在用pod package生成二进制库的时候会看到终端有输出Mangling symbols和Building mangled framework。表示使用了这个技术。 |
| 110 | +//如果你的pod库没有其他依赖的话,那么不使用这个命令也不会报错。但是如果有其他依赖,不使用--no-mangle这个命令的话,那么你在工程里使用生成的二进制库的时候就会报错:Undefined symbols for architecture x86_64。 |
| 111 | +
|
| 112 | +--subspecs |
| 113 | +
|
| 114 | +//如果你的pod库有subspec,那么加上这个命名表示只给某个或几个subspec生成二进制库,--subspecs=subspec1,subspec2。生成的库的名字就是你podspec的名字,如果你想生成的库的名字跟subspec的名字一样,那么就需要修改podspec的名字。 |
| 115 | +这个脚本就是批量生成subspec的二进制库,每一个subspec的库名就是podspecName+subspecName。 |
| 116 | +
|
| 117 | +--spec-sources |
| 118 | +
|
| 119 | +//一些依赖的source,如果你有依赖是来自于私有库的,那就需要加上那个私有库的source,默认是cocoapods的Specs仓库。--spec-sources=private,https://github.com/CocoaPods/Specs.git。 |
| 120 | +
|
| 121 | +``` |
| 122 | + |
| 123 | +### [cocoapods-user-defined-build-types](https://github.com/joncardasis/cocoapods-user-defined-build-types) |
| 124 | + |
| 125 | +- sudo gem install cocoapods-user-defined-build-types |
| 126 | + |
| 127 | +``` |
| 128 | +plugin 'cocoapods-user-defined-build-types' |
| 129 | +
|
| 130 | +enable_user_defined_build_types! |
| 131 | +
|
| 132 | +target "CoffeeApp" do |
| 133 | + pod 'Alamofire' |
| 134 | + pod "SwiftyJSON", :build_type => :dynamic_framework |
| 135 | + |
| 136 | +dynamic_library |
| 137 | +dynamic_framework |
| 138 | +static_library |
| 139 | +static_framework |
| 140 | +
|
| 141 | +``` |
0 commit comments