# ChangeEnvironmentManager **Repository Path**: zj1208/ChangeEnvironmentManager ## Basic Information - **Project Name**: ChangeEnvironmentManager - **Description**: iOS原生。切换环境SDK - **Primary Language**: Objective-C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-14 - **Last Updated**: 2025-09-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 项目名称 '切换环境,支持日常,预发,线上三种环境切换;支持Debug,Profile,Release三种模式展现不同的环境.' Debug:用于模拟器测试 Profile:Release编译,用于真机内测,支持Flutter工程 Release:发布固定 环境选择建议: 1. 小型团队或初创公司 本地环境 + 测试环境 + 生产环境 理由:资源有限,简化环境管理,确保基本开发和测试需求。 2. 中型团队 本地环境 + 开发环境 + 测试环境 + 生产环境 理由:增加开发环境,便于团队协作和集成测试。 3. 大型团队或复杂业务 本地环境 + 开发环境 + 日常环境 +测试环境 + 预发布环境 + 生产环境 理由:增加预发布环境,确保上线前的最终验证,减少生产环境的风险。 ## 运行条件 s.dependency 'Masonry', '~>1.1.0' ###import - (void)envConfig { ChangeEnvironmentManager *manager = [ChangeEnvironmentManager startWithOnlineHost:Api_DomainName_Release preHost:Api_DomainName_Pre dailyHost:Api_DomainName_Dev]; #ifdef DEBUG [manager setBuildConfiguration:BuildConfigurationDebug]; ####elif PROFILE [manager setBuildConfiguration:BuildConfigurationProfile]; ####else [manager setBuildConfiguration:BuildConfigurationRelease]; ####endif [ChangeEnvironmentManager configApiEnv]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeEnvironment:) name:kEnvironmentChangeNotification object:nil]; } - (void)changeEnvironment:(NSNotification *)noti{ [ChangeEnvironmentManager configApiEnv]; //业务处理,flutter小工具切换,网络切换 [MainViewController nativeToFlutterRefreshEnv]; [self networkConfig]; } ###import "CHSViewController.h" ###import ###import @interface CHSViewController () @property (nonatomic, strong) UIButton *changeEnvironmentBtn; @end @implementation CHSViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self.view addSubview:self.changeEnvironmentBtn]; [self.changeEnvironmentBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.view.mas_left).with.offset(12); make.right.mas_equalTo(self.view.mas_right).with.offset(-12); make.centerY.mas_equalTo(self.view.mas_centerY).with.offset(20); }]; } -(UIButton *)changeEnvironmentBtn{ if (!_changeEnvironmentBtn) { _changeEnvironmentBtn = [UIButton new]; [_changeEnvironmentBtn addTarget:self action:@selector(changeEnvironmentBtnAction:) forControlEvents:UIControlEventTouchUpInside]; [_changeEnvironmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; ###ifdef DEBUG [_changeEnvironmentBtn setTitle:@"Debug模式,切换环境" forState:UIControlStateNormal]; ###else [_changeEnvironmentBtn setTitle:@"Profile/Release模式,切换环境" forState:UIControlStateNormal]; ###endif } return _changeEnvironmentBtn; } ###//点击切换开发环境 - (void)changeEnvironmentBtnAction:(id)sender { UIViewController *vc = [ChangeEnvironmentController controller]; [self.navigationController pushViewController:vc animated:YES]; } ## Installation pod 'ChangeEnvironmentManager' ## Author 海参, 879654715@qq.com ## License ChangeEnvironmentManager is available under the MIT license. See the LICENSE file for more info. ## Push pod spec lint --allow-warnings --verbose --no-clean pod repo push gitee-zj1208-specs /Users/simon/ChangeEnvironmentManager/ChangeEnvironmentManager.podspec --allow-warnings --verbose