Cocoapods 私有库制作填坑指南(Weex、支付宝SDK、微信SDK)

1,720 阅读1分钟

1、 私有库指定 sources Git目录

pod lib lint OCompPay.podspec --allow-warnings --use-libraries --sources="https://gitlab.oneitfarm.com/tanhui/CiNetwork.git,https://github.com/CocoaPods/Specs.git,https://gitlab.oneitfarm.com/tanhui/CiUtil.git,https://gitlab.oneitfarm.com/tanhui/CiBaseComponent.git,https://gitlab.oneitfarm.com/luliangxiao/ocomp-native.git" --verbose

2、 添加 frameworks 和 libraries

     s.frameworks = 'CFNetwork', 'CoreMotion', 'Foundation', 'CoreGraphics', 'SystemConfiguration', 'UIKit', 'CoreText', 'QuartzCore', 'CoreTelephony'
     s.libraries = 'z', 'sqlite3.0', 'c++'

3、 支付宝 指定 header 路径

  s.header_dir = "openssl"

4、 支付宝、微信指定 .a 和 .frameworks 路径

     s.vendored_frameworks = 'OCompPay/ThirdSDK/aliPay_SDK_2.0/AlipaySDK.framework'
     s.vendored_libraries = 'OCompPay/ThirdSDK/aliPay_SDK_2.0/libcrypto.a', 'OCompPay/ThirdSDK/aliPay_SDK_2.0/libssl.a'
     s.vendored_libraries = 'OCompPay/ThirdSDK/Wechat_SDK_1.6.2/libWeChatSDK.a'

5、 Weex的使用

 --use-libraries 需要添加这条命令,因为 weex 是 静态库;

6、 指定需要用的资源库

s.resource_bundles = {
  'CIWebView' => [ 'iOS/Source/CIWebView/bundlejs/web.js']
}

7、 source_files 目录 ** 表现遍历下面所有的子目录的文件

8、 提交完成之后如果 搜索不到可以更新一下 pod

pod setup

9 制作的库中如果存在私有库,podfile 中需要 添加 podspec 中的私有库source,公有库 pods 会自动安装,但是私有库无法找到对应的路径

10、 遇到的报错以及解决方案:

Error Info:Unable to find a specification for depended upon by Reason:未添加私有库Git路径

Error Info: linker command failed with exit code 1 (use -v to see invocation Reason:

1 文件名重复,检查是否有命名重复的文件

2 未添加需要依赖的 libraries

pod lib lint OCompConversation OCompConversation.podspec --sources=https://gitlab.oneitfarm.com/tanhui/CiNetwork.git,https://github.com/CocoaPods/Specs.git,https://gitlab.oneitfarm.com/tanhui/CiUtil.git,https://gitlab.oneitfarm.com/tanhui/CiBaseComponent.git,https://gitlab.oneitfarm.com/luliangxiao/ocomp-native.git --allow-warnings --use-libraries

pod lib lint