Xcode9中 export ipa 包出现The data couldn’t be read because it isn’t in the correct format

随笔记录:

        升级Xcode9后在进行ipa包导出时一直提示The data couldn’t be read because it isn’t in the correct format的错误提示,折腾了好久才算解决了,感觉跟个人的开发环境配置有关系,估计以前某一次升级ruby的时候导致环境异常,低版本的Xcode没有验证,最新的Xcode9做了验证。虽然问题是解决了,但对问题的根源并没有特别理解,零散记一下能记住的解决过程。


导出包时提示The data couldn’t be read because it isn’t in the correct format,对话框的左下角“show logs”查看错误日志发现以下错误:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-16/2.0.0/xcodeproj-0.17.0 (Errno::EACCES)

在这里根据网上的方式去尝试执行gem update --system,结果收到以下错误:

ERROR:While executing gem ... (Gem::RemoteFetcher::FetchError)

SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)

参照 https://apple.stackexchange.com/questions/83885/ruby-2-0-0-install-via-rvm-errors-surrounding-openssl 网上的方式进行尝试:

$ rvm remove 2.0.0 # get rid of unsuccessful installation

$ rvm get head --autolibs=3 # get the latest RVM and build required libs

$ rvm requirements # just in case, install all other required stuff

$ rvm install ruby-2.0.0

$ rvm --default use ruby-2.0.0

结果在执行 rvm install ruby-2.3.4 时下载超级慢,最后提示错误 :

There was an error(56).

Failed download

There has been an error fetching the ruby interpreter. Halting the installation.

重新设置了gem源:

$ gem sources -a https://gems.ruby-china.org/

Error fetching https://gems.ruby-china.org/:

SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)

$ echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db

接着开始尝试安装高版本的ruby:

$ rvm install 2.3.0 --disable-binary

安装过程中报错找不到libyaml-0.2.dylib:

/usr/local/Cellar/ruby/2.4.2/lib/ruby/2.4.0/yaml.rb:5:in `':

It seems your ruby installation is missing psych (for YAML output).

To eliminate this warning, please install libyaml and reinstall your ruby.

/usr/local/Cellar/ruby/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/usr/local/Cellar/ruby/2.4.2/lib/ruby/2.4.0/x86_64-darwin16/psych.bundle, 9): Library not loaded: /usr/local/opt/libyaml/lib/libyaml-0.2.dylib (LoadError)

接下来尝试过重新安装openssl、重新安装ruby、重新安装psych、重新安装libyaml:

$ brew remove openssl

$ brew install openssl

$ rm -rf /usr/local/lib/ruby/site_ruby/

$ brew uninstall ruby

$ brew install ruby

$ gem install psych

$ gem install libyaml

$ rvm pkg install libyaml

$ rvm reinstall all --force

# 重新装yaml

$ cd.rvm/src

$ sudo rm-rf yaml*

$ rvm pkg install libyaml

# 手动下载libyaml

$ tar zxf yaml-0.1.4.tar.gz

$ cd yaml-0.1.4

$ ./configure

$ make

$ make install

最后还是报错,而且错误的路径一直是2.0.0 的版本,最后尝试了把默认2.0.0版本删除了,重新设置默认的ruby版本为2.3.4并update,最终解决了问题:

https://github.com/caskroom/homebrew-cask/issues/7732

$ rm -rf /Library/Ruby/Gems/2.0.0

$ gem update --system

现在依然是一知半解的状态,怀疑应该是当初升级ruby后某个环境变量指错了,在进行ipa导出的时候两个版本的ruby都被用到了。附带一些参考的链接:

https://stackoverflow.com/questions/15738883/please-install-libyaml-and-reinstall-your-ruby

https://stackoverflow.com/questions/10392495/installing-libyaml-for-ruby-on-a-mac-osx-lion

https://github.com/caskroom/homebrew-cask/issues/7732

http://www.cocoachina.com/ios/20141018/9958.html

https://stackoverflow.com/questions/12092468/install-libtools-on-mac

https://github.com/Homebrew/homebrew-core/issues/11636

https://github.com/Homebrew/homebrew-core/issues/11635

https://github.com/rvm/rvm/issues/2689

https://apple.stackexchange.com/questions/83885/ruby-2-0-0-install-via-rvm-errors-surrounding-openssl

有人来答疑解惑一下最好了!!!

你可能感兴趣的:(Xcode9中 export ipa 包出现The data couldn’t be read because it isn’t in the correct format)