SVN下 cocoapods私有庫實踐

此文需要讀者熟悉在git下實現私有podspec。

一、SVN下實現私有podspec

步驟
  1. 創建私有庫:

     pod lib create EFThirdLibrary
    

注意:Which testing frameworks will you use? [ Specta / Kiwi / None ]
選擇None。(不然會有些問題,暫時不深究)
Would you like to do view based testing? [ Yes / No ]
選擇NO(否則只能支持iOS8以上)。

  1. 編輯EFThirdPary.podspec文件(見‘podspec編輯’篇章)。

  2. 集成cocoapods:

     pod install
    
  3. 編輯完podspec文件后,需要驗證一下這個文件是否可用:

     pod lib lint EFThirdLibrary.podspec
    
  4. 編輯完podspec文件,需要執行:

     pod update
    

二、SVN下cocoapods的使用

  1. podfile樣本

     target 'testlib' do
         ThirdLibraryVersion = '1' #三方集合庫版本分支號
         
         pod 'EFThirdLibrary', :svn => 'http://192.168.0.1/svn/lumet/EFThirdLibrary/branches/'+ThirdLibraryVersion
     end
    

或者

    pod 'EFThirdLibrary', :svn => 'http://192.168.0.1/svn/lumet/EFThirdLibrary', :tag => '1'

開發的時候,如果涉及多個組件,可以臨時使用以下pod語句:

    pod 'EFThirdLibrary', :svn => '/Users/zuoming/Documents/Source/EFThirdLibrary/trunk/'
  1. pod更新:

     pod update --verbose --no-repo-update
    

    或者

     pod update EFThirdLibrary --verbose --no-repo-update
    

    說明:開發階段使用指定pods更新,可以加快效率。

  2. pod刪除緩存:

    說明:如果podspec的version不改變的情況下,pod update會使用本地緩存,所以需要先清除緩存。

     pod cache clean EFFoundation
    

    或者

     pod cache clean --all
    

podspec編輯

  • 非ARC代碼處理:

      non_arc_files = 'EFThirdLibrary/EFThirdLibrary/Classes/ASI/*.{h,m}'
      
      s.exclude_files = non_arc_files
      s.requires_arc = true
      
      #非arc代碼
      s.subspec 'no-arc' do |sna|
          sna.requires_arc = false
          sna.source_files = non_arc_files
      end
    
  • 添加私有的Framework:

      s.vendored_frameworks = 'EFThirdLibrary/Frameworks/**/*.framework'
    
  • 添加靜態私有庫:

      s.vendored_libraries = 'EFThirdLibrary/Libs/**/*.a'
    
  • 添加需要的lib:

      s.libraries = "iconv", "xml2","stdc++","stdc++.6.0.9","c++","icucore","z","sqlite3"
    
  • 添加系統庫:

      s.frameworks = 'UIKit', 'Accelerate'
    
  • 添加資源文件:

      s.resources = ['EFThirdLibrary/Resources/Others/**/*.png', 'EFThirdLibrary/Resources/Others/**/*.xib', 'EFThirdLibrary/Resources/Others/**/*.plist', 'EFThirdLibrary/Resources/Others/**/*.dat', 'EFThirdLibrary/Resources/Bundles/*.bundle']
    

    注意:bundle與其他資源放在不同目錄,要不然bundle中的png等資源會被重復添加。

  • 私有庫依賴

      s.dependency 'EFThirdLibrary'
    

    說明:如果沒有創建Spec Repo遠端倉庫的話,需要在工程的podfile文件里導入:

      pod 'EFThirdLibrary', :svn => 'http://192.168.0.1/svn/lumet/EFThirdLibrary', :tag => '1'
    

問題

  • Podfile使用use_frameworks!,則只能支持iOS8以上。 FBSnapshotTestCase 需要使用 use_frameworks!。所以如果需要支持iOS7,Would you like to do view based testing? [ Yes / No ],選擇NO。

[!] Pods written in Swift can only be integrated as frameworks; add use_frameworks! to your Podfile or target to opt into using it. The Swift Pod being used is: FBSnapshotTestCase

ld: embedded dylibs/frameworks are only supported on iOS 8.0 and later (@rpath/EFFoundation.framework/EFFoundation) for architecture x86_64

  • The operation couldn’t be completed. (LaunchServicesError error 0.)錯誤原因:資源加載導致的,可能是bunlde中的資源被重復添加至工程。修改完之后,clean+run。

  • 使用以下語句,或許可以解決無法連接SVN的問題:

    svn: E170001: Unable to connect to a repository at URL 'http://192.168.0.1/svn/lumet/EFFoundation/trunk'
    svn: E170001: OPTIONS of 'http://192.168.0.1/svn/lumet/EFFoundation/trunk': authorization failed: Could not authenticate to server: rejected Basic challenge (http://192.168.0.1)

      svn info --username svnname --password --no-auth-cache http://192.168.0.1/svn
    
  • 當出現如下error
    ld: library not found for -l...

    可以試試:

       ?將Building中的Build Active Architectures Only設置為YES。
    
  • 問題sharedapplication is unavailable not available on ios app extension解決方法:

    #在podfile里添加 
    post_install do |installer_representation|
         installer_representation.pods_project.targets.each do |target|
           target.build_configurations.each do |config|
            config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
           end
      end
    end
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容