英文:
How can I specify a unique/different App struct for each target?
问题
我有一个Xcode项目,其中有不同的目标,根据正在构建的目标,我想使用不同的@main
应用程序结构。我应该在目标中的哪个位置指定要用于加载/运行应用程序的实际主要应用程序结构?此外,我如何为应用程序图标做到这一点。
我尝试查看每个目标的设置,但无法找到任何指定此项的地方。
英文:
I have an xcode project with different targets, and depending on which target is being built, I want to use a different @main
App struct. Where can i specify in my target the actual main App struct to be used to load / run the app? Also, how could I do that for the app icon as well.
I tried looking into the settings of each target and i was unable to find any place to specify this.
答案1
得分: 1
在设置中,您可以做很多事情。更改应用程序图标应该是其中之一。
其余部分,我发现通过复制/分支文件然后选择哪个目标应该使用哪些文件是最有帮助的。
对于资源,您可以例如为每个目标拥有一个资产加上共享资产。
因此,在您的情况下,要拆分@main
,您将创建两个主文件,可能具有相同的名称但位于不同的文件夹中。您将为每个文件选择一个目标,并为它们单独编写实现。
使用这种第二种方法,您几乎可以进行任何类型的按目标分支。甚至无需更改应用程序图标名称,因为您可以重用相同的名称,但包含不同的资源目录。
英文:
You can do a lot in settings. Changing an app icon should be one of them.
The rest I find it most helpful to do by duplicating/branching files and then select which target should use which files.
For resources you could for instance have one assets per target plus shared assets.
So in your case to split the @main
you would create two main files, possibly with same name but in different folders. You would select a target for each of the files and have a separate implementation for them.
You can do pretty much any kind of per-target branching with this second approach. There is even no need to change the app icon name as you can reuse the same name but include a different asset catalog.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论