Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Adding .mm files to the Xcode generated project?

Discussion in 'macOS' started by JakeSimpson, Apr 21, 2020.

  1. JakeSimpson

    JakeSimpson

    Joined:
    Dec 4, 2019
    Posts:
    20
    In IOS/tvOS it's possible to mark .mm files in the unity project as Import Files, with meta data associated to them (e.g. what platform they get included on, when generating XCode projects, plus what frameworks you might want to get - e.g. GameCenter etc).

    This allows for a cheap version of a plugin, where the .mm file is included in the resulting XCode project, and is compiled in with it.

    This is great, easy to use and convienent.

    With Unity 2019.3.0, the ability to generate an XCode project for OSX was added, which is also great.

    However, I cannot for the life of me figure out how to have the same solution work, where .mm files are included inside of that XCode project that is generated as part of the Build step for OSX?

    In the inspector, there's an All Platforms checkbox for the individual file, and if that's checked, then the list of platforms below are checked for exclusion. If the All Platforms box is not checked, then the resulting list of platforms below are checked for inclusion.

    Note - there is no OSX platform check box in the list of platforms (and there should be, for obvious reasons).

    With either exclusion (where everything is checked but StandAlone, since I only want this file included on an OSX build) or inclusion, (where only StandAlone is checked), the resulting .mm file does not get included in the XCode project.

    Nor am I able to select frameworks that I would want added to the resulting XCode project.

    I don't know if I'm using the wrong, or this feature is simply not implemented (which would be a problem, since the major reason for generating an XCode project in the first place was to have this feature work) - advice?
     
  2. JakeSimpson

    JakeSimpson

    Joined:
    Dec 4, 2019
    Posts:
    20
    It is worth noting that I can add this file manually to the XCode project for OSX, once it's opened in XCode, and also set the framework / capabilities I need, and that works, but that's a tremendous PIA and extra friction every time...
     
  3. JakeSimpson

    JakeSimpson

    Joined:
    Dec 4, 2019
    Posts:
    20
    Some more details on how this functionality is incomplete / doesn't work.

    • The generated XCode project does NOT take the bundle name from the player settings for OSX XCode projects - as it should do, and indeed does for IOS/tvOS projects.

    • There is no append ability for generating OSX projects, as there is for IOS/tvOS projects; the only option is Replace, which does mean I am forced to rebuild all my in project settings everytime I make a C# change and have to regenerate the project
    • But by far, the most egregious issue is that the resulting XCode project has some code in it somewhere that redirects Debug.Log() and NSLog() (For native code) to some output I cannot find. You see nothing in the debug console window of XCode at all. Not a sausage.
      Add to this the fact that any C# error will crash the entire player - with no stack trace I can follow to narrow down where - and this makes debugging an OSX build almost impossible. I wouldn't be so worried about it, but we are seeing code that works fine in IOS builds crash in OSX builds, and I've no clue why or even where to look, and this whole approach limits my ability to diagnose it.

      NB. Worth noting that C# debugging under OSX VS DOES work, however, once a break point is hit, once you hit play again, the entire Unity Player silently exits. No errors, no crash, it just shuts down. Which is a bit of a problem too.
     
  4. JakeSimpson

    JakeSimpson

    Joined:
    Dec 4, 2019
    Posts:
    20
    And yet another issue.

    The actual project file is missing certain names in some of the project and target sections so trying to use pxbProject on this, in a post build process (using the XCodeAssetPostProcessing suite of class) doesn't work. Asking the pxbProject class for the UnityMainTargetGuid or UnityFrameworkTargetGuid comes back with nulls.

    Needless to say, this seriously devalues the value of this feature.