flutter ios上踩的一个坑

在ios模拟器上调试的时候出现错误信息:The iOS Simulator deployment target is set to 4.3...

原来是因为ios 版本问题,于是找到资料是在 Podfile文件中添加判断

post_install do |installer|
  installer.pods_project.targets.each do |target|
 target.build_configurations.each do |config|
  if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
     end
   end
  end
end

接着又报错,Using new build systemnote: Planning buildnote

查资料原来是要升级 cocospod,于是百度了下,

1. 检测gem版本

 

$ gem -v

如果gem版本小于2.6.x,则需要更新gem

2. 更新gem(gem版本高于2.6.x可跳过此步)

  1. 检测ruby源,更新gem需要官方的ruby源

 

$ gem sources -l
  1. 替换ruby源为官方地址(如果ruby源是"https://rubygems.org/"则跳过此步)

 

$ gem sources --add https://rubygems.org/ --remove xxx.xxx
  1. 确保ruby源中只有"https://rubygems.org/"

 

$ gem sources -l
  1. 更新gem(此步要)

 

$ gem update --system
  1. 查看gem版本,确认大于2.6.x

 

$ gem -v
  1. 将ruby源切换回国内的

 

$ gem sources --add https://gems.ruby-china.com/
 --remove https://rubygems.org/
  1. 确保只有"https://gems.ruby-china.com/"一个ruby源

 

$ gem sources -l

3. 更新cocoapods

 

$ gem install cocoapods -n /usr/local/bin


结果还是不行

xcode报错:

Xcode's output:

    /Users/maxiang/Documents/maxiang/flutter/.pub-cache/hosted/pub.flutter-io.cn/image_gallery_saver-1.2.2/ios/Classes/ImageGallerySaverPlugin.m:2:9: fatal error: 'image_gallery_saver/image_gallery_saver-Swift.h' file not found
    #import
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build systemnote: Planning buildnote: Constructing build description
 

android也报错,最后看有人说是因为版本问题,建议换个插件。

目前使用的插件是:

image_gallery_saver: ^1.2.2
permission_handler: ^4.2.0+hotfix.3

你可能感兴趣的:(Flutter)