Xcode -利用 Configuration/Scheme 实现多环境配置

本文介绍了在iOS开发中如何使用Xcode的Configuration和Scheme来实现多环境配置,包括新增Configuration、Build Setting设置、info.plist的调整、Scheme的管理以及Pod的配置。通过这些步骤,开发者可以轻松地为不同环境如Debug、Release和预生产环境创建不同的APP打包。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

应用场景分析

在 iOS 开发过程中会遇到一个应用对应多个域名的情况,通常情况下使用 DEBUG 的宏来进行判断,这主要是基于 Xcode 中的 Configuration 默认给我们创建了 Debug 和 Release 两个环境。我们也可以对其进行新增和修改,来满足我们实际开发下的更多环境配置。比如: 多有一个预生产的环境域名,同一套代码需要打包不同的 APP 发布等情况。


Configuration

Configuration
新增的时候是选择一个进行的复制,所以建议想要创建的环境与 Debug 和 Release 是相互对应的,避免一些问题,这样的话有一些配置你完全可以不用去在意。比如: 在 Release 环境会有一些优化机制(内联优化等)。


Build Setting 相关设置

Build Setting
在 PROJECT 和 TARGETS 里的 Bulid Setting 都会进行设置,基于 PROJECT 和 TARGETS 的关系 TARGETS 会拷贝一部分 PROJECT 当中的一部分设置,所以会先去设置 PROJECT 中的 Bulid Setting 再去对 TARGETS 进行对应的检查设置。(列举一下我会用到的设置)

  1. info.plist File
  2. Product Bundle identifie
Appid: __UNI__F5500F0 Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild archive -sdk iphoneos18.1 -project [PackagePath]/HBuilder.xcodeproj -archivePath [PackagePath]/XArchive/HBuilder.xcarchive -scheme HBuilder -configuration Debug User defaults from command line: IDEArchivePathOverride = [PackagePath]/XArchive/HBuilder.xcarchive IDEPackageSupportUseBuiltinSCM = YES Build settings from command line: SDKROOT = iphoneos18.1 Prepare packages ComputeTargetDependencyGraph note: Building targets in dependency order note: Target dependency graph (1 target) Target 'HBuilder' in project 'HBuilder' (no dependencies) GatherProvisioningInputs CreateBuildDescription ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.1.sdk -x objective-c -c /dev/null ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.1.sdk -x c -c /dev/null ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --version --output-format xml1 ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/actool --print-asset-tag-combinations --output-format xml1 [PackagePath]/HBuilder/Assets.xcassets ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/actool --version --output-format xml1 ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -version_details ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E
最新发布
03-19
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值