iOS开发-1 安装组件|snapkit安装使用

1,000 阅读1分钟

安装cocoapods

gem install cocoapods

生成podfile

进入创建工程的目录,输入如下命令,生成podfile

pod init

image.png

修改podfile

如果使用swift5.0, 将版本换成5.0.0 如果使用swift4.0,将版本换成4.0.0

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'demo_autoLayout' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for demo_autoLayout
  pod 'SnapKit', '~> 5.0.0'

end

运行安装

输入如下命令,安装sanpkit

pod install

安装后,项目结构变成如下

image-20210312143324372

注意!以后打开项目要打开xcworkspace!