從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