集成GoogleAdmob插件的Unity工程 在 Mac导出Xcode工程报错 - 错误信息:Error running CocoaPods. Please ensure you have at least version 1.0.0. You can install CocoaPods with the Ruby
1.因GoogleAdmob插件在Xcode中需要用到CocoaPods来处理包依赖关系,所以unity在mac导出集成GoogleAdmob插件的xcode工程时, 会首先检测CocoaPods的安装环境,如果没安装,则会自动安装,这时候会卡在:Converting managed assemblies to C++界面,因网络问题,这个过程需要国内一般需要1-2小时,如果不急就等待,如果需要加速就参考:https://juejin.im/post/5c41211ce51d453ba81022c9解决
2.在确定mac已经安装了CocoaPods时候出现了错误提示,
信息如下:
Error running CocoaPods. Please ensure you have at least version 1.0.0. You can install CocoaPods with the Ruby gem package manager:
> sudo gem install -n /usr/local/bin cocoapods
> pod setup
'pod --version' returned status: 1
output:
[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
[0m
/Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:118:in `block in which!': [31m[!] Unable to locate the executable `git`[0m (Pod::Informative)
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:117:in `tap'
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:117:in `which!'
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:143:in `capture_command'
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:116:in `git_version'
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:130:in `verify_minimum_git_version!'
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:49:in `run'
from /Users/daihuoying/.gem/ruby/2.6.0/gems/cocoapods-1.9.1/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
UnityEngine.Debug:LogError(Object)
Google.Logger:Log(String, LogLevel) (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs:91)
Google.IOSResolver:Log(String, Boolean, LogLevel) (at /Users/smiles/dev/src/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:809)
Google.IOSResolver:OnPostProcessInstallPods(BuildTarget, String) (at /Users/smiles/dev/src/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:1974)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
AutoBuildUtil:BuildIOS(String) (at Assets/Editor/Utils/AutoBuildUtil.cs:238)
<>c:<BuildIOSTest>b__16_0() (at Assets/Editor/Utils/AutoBuildUtil.cs:245)
ExportUtil:ExportComplete() (at Assets/Editor/Export/ExportUtil.cs:98)
ExportUtil:ExportResource(BuildTarget) (at Assets/Editor/Export/ExportUtil.cs:70)
ExportUtil:ToBuildiPhoneResource() (at Assets/Editor/Export/ExportUtil.cs:36)
ExportUtil:BuildIPhoneResource(Action) (at Assets/Editor/Export/ExportUtil.cs:24)
AutoBuildUtil:BuildIOSTest() (at Assets/Editor/Utils/AutoBuildUtil.cs:244)
错误截图:
按照错误提示:
1.进入终端依次执行:
sudo gem install -n /usr/local/bin cocoapods
pod setup
2.发现提示CocoaPods安装完成
3.再次打包发现依然报上面的错误
4.分析:明明本机已经安装cocoapods,unity依然提示没有cocoapods版本,
所以猜测虽然执行了上面的命令,但cocoapods并没有安装到unity调用的ruby目录,所以查看系统ruby情况:
所以,解决的办法就是,把系统目录下已经安装的cocoapods文件(或者把gems文件夹的全部)都拷贝到unity调用的ruby gems对应目录中,如图:
5.拷贝替换好后,再次打包,unity成功导出xcode工程,如图: