1

一步一步做,如下所示: http ://www.raywenderlich.com/12139/introduction-to-cocoapods

pod install在不同的项目中运行时出现错误:

### Stack

```
   CocoaPods : 0.15.2
        Ruby : ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
    RubyGems : 1.8.24
        Host : Mac OS X 10.8.2 (12C60)
       Xcode : 4.5.2 (4G2008a)
Ruby lib dir : /usr/local/rvm/rubies/ruby-1.9.3-p194/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 60b51e341f727b7d715ed541ea9cb52f6e0cc819
```

### Podfile

```ruby
          platform :ios, '6.0'
pod 'AFNetworking', '1.0'
```

### Error

```
invalid byte sequence in US-ASCII
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/local_pod.rb:540:in `glob'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/local_pod.rb:540:in `glob'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/local_pod.rb:540:in `block in expanded_paths'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/local_pod.rb:534:in `map'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/local_pod.rb:534:in `expanded_paths'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/local_pod.rb:327:in `readme_file'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/generator/documentation.rb:50:in `index_file'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/generator/documentation.rb:70:in `appledoc_options'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/generator/documentation.rb:81:in `generate'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:91:in `generate_docs'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:60:in `block (2 levels) in install_dependencies!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/user_interface.rb:37:in `section'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:53:in `block in install_dependencies!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:50:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:50:in `install_dependencies!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:119:in `block in install!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/user_interface.rb:37:in `section'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/installer.rb:118:in `install!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/command/install.rb:46:in `run_install_with_update'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/command/install.rb:51:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/lib/cocoapods/command.rb:75:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/cocoapods-0.15.2/bin/pod:16:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/pod:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/pod:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
```

更新。

➜  ~  gem install cocoapods
zsh: correct 'cocoapods' to '.cocoapods' [nyae]? n
Fetching: xcodeproj-0.4.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for -std=c99 option to compiler... *** 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
    --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=/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `block in try_compile'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:443:in `with_werror'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `try_compile'
    from extconf.rb:24:in `block in <main>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from extconf.rb:23:in `<main>'


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p194/gems/xcodeproj-0.4.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p194/gems/xcodeproj-0.4.0/ext/xcodeproj/gem_make.out
4

3 回答 3

13

将 export LC_ALL="en_US.UTF-8" 添加到您的 ~/.zshrc 或 ~/.bashrc https://github.com/CocoaPods/CocoaPods/issues/639

于 2013-01-02T14:35:41.997 回答
2

打开一个新的终端窗口足以解决我的问题。

我的终端实例/会话如何搞砸了。pod install将在新窗口中工作,但在旧窗口中继续失败。

于 2021-01-04T08:57:12.853 回答
0

问题出在 Ruby 编译器中,它已被其他一些应用程序损坏。重新安装后一切正常。

于 2012-12-04T12:14:03.590 回答