iOS组件化

  1. 创建Podfileworksspace
mkdir myapps
cd myapps
vs Podfile
  1. myapps文件夹下新建两个项目app1, app2
  2. 编写Podfile,并执行pod install
# platform :ios, '10.0'
use_frameworks!
workspace 'myapps'

def shared_pods
  pod 'SwiftComponents', :git => 'https://github.com/LZRight123/SwiftComponents.git'
end

target 'app1' do
  project 'app1/app1.xcodeproj'

  shared_pods
end


target 'app2' do
  project 'app2/app2.xcodeproj'

  shared_pods
end
  1. 打开myaaps.worksspace,在两个项目的vc里写上代码 运行看效果
import SwiftComponents

view.backgroundColor = .random