代码之家  ›  专栏  ›  技术社区  ›  aecend

为什么Xcode在使用Podfile时会将所有Swift库安装到我的测试设备上?

  •  0
  • aecend  · 技术社区  · 6 年前

    我刚刚在iOS项目中添加了一个Podfile,无论我为ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES(甚至$(继承))设置了什么,它仍然会将所有这些SWIFT库添加到我的构建中。在我添加播客文件之前,我的应用程序大约是20MB,现在是1.35GB。。。我在谷歌上搜索了很多次,但我似乎不知道是什么原因导致了这种情况。我使用的是Xcode 10.1,下面是我的播客文件:

    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
    
    0 回复  |  直到 5 年前
        1
  •  0
  •   aecend    5 年前

    经过几个小时的挫折,我终于发现了问题的根源。结果我错过了一个重要的步骤: 清理生成文件夹 .

    无论何时更改播客文件,都需要重新运行 pod install 然后单击“项目”菜单下的“清理生成文件夹”。

    以下是阻止安装多个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
    

    一旦我做到了这一点,我的应用程序又回到了原来的小尺寸。编码快乐!