iOS 私有库问题随笔

488 阅读2分钟

iOS Pod库问题随笔

一、pod lib create XLBaseTestpod install 时抛异常

M1电脑抛出异常
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275: [BUG] Bus Error at 0x00000001009dc000

解决:安装ffi,执行

sudo arch -x86_64 gem install ffi

后,终端cd到Example下重新pod install,若还是失败执行

arch -x86_64 pod install

二、The repo xxxxx at ../../../../../.cocoapods/repos/xxxx is not clean异常

Pod repo push CXSpecs XXX.podspec 时

抛异常「The repo xxxxx at ../../../../../.cocoapods/repos/xxxx is not clean

解决:

pod repo update [xxxx]

若还是失败,先移除 pod repo remove [XXX],在重新添加 pod repo add [url] [XXX]

三、ERROR | iOS unknown: Encountered an unknown error (Unable to find a specification for B (~> 0.1.0) depended upon by A) during validation.

解决:

pod lib lint XXX.podspec --sources='http://XXXX/XLTest/XLTest.git,https://github.com/CocoaPods/Specs.git' --allow-warnings --use-libraries —-verbose

描述:

http://XXXX/XLTest/XLTest.git:私有库地址

--allow-warnings:允许警告。

--use-libraries:使用静态库或者是framework,解决依赖相关framework库后校验提示找不到库问题。

—-verbose:显示详情。

四、pod lib lint/repo push不支持i386编译&只能真机运行的库

解决:

第一种:取消模拟器生成的二进制文件

在 podspec 文件中添加 s.pod_target_xcconfig = { 'VALID_ARCHS[sdk=iphonesimulator*]' => '' },如果项目已经设置 pod_target_xcconfig,添加到已有值的后面。

pod lib lint --skip-import-validation

pod repo push XXSpecs XXX.podspec --skip-import-validation

--skip-import-validation:跳过验证pod是否可以导入

第二种:跳过编译验证

1、gem which cocoapods

2、open /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods

3、编辑 validator.rb

4、修改iOS 配置
原文件:   when :ios

        command += %w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator)

        command += Fourflusher::SimControl.new.destination(:oldest, 'iOS', deployment_target)

修改为:

      when :ios

        command += %w(—-help)

五、警告 Insecure world writable dir /usr/local/sbin in PATH, mode 040777

警告:在path 模式040777中的Path/usr/local/sbin为不安全可写目录,可执行一下操作:

sudo chmod go-w /usr/local/sbin
sudo chmod 775 /usr/local

六、集成组件报错处理 -- include of non-modular header inside XXXX

解决:

第一种:将项目的 target -> Build Settings -> Allow Non-modular includes in Framework Modules选项卡设为YES。

第二种:私有库的 .podspec 中配置 xcconfig,如下:

s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES'}

七、RuntimeError - [Xcodeproj] Unknown object version (56).

Xcode 版本和 CocoaPods 的版本不兼容,需要更新 CocoaPods

RuntimeError - [Xcodeproj] Unknown object version (56).
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:228:in `initialize_from_file'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1190:in `block (2 levels) in inspect_targets_to_integrate'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1189:in `each'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1189:in `block in inspect_targets_to_integrate'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1184:in `inspect_targets_to_integrate'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:106:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `<main>'
// 查看当前pod 版本
pod --version
# 1.11.3

// 更新cocoapods
brew update cocoapods
# cocoapods 1.11.3 -> 1.12.0

pod --version
# 1.12.0