在Xcode项目文件夹中运行“ pod install”不会创建.xcworkspace文件

时间:2020-10-24 22:01:25

标签: swift xcode firebase cocoapods

已在原始帖子下方更新并显示错误消息。

原始帖子: 我有一个带有以下Podfile的Swift项目。在项目文件夹中运行“ pod install”不会创建.xcworkspace文件,也不会安装任何Pod。

我遵循了https://cocoapods.org“入门”部分中的所有说明,但仍然没有。

我在做什么错?在最新版本的macOS Big Sur Public Beta上运行Xcode 12.1。

target 'FY' do
use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'FacebookCore'
pod 'FacebookLogin'
end

更新并显示错误消息: 显然,由于/ usr / bin问题,未安装Cocoapods。我使用sudo gem install cocoapods --verbose来获取以下错误消息。还从开发人员门户网站安装了Xcode 12.1和12.2的命令行工具。

current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c
["/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby", "-I", "/Library/Ruby/Site/2.6.0", "-r", "./siteconf20201025-16127-3uc1s5.rb", "extconf.rb"]
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib
    --enable-system-libffi
    --disable-system-libffi
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header'
    from extconf.rb:10:in `system_libffi_usable?'
    from extconf.rb:42:in `<main>'
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20201025-16127-3uc1s5.rb extconf.rb
Building has failed. See above output for more information on the failure.
To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.13.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.13.1/gem_make.out

来自mkmf.log的错误

package configuration for libffi is not found
"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -DUSE_FFI_CLOSURE_ALLOC conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.Internal.sdk/usr/local/lib     -lruby.2.6   "
In file included from conftest.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
         ^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

2 个答案:

答案 0 :(得分:1)

初始化cocoapods

第一次需要在项目目录中运行pod init来初始化项目。

它将创建新的xcworkspace AND pod文件。完成此操作后,将您的Pod添加到Pod文件中并运行pod install

确保xcode项目的部署目标与pod文件中的平台相同。例如ios 14.1。

安装广告连播

如果要添加更多Pod,请将其添加到Pod文件中,然后在项目目录中再次运行pod install

更新广告连播

如果要更新所有Pod,请在项目目录中运行pod update

从项目中删除单个吊舱

只需从pod文件中删除该行或对其进行注释,然后再次在您的项目目录中运行pod install

从项目中删除可可足类

在某些情况下,可能有必要从项目中完全删除可可足类。在项目目录中运行以下命令。

pod deintegrate

pod cache clean --all

rm Podfile

如果仅尝试重新安装它,请仅尝试pod deintegrate,并保持Pod文件和高速缓存不变。后跟pod install。如果这样做不起作用,请使用上面的所有三个命令并从头开始。

如果尚未安装pod deintegratepod clean,则可能需要安装。运行sudo gem install cocoapods-deintegrate cocoapods-clean

对此answer here

的信用

安装说明

确保在您的系统上正确安装了cocoapods。您可以使用pod --version,它将为您提供已安装的版本。如果显示“找不到文件或类似文件”,则说明有问题。

sudo gem install cocoapods通常具有usr/bin目录权限的问题。它应该告诉您在尝试安装时。

改为尝试sudo gem install -n /usr/local/bin cocoapods

如果这不起作用,请尝试sudo gem install cocoapods --verbose并查看输出。通常在最后,您会看到导致安装失败的错误。

使用安装cocoapods时使用的相同命令将其更新到最新版本。

答案 1 :(得分:0)

this post中的“自动化脚本”有助于解决此问题。感谢大家的投入和帮助。感谢帖子的创建者和自动脚本。