如何在CocoaPods中制作含有ARC和MRC工程的SPEC
- 目前工程中引用了一些三方库是MRC的,并且是以COPY源码的方式
- 70%的源码是MRC的
希望有一种方式能够在SPEC中配置混编ARC,MRC
祥瑞雪风号
10 years, 3 months ago
Answers
使用
subspec
(子模块配置),每个子模块中可以各自设置,决定是否使用
ARC
详细说明看一下官方文档
Podspec Syntax Reference
下面是一个例子,做的是百度地图2.8的API,其中我扩展了一些方法。
例子中,其中
BaiduMapAPI/Core
不支持
ARC
,
BaiduMapAPI/Extend
支持
ARC
,默认加载
All
,
All
中依赖
BaiduMapAPI/Core
和
BaiduMapAPI/Extend
这样就可以在默认情况下将完整的库引入项目:
Pod::Spec.new do |s|
s.name = 'BaiduMapAPI'
s.version = '2.8.0'
s.license = { :type => 'Copyright', :text => 'LICENSE ©2013 Baidu, Inc. All rights reserved.' }
s.summary = 'Baidu Map API For iOS.'
s.homepage = 'http://developer.baidu.com/map/index.php?title=iossdk'
s.authors = { 'Steven' => '[email protected]' }
s.source = { :git => 'https://github.com/qzs21/BaiduMapAPI.git', :tag => s.version }
s.ios.deployment_target = '5.0'
s.default_subspec = 'All'
s.subspec 'All' do |spec|
spec.ios.dependency 'BaiduMapAPI/Core'
spec.ios.dependency 'BaiduMapAPI/Extend'
end
s.subspec 'Core' do |spec|
spec.requires_arc = false
spec.compiler_flags = '-ObjC'
spec.resources = 'Framework/Resources/mapapi.bundle'
spec.ios.vendored_frameworks = 'Framework/BaiduMapAPI.framework'
spec.public_header_files = [
'Framework/BaiduMapAPI.framework/Headers/*.h'
]
spec.frameworks = [
'UIKit',
'CoreLocation',
'QuartzCore',
'OpenGLES',
'SystemConfiguration',
'CoreGraphics',
'Security'
]
spec.libraries = [
"stdc++",
"stdc++.6"
]
end
s.subspec 'Extend' do |spec|
spec.requires_arc = true
spec.public_header_files = [
'Framework/Extend/*.h'
]
spec.source_files = [
'Framework/Extend/*.{h,mm,m}'
]
spec.ios.dependency 'BaiduMapAPI/Core'
end
end
可爱哒小鱼人
answered 10 years, 3 months ago