在swift中使用CocoaPods

在swift中使用CocoaPods和Objective-C中其实没啥区别,
在工程路径下使用,pod init 创建Profile文件
打开Profile文件,以下以添加SnapKit和Alamofire为例,在文件中写入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'CRWeiBo' do
pod 'SnapKit', '0.18.0'
pod 'Alamofire', '3.1.3'
end
target 'CRWeiBoTests' do
end
target 'CRWeiBoUITests' do
end

如profile前面提示的,如果在swift环境下添加use_frameworks!,因为我们是直接生成的Profile文件,所以直接取消上面那行注释就可以了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'CRWeiBo' do
pod 'SnapKit', '0.18.0'
pod 'Alamofire', '3.1.3'
end
target 'CRWeiBoTests' do
end
target 'CRWeiBoUITests' do
end

如果是自己手动创建的,则需要自己补上


注:版权声明:本文为博主原创文章,未经博主允许不得转载。