美文网首页
Swift 多环境配置(一)

Swift 多环境配置(一)

作者: 迷路的小小 | 来源:发表于2021-11-19 14:24 被阅读0次

1. 新增Configurations配置

  • 点击工程文件 --> Info --> PROJECT --> Configuration
  • 点击“+”,新增一条配置,如Test
    新增配置
  • 配置Build Settings
    1. Apple Clang - Preprocessing --> Preprocessor Macros
      修改DEBUG=1TEST=1
    2. Swift Compliler Conditions --> Active Compilation Conditions
      修改DEBUGTEST

2. 配置Pod

  • 配置Podfile
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          if config.name == 'Test'
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)','TEST=1']
            config.build_settings['SWIFT_ACTIVE_COMPILATION_CONDITIONS'] = ['$(inherited)','TEST']
          end
        end
      end
    end
    
  • 执行命令pod install

3. 多环境的应用和使用配置

  1. 新增Scheme
    Xcode调试区,点击Target,选择新建方案
    新建Scheme
    TEST Scheme
  2. 配置TEST Scheme
    Xcode调试区,点击Target,选择编辑方案
    运行方案配置

相关文章

网友评论

      本文标题:Swift 多环境配置(一)

      本文链接:https://www.haomeiwen.com/subject/cfostrtx.html