search

Home  >  Q&A  >  body text

ios - 如何在CocoaPods中制作含有ARC和MRC工程的SPEC

希望有一种方式能够在SPEC中配置混编ARC,MRC

迷茫迷茫2772 days ago932

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-17 15:17:33

    Use subspec (submodule configuration), each submodule can be set separately to decide whether to use ARC
    For detailed instructions, take a look at the official document Podspec Syntax Reference
    The following is an example using the API of Baidu Map 2.8, in which I extended some methods.
    In the example, BaiduMapAPI/Core does not support ARC, BaiduMapAPI/Extend supports ARC, and All is loaded by default. All depends on BaiduMapAPI/Core and BaiduMapAPI/Extend so that the complete library can be loaded by default Introducing projects:

    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' => 'qzs21@qq.com' }
      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
    

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 15:17:33

    spec.ios.vendored_frameworks When I submit, it tells me that the file cannot be found with my path, however, the path is correct.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 15:17:33

    I specified the vendored_frameworks path in the spec file and there was no problem. But when I compiled the project, it prompted file not found. How can I solve it?

    reply
    0
  • Cancelreply