xcode 如何为 OEM 构建同一 iOS 应用程序的多个版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11473289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I build multiple versions of the same iOS application for OEMs
提问by snctln
I have an existing iOS application that I need to be able to build and release multiple versions of for different clients.
我有一个现有的 iOS 应用程序,我需要能够为不同的客户端构建和发布多个版本。
This application interfaces with hardware that is available from a handful of different companies, the hardware is identical but each company sells the hardware under a different name
此应用程序与少数不同公司提供的硬件接口,硬件是相同的,但每家公司以不同的名称销售硬件
This is a free app, the goal is not to spam the appstore with multiple versions of the same app, the goal is to allow companies that sell rebranded hardware to have a mobile app that uses the brand name that they use for the hardware.
这是一个免费的应用程序,目标不是向应用程序商店发送同一应用程序的多个版本的垃圾邮件,目标是允许销售更名硬件的公司拥有一个使用他们用于硬件的品牌名称的移动应用程序。
What I need to be able to do:
我需要能够做的:
- Build multiple versions of the same application that can be submitted to the Appstore, each version would be submitted under a different companies apple account. I would assume that means multiple projects so that each project can use a company specific provisioning profile
- Each version has some different images (Icon, startup image, maybe a few others)
- Each version has some different strings (Company name, Product Name, maybe a few others)
- 构建可以提交到Appstore的同一个应用程序的多个版本,每个版本将提交到不同公司的苹果帐户下。我认为这意味着多个项目,以便每个项目都可以使用公司特定的配置文件
- 每个版本都有一些不同的图像(图标、启动图像,也许还有其他一些)
- 每个版本都有一些不同的字符串(公司名称、产品名称,也许还有其他一些)
With Android I just create a library project and I can override strings and images with a trivial amount of effort.
使用 Android,我只需创建一个库项目,就可以轻松覆盖字符串和图像。
With iOS I haven't found an obvious answer.
对于 iOS,我还没有找到明显的答案。
I looked into adding a new target to my existing project but I don't think that will work: - I can't figure out how to replace images beyond the icon and starting screen - I can't figure out how to replace strings - Would I be able to use different provisioning profiles for the different apps that compile with the same project? I know the target settings allow different provisioning profiles, but doesn't the project settings have its own set of provisioning profiles?
我考虑向现有项目添加一个新目标,但我认为这行不通: - 我不知道如何替换图标和启动屏幕之外的图像 - 我不知道如何替换字符串 -我能否为使用同一项目编译的不同应用程序使用不同的配置文件?我知道目标设置允许不同的配置文件,但是项目设置没有自己的配置文件集吗?
Can I package the current application into a library that other projects can use and replace images/strings? So each version would have its own xCode project but use the same code.
我可以将当前应用程序打包到其他项目可以使用的库中并替换图像/字符串吗?所以每个版本都有自己的 xCode 项目,但使用相同的代码。
Maybe I need to work more with the idea of multiple targets...
也许我需要更多地处理多个目标的想法......
I am using xCode 4.2, but I am prepared to move to a newer version if necessary
我正在使用 xCode 4.2,但我准备在必要时迁移到更新版本
采纳答案by Erik
Create multiple targets that use different Info.plist files. The biggest difference will be different bundle identifiers. You can also define different preprocessor macros that will control the conditional compilation of various chunks of code.
创建多个使用不同 Info.plist 文件的目标。最大的区别是不同的包标识符。您还可以定义不同的预处理器宏来控制各种代码块的条件编译。
Alternatively/additionally, you can put your build configuration settings (including the changing location of the Info.plist file) into *.xcconfig files and reference those in your project, info, configurations area. Then, you can build a different version of your app by simply by changing your scheme. Putting build configration settings into files is a huge win for configuration control too.
或者/此外,您可以将构建配置设置(包括 Info.plist 文件的更改位置)放入 *.xcconfig 文件中,并在您的项目、信息、配置区域中引用这些设置。然后,您只需更改您的方案即可构建不同版本的应用程序。将构建配置设置放入文件也是配置控制的一个巨大胜利。
Here's a link to setting up *.xcconfig files: http://itcoding.blogspot.com/2011/03/using-xcconfig-abandoning-build-panel.html. I've seen other articles like this as well -- but this one will get you started.
这是设置 *.xcconfig 文件的链接:http://itcoding.blogspot.com/2011/03/using-xcconfig-abandoning-build-panel.html 。我也看过其他类似的文章——但这一篇会让你开始。
Good luck.
祝你好运。
回答by David H
I did this differently at my last company, where we generated around 8 apps from one primary source repository.
我在上一家公司的做法有所不同,我们从一个主要源存储库生成了大约 8 个应用程序。
We created one project that required one external class, call it Config. That class vended the unique info that makes each app unique.
我们创建了一个需要一个外部类的项目,称为 Config。该课程提供独特的信息,使每个应用程序都独一无二。
Then to spin one app you create your App project, include the common "library", provide the Config.m file (Config.h is common), add the unique images etc.
然后旋转一个应用程序,你创建你的应用程序项目,包括通用的“库”,提供 Config.m 文件(Config.h 是通用的),添加唯一的图像等。
回答by possen
This was very helpful for me. It is essentially the multi-target approach but you customize it for a company and you upload to their account.
这对我很有帮助。它本质上是多目标方法,但您可以为公司定制它并上传到他们的帐户。
https://developer.apple.com/videos/play/wwdc2019/304/See from the 17 minute mark.
https://developer.apple.com/videos/play/wwdc2019/304/从 17 分钟开始看。
To summarize, you partner with the company you are developing for, from their Apple Connect account, they assign you as the developer and marketing role for the specific apps you are developing for them. You upload your builds to their account. They get ultimate decision of when they will release it and who will test it with TestFlight.
总而言之,您与您为其开发的公司合作,通过他们的 Apple Connect 帐户,他们将您指定为您为他们开发的特定应用程序的开发者和营销角色。您将构建上传到他们的帐户。他们最终决定何时发布它以及谁将使用 TestFlight 对其进行测试。