我们正在为我们的 iOS 应用程序 使用单独的生产 和开发 数据库,并且我们正在通过 TestFlight 进行测试。 问题是 TestFlight 以 Release模式分发应用程序。
如何配置项目以便它在开发模式下分发应用程序?
或者我真的应该为发布和开发设置不同的构建标识符,然后在 TestFlight 中有两个应用程序吗?
通常做什么?
最佳答案
Summary of solution
我建议您在build设置中添加一个值。只有在构建生产版本时才将其设置为 PRODUCTION
。
只需使用 #if
语句来检查是否设置了 PRODUCTION
In my app (I use Batch for push notifications)
我有同一个应用的两个版本。一种是免费的,有广告,一种是付费的,没有广告。 我只是在免费版本中这样设置:
在付费版本中是这样的:
最后我在代码中使用了它 =]
// MARK: Batch.
#if FREE
#if DEBUG
print("Batch FREE - DEBUG mode")
Batch.start(withAPIKey: "-MY FREE VERSION DEBUG KEY-") // dev
#elseif RELEASE
print("Batch FREE - RELEASE mode")
Batch.start(withAPIKey: "-MY FREE VERSION RELEASE KEY-") // live
#endif
#elseif PAID
#if DEBUG
print("Batch PAID - DEBUG mode")
Batch.start(withAPIKey: "-MY PAID VERSION DEBUG KEY-") // dev
#elseif RELEASE
print("Batch PAID - RELEASE mode")
Batch.start(withAPIKey: "-MY PAID VERSION RELEASE KEY-") // live
#endif
#endif
// Register for push notifications
BatchPush.registerForRemoteNotifications()
In your case it will be manual due.
只有在构建到生产环境时,您才能在 Active Compilation Conditions
中设置 PRODUCTION
。
然后添加这段代码:
#if PRODUCTION
// Connect to production database
#else
// Connect to test database
#endif
关于ios - 在 Debug模式下分发 TestFlight 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47144417/