iOS 多 Target CocoaPods 管理
xxxixxxx

1. iOS 多 Target CocoaPods 管理,直接来看例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
platform :ios, "11.0"
source "https://cdn.cocoapods.org/"
#source 'https://github.com/CocoaPods/Specs.git'

#定义公共库
def commonPods
use_frameworks!

pod "KakaJSON", "~> 1.1.2"
pod "SnapKit", "~> 5.0.1"
end

#为 Target1 配置自己独有的库
target "Target1" do
commonPods
pod "YYCategories"
pod "Alamofire", "~> 5.2.2"
end
#为 Target2 配置自己独有的库
target "Target2" do
commonPods
pod "Moya", "~> 14.0.0"
end

2. 判断在哪一个 Target,iOS Target 判断

Swift 设置

Build Settings 搜索 swift compiler 具体看图
添加 Target 判断条件

使用

1
2
3
#if MAINTARGET
tipLab.text = "mmmm"
#endif

OC 设置

Build Settings 搜索 macros 具体看图
OC 操作图

使用

1
2
3
 #ifdef TARGETMAIN
NSLog(@"=======TARGETMAIN=======");
#endif
  • Post title:iOS 多 Target CocoaPods 管理
  • Post author:xxxixxxx
  • Create time:2020-11-28 00:00:00
  • Post link:https://xxxixxx.github.io/2020/11/28/500-iOS-多-Target-CocoaPods-管理/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments