我刚刚向我的 iOS 项目添加了一个 Podfile,无论我为 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES 设置什么(甚至 $(inherited)),它仍然会将所有这些 swift 库添加到我的构建中。在添加 Podfile 之前,我的应用程序大约有 20 MB,现在是 1.35 GB...我已经进行了大量的谷歌搜索,但我似乎无法弄清楚是什么原因造成的。我使用的是 Xcode 10.1,这是我的 Podfile:
platform :ios, '10.0'
target 'MyApp' do
use_frameworks!
# Core Dependencies
pod 'SwiftLint', '~> 0.29.1'
pod 'R.swift', '~> 5.0.0.rc.1'
pod 'RxSwift', '~> 4.4.0'
pod 'RxCocoa', '~> 4.4.0'
pod 'Alamofire', '~> 4.8.0'
pod 'Moya/RxSwift', '~> 12.0.1'
# Database management
pod 'RxRealm', :git => 'https://github.com/RxSwiftCommunity/RxRealm', :tag => '0.7.7'
pod 'RealmSwift', '~> 3.12.0'
# Remote Image management
# pod 'Kingfisher', '~> 4.6.3'
target 'MyAppTests' do
inherit! :search_paths
pod 'Nimble', '~> 7.3.1'
pod 'SnapshotTesting', '~> 1.0'
end
target 'MyAppUITests' do
inherit! :search_paths
pod 'Nimble', '~> 7.3.1'
pod 'SnapshotTesting', '~> 1.0'
end
end
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
end
end
end
最佳答案
好吧,经过几个小时的挫败感,我终于发现了导致问题的原因。事实证明我错过了一个重要的步骤:清理构建文件夹。
每当您对 Podfile 进行更改时,都需要重新运行 pod install
,然后单击“项目”菜单下的“清理构建文件夹”。
以下是 Podfile 底部的正确代码,可阻止安装 Swift 标准库的多个副本:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = '$(inherited)'
end
end
end
完成此操作后,我的应用程序恢复到原来的小尺寸。编码愉快!
关于ios - 使用 Podfile 时,为什么 Xcode 将所有 Swift 库(多次)安装到我的设备上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54640021/