Return of missing persons

Componentization has been used for a period of time, encountered a lot of problems, but it can be considered to be solved. To sum up some problems of manual introduction of third-party components, I have not practiced the solution method of Swift and OC. Podspec is mainly composed of subspec methods, including wechat, Alipay, Weibo, Aurora, and Umeng

WeChat

Wechat needs to introduce.a and.h files

H files use source_files

A files use vendored_libraries

The original directory is as follows

Pod::Spec.new do |s|
  s.name             = 'xxx-BaseCore'
  s.version          = '1.0.7'
  s.summary          = 'Base components'

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = << -desc Base component DESC

  s.homepage         = 'homepage'
  s.license          = { :type= >'MIT'.:file= >'LICENSE' }
  s.author           = { '[email protected]'= >'[email protected]' }
  s.source           = { :git= >'[email protected]'.:tag => s.version.to_s }

  s.ios.deployment_target = '11.0'
  s.swift_version = '5.0'
  s.source_files = 'xxx-BaseCore/Classes/**/*'
  s.default_subspec = "Core"

  s.resource_bundles = {
          'xxx-BaseCore'= > ['xxx-BaseCore/Assets/*{.storyboard,.xcassets}'.'xxx-BaseCore/Assets/**/*']
  }
  s.static_framework = true
  s.frameworks = 'UIKit'
  
  # Core modules
  s.subspec 'Core' do |subspec|
    subspec.dependency 'RxSwift'                  , '4.5.0'
    subspec.dependency 'RxGesture'                , '2.2.0'
    subspec.dependency 'RxDataSources'            , '3.1.0'
    subspec.dependency 'Moya/RxSwift'             , '13.0'
    subspec.dependency 'ObjectMapper'             , '3.4.2'
  end
  
  # wechat module
  s.subspec 'WXManager' do |subspec|
    subspec.dependency 'xxx-BaseCore/Core'
    subspec.frameworks = 'CFNetwork'.'CoreMotion'.'Foundation'.'CoreGraphics'.'SystemConfiguration'.'UIKit'.'CoreText'.'QuartzCore'.'CoreTelephony'
    subspec.libraries = 'z'.'sqlite3.0'.'c++'
    subspec.source_files = 'xxx-BaseCore/WXManager/*.h'
    subspec.vendored_libraries = 'xxx-BaseCore/WXManager/libWeChatSDK.a'
  end

end

Copy the code

Alipay

Alipay needs to introduce.framework and.h files

The catalogue is consistent with wechat

.framework files use vendored_frameworks

H file usagesource_filesThe important thing is to include all the.h files in the framework

  # Alipay module
  s.subspec 'AliPayManager' do |subspec|
    subspec.dependency 'xxx-BaseCore/Core'
    subspec.frameworks = 'CFNetwork'.'CoreMotion'.'Foundation'.'CoreGraphics'.'SystemConfiguration'.'UIKit'.'CoreText'.'QuartzCore'.'CoreTelephony'
    subspec.libraries = 'z'.'sqlite3.0'.'c++'
    subspec.source_files = 'xxx-BaseCore/AliPayManager/*'.'xxx-BaseCore/AliPayManager/AlipaySDK.framework/Headers/*.h'
    subspec.vendored_frameworks = 'xxx-BaseCore/AliPayManager/AlipaySDK.framework'
    subspec.resources = ['xxx-BaseCore/AliPayManager/AlipaySDK.bundle']

  end
Copy the code

weibo

Basically the same as wechat, but it should be noted that the need to add resource files

# Microblog module
  s.subspec 'WeiboManager' do |subspec|
    subspec.dependency 'xxx-BaseCore/Core'
    subspec.frameworks = 'CFNetwork'.'CoreMotion'.'Foundation'.'CoreGraphics'.'SystemConfiguration'.'UIKit'.'CoreText'.'QuartzCore'.'CoreTelephony'
    subspec.libraries = 'z'.'sqlite3.0'.'c++'
    subspec.source_files = 'xxx-BaseCore/WeiboManager/*.h'
    subspec.vendored_libraries = 'xxx-BaseCore/WeiboManager/libWeiboSDK.a'
    subspec.resources = ['xxx-BaseCore/WeiboManager/WeiboSDK.bundle']
  end
Copy the code

The aurora

Basically consistent with wechat, but to live is the need to add resource files

The. A file downloaded from the official website may not be named properly and needs to be renamed

  # Aurora push module
  s.subspec 'JPush' do |subspec|
    subspec.dependency 'xxx-BaseCore/Core'
    subspec.frameworks = 'CFNetwork'.'CoreFoundation'.'CoreTelephony'.'SystemConfiguration'.'CoreGraphics'.'Foundation'.'UIKit'.'Security'.'UserNotifications'
    subspec.libraries = 'z'.'resolv'
    subspec.source_files = 'xxx-BaseCore/JPush/*.h'
    subspec.vendored_libraries = 'XXX - BaseCore/JPush/libjcore - noidfa - ios - 2.1.4. A'.'XXX to XXX/JPush/libjpush - the extension - ios - 1.1.2. A'.'XXX - BaseCore JPush/libjpush - ios - 3.2.6. A'
  end
Copy the code

Their Allies

The situation of Umeng is special, mainly because there are some troubles in the integration of Swift, and it takes a lot of data to get it done

The directory structure

The short answer is increaseprepare_commandCreate the ModuleMap for Swift

What I integrate is Facebook and wechat of Umeng


s.prepare_command = < < - EOF # create UMCommon Module rm - rf/Umeng UMCommon XXX. Framework/Modules/mkdir XXX Umeng/UMCommon framework/Modules touch xxx/Umeng/UMCommon.framework/Modules/module.modulemap cat <<-EOF > xxx/Umeng/UMCommon.framework/Modules/module.modulemap
    framework module UMCommon {
      umbrella header "UMCommon.h"
      export *
      link "sqlite3.0"
    }
    \EOF
    
    Create UMShare Module
    rm -rf xxx/Umeng/UMShare.framework/Modules
    mkdir xxx/Umeng/UMShare.framework/Modules
    touch xxx/Umeng/UMShare.framework/Modules/module.modulemap
    cat <<-EOF > xxx/Umeng/UMShare.framework/Modules/module.modulemap
    framework module UMShare {
      umbrella header "UMShare.h"
      export *
      link "sqlite3.0"
    }
    \EOF
  EOF
Copy the code

Submodule content

  # Allies
  s.subspec 'Umeng' do |subspec|
      subspec.dependency 'xxx/Core'
      subspec.frameworks = 'CFNetwork'.'CoreMotion'.'Foundation'.'CoreGraphics'.'SystemConfiguration'.'UIKit'.'CoreText'.'QuartzCore'.'CoreTelephony'.'WebKit'
      subspec.libraries = 'z'.'sqlite3.0'.'c++'
      subspec.resources = [
      'xxx/Umeng/UMSocialSDKResources.bundle'
      ]
      subspec.source_files = 'xxx/Umeng/*'

      subspec.vendored_frameworks = [
      'xxx/Umeng/*.framework'.'xxx/Umeng/SocialLibraries/Facebook/*.framework'
      ]
      
      subspec.vendored_libraries = [
      'xxx/Umeng/SocialLibraries/Facebook/libSocialFacebook.a'.'xxx/Umeng/SocialLibraries/WeChat/libSocialWeChat.a'
      ]
  end
Copy the code