Cocoapods
使用cocoapods 创建本地模块
pod spec create ModuleFoundation
会生成 'ModuleFoundation.podspec'
各字段含义请参考https://guides.cocoapods.org/making/private-cocoapods.html
Example:
Pod::Spec.new do |spec|
spec.name = "ModuleFoundation"
spec.version = "1.0.0.#{Time.now.to_i}"
spec.summary = "Foundation Module"
spec.description = "Foundation Module"
spec.homepage = "https://zliucode.github.io"
spec.license = "MIT"
spec.author = { "zliuCode" => "gdlck1993@outlook.com" }
spec.source = { :git => "https://zliucode.github.io/ModuleFoundation.git", :tag => "#{spec.version}" }
spec.source_files = 'ModuleFoundation/Code/**/*.{h,m,swift}'
spec.platform = :ios, '11.0'
spec.swift_versions = ['5.0']
spec.test_spec 'Tests' do |test_spec|
test_spec.requires_app_host = true
test_spec.source_files = 'ModuleFoundation/UnitTests/*.{h,m,swift}'
end
end
#{Time.now.to_i} 目的是为了让pod update 时更新到最新的代码
在主项目中:
Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
ARGV.each do|command|
if command == "install" then
print "\nPlease always run `pod update`\n\n"
Process.exit!(true)
end
end
platform :ios, '11.0'
use_frameworks!
MODULE_ROOT = 'Modules'
LIBRARIES_ROOT = 'Libraries'
def core_frameworks_dependencies
# 在这里引入核心模块
pod 'ModuleFoundation', :path => LIBRARIES_ROOT, :testspecs => ['Tests']
end
def module_dependencies
# 在这里引入你的功能模块
end
target 'ModularizationSample' do
# Comment the next line if you don't want to use dynamic frameworks
core_frameworks_dependencies
# Pods for ModularizationSample
target 'ModularizationSampleTests' do
inherit! :search_paths
# Pods for testing
end
target 'ModularizationSampleUITests' do
# Pods for testing
end
end
其他Module 按照上面创建并引入。