AFNetWoking中UIWebView导致苹果包不通过的完美方案

从2020年4月1日起,Apple对新发布的应用ipa中使用了UIWebView的直接不予上传,即使你通过Xcode将包Upload成功了,在App Store Connect中也看不到,同时你会收到这样的邮件:

ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

在Xcode中通过搜索UIWebView关键字或者在项目根目录的控制台下搜索``,会发现只有AFNetWorking这个三方库中用到了UIWebView,所以解决方案很简单,只要删掉库中的UIWebView即可,可以等待AFNetWorking作者更新,github上也有关于这个问题的issue,现在已经关闭了。
对于目前就要上架App Store的应用来说,就需要手动处理掉UIWebView了。
方案无非两个:
1、不引用AFNetWorking中的UIkit子库,如下:

  • 可以暂时这样去解决,如果你没有使用AFNetworking/UIKit
pod 'AFNetworking/NSURLSession', '3.2.1'
pod 'AFNetworking/Reachability', '3.2.1'
pod 'AFNetworking/Security', '3.2.1'
pod 'AFNetworking/Serialization', '3.2.1'
  • 或者
#此处以Serialization, Security, NSURLSession为例
pod 'AFNetworking', :subspecs => ['Serialization', 'Security', 'NSURLSession', 'Reachability'] 

2、在pod中通过脚本,在pod install时删掉UIWebView文件,这个方案更推荐,不影响UIKit子库使用,只保证UIWebView不可用(实际上也不用了)。
此方案Podfile文件如下:

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
platform :ios, '9.0'
inhibit_all_warnings!
target 'ProjectName' do
# 这当中是各种依赖库
pod 'AFNetworking', '~> 3.2.1'
end

# remove UIKit(UIWebView) rejected by AppStore
pre_install do |installer|
    puts 'pre_install begin....'
    dir_af = File.join(installer.sandbox.pod_dir('AFNetworking'), 'UIKit+AFNetworking')
    Dir.foreach(dir_af) {|x|
      real_path = File.join(dir_af, x)
      if (!File.directory?(real_path) && File.exists?(real_path))
        if((x.start_with?('UIWebView') || x == 'UIKit+AFNetworking.h'))
          File.delete(real_path)
          puts 'delete:'+ x
        end
      end
    }
    puts 'end pre_install.'
end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值