Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Resolved (macOs) .bundle plugins can't be signed in xcode projects, 2019.4.8 change is not sufficient

Discussion in 'macOS' started by jason_yak, Sep 9, 2020.

  1. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Hi there,

    I've found an issue with the xcode project compiling for mac. Here are the details (I've submitted a repro project for this, issue id: 1276317):

    Please note this is not a duplicate bug report either. It's a development on a previous issue that was reported as fixed in 2019.4.8

    Steps:
    1. Create a new project in 2019.4.9, the only modification I've done is to add a plugin .bundle for Mac
    2. In Build Settings make sure the standalone mac platform is active, enable Create Xcode Project and Build out an xcode project
    3. Trying to then compile results in code sign error:

    CodeSign /Users/jason/Library/Developer/Xcode/DerivedData/MacXcode-ddporllwmsqitcfnqhidpczffuop/Build/Intermediates.noindex/ArchiveIntermediates/MacXcode/InstallationBuildProductsLocation/Applications/MacXcode.app/Contents/PlugIns
    cd /Users/jason/Desktop/MacXcode/Build
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate

    Signing Identity: "-"

    /usr/bin/codesign --force --sign - --preserve-metadata=identifier,entitlements,flags --timestamp=none /Users/jason/Library/Developer/Xcode/DerivedData/MacXcode-ddporllwmsqitcfnqhidpczffuop/Build/Intermediates.noindex/ArchiveIntermediates/MacXcode/InstallationBuildProductsLocation/Applications/MacXcode.app/Contents/PlugIns

    A copy files phase was added for the Plugins in 2019.4.8, but this change is not sufficient at adding bundle plugins into a generated xcode project despite this issue being declared as fixed: https://issuetracker.unity3d.com/issues/macos-bundle-plugins-are-not-linked-on-xcode-project-export

    This is the result from 2019.4.8:
    https://www.dropbox.com/s/6fru063gzat5mny/MacCompileError1.png?dl=0

    But this is the result that it should be which matches the xcode projects generated in iOS and allows bundles to be correctly signed:
    https://www.dropbox.com/s/n75h69p32zkryq9/MacCompileError2.png?dl=0

    Note that the correct copy phase is set to PlugIns and has 'Code Sign on Copy' enabled per bundle. The copy phase set to Wrapper that was added in 2019.4.8 does not allow this setting to be set on the static plugins folder and makes it impossible to compile at the moment using the mac Xcode project option. The change that addds a static plugins copy phase needs to be removed again is not correct. The solution for this should match what iOS project creation does. We have taken a copy of the PBXProject api and modified this to properly add the bundles, please reach out if it would help to get a copy of how we did this if it speeds up implementation, but as it stand this is the single biggest blocker for Unity developers that want to use the Xcode project option for Mac and because it's a extremely technical process to modify the PBXProject properly many developers we know have given up on trying to use the xcode project for mac option because of this.
     
  2. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    91
    Not sure if it helps or if your issue is deeper, but I had something similar the other day and fixed it by renaming the PlugIns folder in the xcode project to Plugins (lower case i).
     
  3. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Thanks but no it's more of a matter that the xcode project generated is not sufficiently code signing bundled plugins. The output folder name Unity were incorrectly using in precompiled .app builds 'Plugins' was recently renamed to PlugIns to match the correct mac app structure. My post processing script is adding a pass that happens to be adding a reference group in the xcode project Plugins with lowecase i, but it's not important, it's more to do with the output of the app and those plugins are added in the copy phase to the correctly named PlugIns folder. Without this setup xcode never signs the bundle files. If you open up an xcode project generated for iOS that uses a .bundle file it has the correct setup, the mac xcode project at the moment doesn't, it just needs to replicate the exact same process that iOS xcode project creation uses.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,111
    Thanks for the bug report. We'll take a look at it.
     
    jason_yak likes this.
  5. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Thanks =) it would be so great if plugins were handled properly.
     
  6. wklefhjweh38473847384847

    wklefhjweh38473847384847

    Joined:
    Jan 27, 2021
    Posts:
    2
    What's the status of this?
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,111
    Fixed in 2021.1 beta, backports to 2020.2 and 2019.4 are in progress.
     
  8. Mad-hotdog

    Mad-hotdog

    Joined:
    Apr 5, 2016
    Posts:
    2
    Is there any ETA on the 2020.2 backport? It looks like it missed the most recent release and this is kinda blocking us submitting our game.
     
  9. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    @Tautvydas-Zilys Hi there, I've seen that this bug fix has made it into 2020.3.0 however it's introducing a new compiler error: https://issuetracker.unity3d.com/issues/xcode-macos-bundle-plugins-are-not-signed-in-xcode-projects

    While this fix correctly adds the missing copy file phase and adds bundles marked to be signed, windows based DLL files are being swept up and incorrectly added to copy phase as well which should not be there and obviously cause the xcode compiler to fail. It's easily replicated in a new empty project by compiling with 2020.3.0, Rewired plugin added, build target set to Mac and create xcode project ticked in build settings. Trying to compile in the generated xcode project and it will fail to compile.

    I've submitted a repro project bug report: 1321049

    For now I've had to do this post processing workaround to remove incorrectly added DLL's using PBXProject api:
    project.RemoveFile( project.FindFileGuidByProjectPath( $"{PlayerSettings.productName}/PlugIns/SomeWindowsPlugin.dll" ) );
     
  10. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Note: that my workaround is not perfect though. It leaves some strange remnants in the build phase which I can't remove without editing the project as a raw string because the PBXProject api does not have any exposed methods that allow me to remove a build file reference from build phases properly. But it removes the files enough that I can compile the project and should not cause any runtime issues...?!
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,111
    Damn, sorry about that :(. I'll make sure we prioritize fixing this.
     
    jason_yak likes this.
  12. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Thanks =) it's super close to being how we need it, just this one glitch. I've tried compiling a few different projects which have different sets of DLL files and yup it can get pretty nuts on the results where various references to unrelated editor DLL's can be compiled into the xcode build phase. The workaround I've mentioned seems to be working pretty well in the meantime. Thanks for prioritzing it, cheers!
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,111
    Hey, I implemented a fix for this yesterday, and hoping to get it reviewed and merged as soon as possible. Hang tight!

    By the way, yesterday somebody clicked the wrong button on the bug and instead of commenting on it, they sent an email to you. Feel free to disregard it...
     
  14. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Thanks for the fast turn around, really appreciate it, cheers :)
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,111
    Hey, the fix landed to 2020.3.5f1.
     
    jason_yak likes this.
  16. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Brilliant, thanks for letting me know :)
     
  17. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    415
    Can confirm 2020.3.5 fixes the issue where Window's based DLL plugin files were being added to Xcode projects compiled for Mac.
     
unityunity