简体   繁体   English

两个具有相同代码库的项目

[英]Two projects with same code base

Is it possible to have two projects in XCode using the same codebase? 是否可以在XCode中使用相同的代码库进行两个项目?

I have an app which offers a demo version and a full version. 我有一个提供演示版和完整版的应用程序。 They both share the same code and I just set a flag in my plist file, and somewhere in my code I do 它们共享相同的代码,我只是在plist文件中设置了一个标志,并且在我的代码中的某个地方

if (demo_mode) {
    // ...
} else {
    // ...
}

This is easy for testing, but not suitable for the app store, since I want slightly different app icons and app names for them. 这很容易进行测试,但不适合应用程序商店,因为我需要稍微不同的应用程序图标和应用程序名称。

I could as well make a copy of the project, but then I'd have to apply changes in one project to the other (bugfixes, UI changes etc). 我也可以制作一个项目的副本,但是我必须将一个项目中的更改应用到另一个项目(错误修正,UI更改等)。 That's why I want to use the same source folder for two projects. 这就是为什么我想为两个项目使用相同的源文件夹。

You are probably going to use StoreKit to provide a non-consumable purchase for users to upgrade, and use this as your flag. 您可能会使用StoreKit为用户提供非消耗品升级,并将其用作您的标志。 StoreKit usually involves a good deal of boilerplate, so you might consider implementing something like MKStoreKit to handle some of that for you. StoreKit通常涉及大量样板文件,所以你可以考虑实现像MKStoreKit这样的东西来为你处理一些问题。 You can use MKStoreKit to easily check if the user has purchased the upgrade or not. 您可以使用MKStoreKit轻松检查用户是否购买了升级。 Restoring purchases is also relatively easy. 恢复购买也相对容易。

All you need is one project with two target. 您只需要一个有两个目标的项目。

You can make different config or file with different target, also share the same code, but submit to App Store separately. 您可以使用不同的目标制作不同的配置或文件,也可以共享相同的代码,但可以单独提交到App Store。

Let me know if you need more help. 如果您需要更多帮助,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM