此文需要读者熟悉在git下实现私有podspec。
一、SVN下实现私有podspec
步骤
-
创建私有库:
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以上)。
编辑EFThirdPary.podspec文件(见‘podspec编辑’篇章)。
-
集成cocoapods:
pod install
-
编辑完podspec文件后,需要验证一下这个文件是否可用:
pod lib lint EFThirdLibrary.podspec
-
编辑完podspec文件,需要执行:
pod update
二、SVN下cocoapods的使用
-
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/'
-
pod更新:
pod update --verbose --no-repo-update
或者
pod update EFThirdLibrary --verbose --no-repo-update
说明:开发阶段使用指定pods更新,可以加快效率。
-
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