What is the best way to share Xcode content for projects targeted at many clients?

I have a relatively large Xcode project that creates one application. However, I have many clients / clients who require in-depth customization and branding of this application. These configurations include various graphics, several different interfaces and implementations, and perhaps most importantly, .xcconfig files.

My Xcode project has a dedicated group that points to a specific client settings folder on disk, therefore, opening the project and building Xcode, you will get a single application assembly with the current client settings. To switch to another client, I change where this group points to the disk. (I also change and switch the xcconfig “Based on” settings in the Project Information panel to reload the full xcconfig inheritance; just changing the group containing one or more xcconfig files does not reload it!) This worked great for 100+ clients. It’s a little tedious to switch this folder every time you need to create an application for another client and make sure xcconfig is correct, but it works.

Now I'm doing build automation through the command line and am facing problems. The quick and dirty solution for specifying the aforementioned Xcode group in another setup folder was to copy the ProjectName.xcodeproj/project.pbxproj file into ProjectName.xcodeproj/project-template.pbxproj and place placeholders in this file that could be grepped and replaced to the name and path to the desired settings folder, Then temporarily rewrite project.pbxproj with the modified project-template.pbxproj and create it to get the right application.

As you probably noticed, project.pbxproj has been duplicated and modified, and therefore it will not be synchronized, as developers will change the original and forget to also update the template. And besides, I don’t have to bother with pbxproj files at all this way - these are Xcode's personal stuff.

So, is there a better way to tell Xcode about a folder full of resources, code, and configuration files, perhaps during the build phase with a script variable or environment, rather than at the project group level? The most difficult bit seems to be the xcconfig chain, since each client has its own xcconfig file, which is inherited from the individual xcconfig debugging, development, and application distribution files.

Sorry for the longevity of this question, but it's a little complicated! Any suggestions would be greatly appreciated!

+7
source share
1 answer

I think you'd better use the goal function in Xcode. There is one project and the resources of each client in this project.

Then you can copy the existing target (right-click on the target by selecting the project file in Xcode Project Navigator).

All your goals will be compiled with the same code. You just need to change the resources in Build Phases> Copy Kit Resources to create different applications for each purpose. No need to look at the internal Xcode files.

You can even change the code in your source files by adding a preprocessor macro to your build options (something like FIRST_CLIENT=1 ), and then look for these definitions in your file with #if FIRST_CLIENT .

I have a project like this and it works pretty well:

enter image description here

+2
source

Source: https://habr.com/ru/post/899543/


All Articles