Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mapping "Unity as a library" build configurations to main project's build configurations

Discussion in 'iOS and tvOS' started by ALantean, Jan 8, 2021.

  1. ALantean

    ALantean

    Joined:
    Nov 13, 2017
    Posts:
    8
    Hello all,
    I've integrated Unity as a library into a workspace and it's now a dependency of my main project, that is also in this workspace. As it is, this main project uses several different build configurations and depending on the selected build configuration, e.g., different backend endpoints are targeted.
    Now, Unity features the following build configurations, when it's exported: Debug, ReleaseForProfiling, ReleaseForRunning and Release.

    Per default Xcode tries to match build configuration on the basis of their names for dependent frameworks. That means that the main project build configuration "Debug" will map to the Unity Framework build configuration "Debug", because their names match. The thing is that my main project does not have any build configurations that exactly match the names of the build configurations of the Unity Framework.

    My goal is to map a build configuration from the main project to a build configuration from the Unity library. So when a specific main project build configuration is selected, the Unity Framework is build with a specific build configuration of my choosing.
    What I found so far is that Xcode falls back to whatever is set in "Project > Unity-iPhone > Info (Tab) > Use {config} for command-line builds", when a build configuration cannot be mapped via their names.

    Maybe someone has already dealt with a similar problem and can shed some light on this. As far as I can tell, there is no way to explicitly map a main project build configuration to a Unity Framework build configuration via e.g. "Targets > main-target > Build Settings (Tab)".

    The cleanest solution I've come up so far is to duplicate the build configurations of the Unity library to match the names of the main project build configurations. In Xcode this is quite easy, because there is a menu entry "Duplicate", which duplicates existing build configurations. Unfortunately, this is not supported by PBXProject, if I wanted to create these build configurations via PostProcessBuild.

    Kind regards.
     
  2. PavelLU

    PavelLU

    Unity Technologies

    Joined:
    Feb 23, 2017
    Posts:
    107
    in BuildPostProcess you can try to just string replace configuration name in Unity-iPhone.xcodeproj/project.pbxproj, at least ReleaseForRunning name is unique and probably will do a job

    another way is to change Xcode Trampoline project within Unity Editor. You can add/duplicate configuration, so every generated project will have this extra configuration.
     
  3. ALantean

    ALantean

    Joined:
    Nov 13, 2017
    Posts:
    8
    Thank you for the reply!

    How can I change the Xcode Trampoline project from within the Unity Editor? I can't seem to find any documentation regarding this.
     
  4. stacconi

    stacconi

    Joined:
    Jul 26, 2019
    Posts:
    4
    This is exactly the same problem I'm having. Did you find a way to do this?

    It would be nice if PBXProject had a method to Duplicate a configuration. Or if not, if we could list all the build properties for a given config. This way we could create a new config, and then copy all the values from a default one.

    I couldn't find any info on how to change the "Xcode Trampoline project in the Unity Editor" either.