CocoaPodプライベートライブラリの使用方法

3343 ワード

  • 作成および構成方法
  • リモート・ウェアハウスへのプロジェクトの作成
    Gitee code.aliyun Github    
    

    ローカルインデックスライブラリの表示
    pod repo
    

    プライベートインデックスライブラリの追加
    pod repo add HKIJKVideo [email protected]:xxxx/HKIJKVideo
    
  • コンポーネントライブラリの作成
    コンポーネントライブラリテンプレートを使用した作成
    pod lib create HKIJKVideo
    

    コンポーネントコンテンツの追加
    HKIJKVideo->Class   ReplaceMe.m,       
    

    Specの変更
    Pod::Spec.new do |s|
      s.name             = 'HKIJKVideo'
      s.version          = '0.1.0'
      s.summary          = 'A short description of HKIJKVideo.'
    
      s.description      = < 'MIT', :file => 'LICENSE' }
        
     s.author           = { 'lefo720' => '[email protected]' }
     
    s.source           = { :git => '[email protected]:xxx/hkijkvideo.git', :tag => s.version.to_s }
    
    s.ios.deployment_target = '8.0'
    
    s.source_files = 'HKIJKVideo/Classes/*'
    
    s.resource_bundles = {
      'HKIJKVideo' => ['HKIJKVideo/Assets/**/*']
    }
    s.vendored_frameworks =  'HKIJKVideo/libs/IJKMediaFramework.framework'
    
    s.frameworks = 'UIKit', 'AudioToolbox', 'CoreAudio', 'CoreMedia', 'MediaPlayer', 'QuartzCore', 'OpenGLES', 'VideoToolbox', 'MobileCoreServices', 'CoreGraphics', 'AVFoundation'
    s.dependency 'Masonry'
    s.static_framework  =  true
    

    ローカルの検証
    pod lib lint --allow-warnings
    

    検証リモート
    pod spec lint --allow-warnings
    
  • 使用形態
  • リモート・プライベート・ライブラリの使用は、作成した倉庫にプッシュする必要があります.
    Podfile      
    source '[email protected]:lilei1/hkijkvideo.git'(        )
    source 'https://github.com/CocoaPods/Specs.git'(         )
    
    
    target 
        pod 'HKIJKVideo',:git => '[email protected]:xxx/hkijkvideo.git'
    @end
    

    ローカルで私有ライブラリを使用する場合は、プッシュする必要はありません.直接参照するには、MainProjectとの統合ディレクトリに注意してください.
    target 
       pod pod 'HKIJKVideo', :path => '../HKIJKVideo'
    @end
    
  • 一般的なソリューション
  • 1.静的ライブラリの使用方法及びエラーの解決方法
     vendored_frameworks             Framework,          
      dependency          
      1.     Framwork ,        ,     s.static_framework = true,   vendored        ,           , pod    use_frameworks!         
      2. framework       ,    pod ,  img not found          .         ①        ,  Embedded Binaries        ,②     publicHeader  cocoapod          ,        
       :①             ,  ②          ,   ②      framework      git  ,  pod        cocoapod    .②        Framework   ,      
    

    2.画像リソースのロード方式
    ①        Asset ,             Bundle,         Asset ,   pod        Bundle,             Bundle
    ②          -(void)imageName:(NSSttring *)name ;    Bundle pathxxxxx ,           
    

    3.他のpodライブラリの静的ライブラリを使用する場合は、このように構成する必要があります.
    #     Framework 
    s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' =>     '${PODS_ROOT}/PolyvIJKPlayer' }
    #   .a 
    s.xcconfig = { 'LIBRARY_SEARCH_PATHS' =>     '$(PODS_ROOT)/PolyvIJKPlayer' }    
    

    4.コードにxibファイルが含まれている場合、xibファイルとpngは同じリソースファイルである、xibファイルをassetに入れてロードすることができる.