pod package找不到命令

问题背景

私有Cocoapods打包完成,打包类库

sudo gem install cocoapods-packager
复制代码

安装完成使用

pod package xxx.podspec --library --force
复制代码

会报下面的错误,使用不了命令

$ pod COMMAND

  CocoaPods, the Cocoa library package manager.
复制代码

解决路径

参考:github.com/CocoaPods/c… 大佬表示是环境的问题,我的路径确实不太一样。
1、升级gem、ruby等,最后安装cocoapods会报

Gem files will remain installed in xxx for inspection.
Results logged to xxx/gem_make.out
复制代码

这个查找了下说是xcode-select的问题需要安装下,但是我之前就已经安装完成的
先是删除了rvm、cocoapods、gem等重新安装还是不行,降低Ruby的版本也不行
2、后来看到上面有个错误报

error: implicit declaration of function 'ffi_prep_closure_loc' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
    ffiStatus = ffi_prep_closure_loc(code, &fnInfo->ffi_cif, callback_invoke, closure, code);
                ^
Function.c:852:17: note: did you mean 'ffi_prep_closure'?
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/ffi/ffi.h:269:1: note: 'ffi_prep_closure' declared here
ffi_prep_closure(
复制代码

查找到

gem install ffi -- --enable-system-libffi
复制代码

安装完成之后再继续安装cocoapods即可成功
3、继续pod package打包报错

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer
复制代码

参考解决方案:

输入:xcode-select --print-path
输出:/Library/Developer/CommandLineTools
输入:sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/ 
输入:xcode-select --print-path
输出:/Applications/Xcode.app/Contents/Developer
复制代码

4、继续pod package报错

fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: Pods/build/package.a and Pods/build-sim/package.a have the same architectures (arm64) and can't be in the same fat output file
复制代码

参考cocoapod-packager的官方:github.com/CocoaPods/c…
有的使用了,官方不建议使用s.user_target_xcconfig

s.pod_target_xcconfig = {'EXCLUDED_ARCHS [sdk = iphonesimulator *]'=>'arm64'}
s.user_target_xcconfig = {'EXCLUDED_ARCHS [sdk = iphonesimulator *]'=>'arm64'}
复制代码

有的修改本地cocoapods-packager源ruby代码pod_utils.rb解决了这个问题,查找cocoapods-packager源码路径参考:www.jianshu.com/p/2df0bd221…

 config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
复制代码

我使用了替换源码的方式解决了。
还有一种方式:
github.com/TyrantDante…

参考

macos下安装brew,rvm,ruby,gem,cocoaPods及其初始化

Active Admin gem ffi won’t compile on MacOS

iOS自动化构建 xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/D…
Xcode12 Cocoapods-Package 打包Framework失败

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享