pod组件二进制开发示例

2019-10-17  本文已影响0人  conowen

建立组件工程

建立主workspace工程与组件的pod工程如(podLibTest)

多个模式共存

源码模式的podspec

s.xcconfig = { 'USER_HEADER_SEARCH_PATHS' => '$(PROJECT_DIR)/../Logger/** $(PROJECT_DIR)/../config/** $(PROJECT_DIR)/../Debug/Header' }

s.prefix_header_contents = '#import <UIKit/UIKit.h>'

源码、debug、release模式切换

组件的默认模式为release模式,开发者在主工程的时候可以通过不同方式的pod install来切换不同模式

SOURCE=1 pod install --no-repo-update//源码模式

上述指令把组件源码直接clone到主工程中调试,如果需要制定本地组件仓库的话,可以修改podfile文件

pod 'podLibTest', :path =>'~/workspace/MyComponent/podLibTest/'

DEBUG=1 pod install --no-repo-update//debug模式

RELEASE=1 pod install --no-repo-update//release模式

注意:每次push到主工程中的commit,一定要确保组件模式为默认(release模式)

源码模式的spec可以参考以下


Pod::Spec.new do |s|
s.name             = 'podLibTest'
s.version          = '1.0.20'
s.summary          = 'podLibTest'
s.description      = 'podLibTest组件源码+二进制库'
s.homepage         = 'http://git.test.com/MyComponent/podLibTest'
s.license          = { :type => 'MIT', :file => 'LICENSE' }
s.author           = { 'dzz' => 'test@google.com.cn' }
s.source           = { :git => 'ssh://git@git.test.com:8018/MyComponent/podLibTest.git', :tag => s.version.to_s }
# s.requires_arc     = true
s.platform         = :ios

s.ios.deployment_target = '8.0'


if ENV['SOURCE']
    puts '----- SOURCE MODE -----'
    s.default_subspec = 'All'
    s.subspec 'All' do |s|
        s.ios.dependency 'podLibTest/core'
        s.ios.dependency 'podLibTest/non_arc'
        s.prefix_header_contents = '#import <UIKit/UIKit.h>','#import <Foundation/Foundation.h>','#import <CocoaLumberjack/CocoaLumberjack.h>','#import "MyLogDefines.h"','#import "MyResult.h"','#import "MyConstants.h"','#import "MyLogMacro.h"'
        s.xcconfig = { 'USER_HEADER_SEARCH_PATHS' => '$(PROJECT_DIR)/../Logger/** $(PROJECT_DIR)/../config/** $(PROJECT_DIR)/../Debug/Header' }
    end

    s.subspec 'core' do |s|
        non_arc_files = 'podLibTest/Array/Foundation+Security.m','podLibTest/Regex/Regex.m'
        s.exclude_files = non_arc_files
        s.requires_arc            = true
        s.source_files = 'podLibTest/**/*.{h,m,mm}'

    end

    s.subspec 'non_arc' do |s|
        non_arc_files = 'podLibTest/Array/Foundation+Security.m','podLibTest/Regex/Regex.m'
        s.requires_arc            = false
        s.source_files = non_arc_files

    end

elsif ENV['DEBUG']
    puts '----- DEBUG MODE -----'
    s.vendored_frameworks = 'Products/debug/universal/podLibTest.framework'
elsif ENV['RELEASE']
    puts '----- RELEASE MODE -----'
    s.vendored_frameworks = 'Products/release/iphoneos/podLibTest.framework'
else
    puts '----- DEFAULT RELEASE MODE -----'
    s.vendored_frameworks = 'Products/release/iphoneos/podLibTest.framework'
end


s.libraries  = 'c++'
s.static_framework = true #声明静态库
s.user_target_xcconfig = {'OTHER_LDFLAGS' => '-ObjC'}
s.dependency 'ReactiveCocoa', '2.5'
s.dependency 'SAMKeychain', '1.5.2'
s.dependency 'TMCache', '2.1.0'
s.dependency 'YYCache', '1.0.3'

end

上一篇 下一篇

猜你喜欢

热点阅读