使用不同的设置和名称来管理开发,测试和生产版本的最佳方法

编程入门 行业动态 更新时间:2024-10-09 18:25:01
本文介绍了使用不同的设置和名称来管理开发,测试和生产版本的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有三个API,它们具有不同的API Keys和一些不同的设置

I've three APIwith different API Keys and some different settings

  • 用于开发或内部测试构建-iOS App Store外部的开发发行版

  • For development or internal testing build - Development distribution outside the iOS App Store

  • Host-devapi.project-name
  • API Key-development_key
  • FLEX [ 1 ]-启用
  • Host - devapi.project-name
  • API Key - development_key
  • FLEX[1] - Enable

用于客户端测试版本-iOS App Store外部的企业发行版

For client testing build - Enterprise distribution outside the iOS App Store

  • Host-stgapi.project-name
  • API Key-enterprise_key
  • FLEX-启用
  • Host - stgapi.project-name
  • API Key - enterprise_key
  • FLEX - Enable

用于生产构建-在iOS App Store中分发

For production build - Distribution in the iOS App Store

  • Host-API.project-name
  • API key-app_store_key
  • FLEX-禁用
  • Host - API.project-name
  • API key - app_store_key
  • FLEX - Disable

我可以使用DEBUG

#if DEBUG #define API_BASE_URL @"devapi.project-name/api/v1" #define API_KEY @"development_key" #else #define API_BASE_URL @"stgapi.project-name/api/v1" #define API_KEY @"enterprise_key" #endif // In AppDelegate.m #if DEBUG [[FLEXManager sharedManager] showExplorer]; #endif

但是第一个问题是企业发行版(用于客户端测试)和iOS 适用于企业和App的App Store发行(生产)构建 每次需要更改代码时商店的分布情况

But first problem is Enterprise distribution (for client testing) and iOS App Store distribution (production) build, for Enterprise and App Store distribution every time need to change code

  • 用于企业发行

    #if DEBUG //debug setting #else //enterprise setting #define API_BASE_URL @"stgapi.project-name/api/v1" #define API_KEY @"enterprise_key" #endif

  • 用于App Store分发

    #if DEBUG //debug setting #else //app store setting #define API_BASE_URL @"api.project-name/api/v1" #define API_KEY @"app_store_key" #endif

  • 我正在寻找类似这样的方式

    I'm looking for way something like this

    #ifdef DEVELOPMENT #define API_BASE_URL @"devapi.project-name/api/v1" #define API_KEY @"development_key" #elif ENTERPRISE #define API_BASE_URL @"stgapi.project-name/api/v1" #define API_KEY @"enterprise_key" #elif APP_STORE #define API_BASE_URL @"api.project-name/api/v1" #define API_KEY @"app_store_key" #endif

    还是其他?

    第二个问题

    Second Problem

    有什么方法可以创建三个名称不同的构建而不创建不同的目标?

    Is there any way to create three build with different name without creating different target?

    • ProductName-适用于App Store
    • ProductName-Dev-用于内部开发版本
    • ProductName-Stg-用于客户端测试(企业)版本
    • ProductName - For App Store
    • ProductName-Dev - For Internal Development build
    • ProductName-Stg - For Client Testing (Enterprise) build

    我刚刚根据 iamnichols 提供的解决方案创建了演示项目和完整的视觉指南>

    I've just created demo project and full visual guide based on solution give by iamnichols

    • 管理开发的最佳方法,使用不同的设置测试和生产iOS版本
    • github/vineetchoudhary/BuildManagement
    • Best way to manage Development, Testing and Production iOS builds with different settings
    • github/vineetchoudhary/BuildManagement
    推荐答案

    调试和发布版本之间的区别在于,其中一个已归档并导出,而另一个通过调试器中的Xcode在本地运行.您可能会发现有时也想在调试器中运行生产或暂存版本,但是通过#ifdef DEBUG拆分内容,您可能会遇到问题.

    The difference between a debug and a release build is that one is archived off and exported but the other is run locally via Xcode in the debugger. You might find that you want to sometimes run the production or staging build in the debugger too but by splitting stuff out by #ifdef DEBUG, you are probably going to run into issues.

    这是我所做工作的简化版本:

    This is a simplified version of what I do:

    在项目(而非目标)设置中,创建(与原始副本相同)以下配置:

    In the project (not target) settings, create (duplicate from the originals) the following configurations:

    • Debug_Dev
    • Debug_Staging
    • Debug_Prod
    • Release_Dev
    • Release_Staging
    • Release_Prod

    请注意,如果您使用Cocoapods,则需要将配置设置回无,删除项目中Pods文件夹的内容(不是Pods项目),然后重新运行.

    Note that if you use Cocoapods then you will need to set the configurations back to none, delete the contents of the Pods folder in your project (Not the Pods project) and re-run pod install.

    创建以下内容(而不是使用MyApp方案)(复制原始内容):

    Instead of just having a MyApp scheme, create the following (duplicate the original):

    • MyApp_Dev
    • MyApp_Staging
    • MyApp_Prod

    在每种方案中,请在适当的地方使用关联的Debug_ *和Release_ *配置.

    In each scheme, use the associated Debug_* and Release_* configurations where appropriate.

    添加一个附加的预处理器宏,以标识要针对哪个环境构建.

    Add an additional preprocessor macro to identify what environment you are building against.

    在项目构建设置中,单击+并添加用户定义的构建设置,然后将其命名为MYAPP_ENVIRONMENT.然后,对于每个不同的环境组,向每个环境添加一个不同的预处理器宏.即ENV_DEV=1,ENV_STAGING=1和ENV_PROD=1.

    In the project build settings, click the + and add a user defined build setting and call it something like MYAPP_ENVIRONMENT. Then, for each different group of environments, add a different preprocessor macro to each one. i.e ENV_DEV=1, ENV_STAGING=1 and ENV_PROD=1.

    然后,在c预处理器宏中(同样在项目级别而非目标级别),使用$(MYAPP_ENVIRONMENT)添加此新的MYAPP_ENVIRONMENT设置.

    Then, in the c preprocessor macros (again on a project level and not the target level) add this new MYAPP_ENVIRONMENT setting using $(MYAPP_ENVIRONMENT).

    这样,您就可以像下面这样确定要针对哪个环境进行构建:

    This way, you can then determine what environment you are building against like so:

    #ifdef ENV_DEV NSString * const MyAppAPIBaseURL = @"api-dev.myapp/"; #elif ENV_SAGING NSString * const MyAppAPIBaseURL = @"api-staging.myapp/"; #elif ENV_PROD NSString * const MyAppAPIBaseURL = @"api.myapp/"; #endif

    可能要花很多钱,但请告诉我您的情况.

    It's probably a lot to take in but let me know how you get on.

    然后,您还可以创建不同的用户定义的构建设置来执行不同的操作,例如更改应用程序的显示名称.

    You can then also create different user defined build settings to do different things, like change the display name of your app.

    您可以通过创建一个名为MYAPP_DISPLAY_NAME的新设置来做到这一点,例如,为每种配置设置正确的名称,然后在info.plist中将捆绑显示名称的值设置为$(MYAPP_DISPLAY_NAME).

    You could do this by creating a new setting called MYAPP_DISPLAY_NAME for example, set the correct name for each configuration and then in your info.plist set the value of the Bundle Display Name to $(MYAPP_DISPLAY_NAME).

更多推荐

使用不同的设置和名称来管理开发,测试和生产版本的最佳方法

本文发布于:2023-11-23 07:27:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620601.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   版本   测试   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!