Skip to content

Application referencing a native framework signing issue #5213

Closed

Description

@pp111

In my project I have referenced a Native framework (not signed). When I compile, the framework is copied to the bundle inside the /Contents/Frameworks as expected and everything works ok.

However when I try to deep sign the bundle it shows:
"bundle format is ambiguous (could be app or framework) In Subcomponent: "

According to Apple, only two things allowed at the root of a framework folder: symlinks and the Versions directory. I checked the original framework and it is compliant, however when Xamarin copies the framework to the bundle it replaces the symlinks with the real files.

To confirm this was the issue, I copied manually the framework to the the bundle and I was able to sign the bundle successfully.

As a workaround I added a postbuild task to my project to delete the framework from the compiled bundle and copy it with copy -R command to keep the symlinks.

Steps to Reproduce

  1. Create a new project and add a 3rd party framework as a native reference
  2. Compile to Release
  3. sign manually the bundle with:
    codesign --force --sign "my signature ID" "MyApplication.app" --deep

Expected Behavior

The native framework is copied to the bundle in /Contents/Frameworks as it is in the origin
Application signed correctly

Actual Behavior

Xamarin copied the Framework replacing symlinks with the real files
The codesign tool failed with:
"bundle format is ambiguous (could be app or framework) In Subcomponent: "

Environment

=== Visual Studio Community 2017 for Mac ===

Version 7.7 (build 1868)
Installation UUID: e238b76e-7013-49fd-9574-267eccb5a563
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e)

Package version: 516000221

=== Mono Framework MDK ===

Runtime:
Mono 5.16.0.221 (2018-06/b63e5378e38) (64-bit)
Package version: 516000221

=== NuGet ===

Version: 4.7.0.5148

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.2
2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
2.1.302
2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Not Installed

=== Android Device Manager ===

Version: 7.7.1.0
Hash: 06ceaea1

=== Apple Developer Tools ===

Xcode 9.4.1 (14161)
Build 9F2000

=== Xamarin.Mac ===

Version: 5.2.1.11 (Visual Studio Community)
Hash: 5ef73d3
Branch:
Build date: 2018-11-21 00:03:25-0500

=== Xamarin.iOS ===

Xamarin.iOS not installed.
Can't find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 707001868
Git revision: 8bcdfa96d67c8c88dc45728cc968a2f84b55322f
Build date: 2018-11-22 12:19:29+00
Build branch: release-7.7
Xamarin extensions: d66dbedcda237cd9b546abfecfeecafba6f8e3cb

=== Operating System ===

Mac OS X 10.14.0
Darwin 18.0.0 Darwin Kernel Version 18.0.0
Wed Aug 22 20:13:40 PDT 2018
root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

Build Logs

Example Project (If Possible)

Test.zip

Activity

  1. VincentDondain commented on Nov 30, 2018

    @VincentDondain
    Contributor

    Hi,

    Sorry I'm having a hard time reproduce this issue.

    I created a new iOS project and added an Objective-C native framework I manually created as native reference.

    1. The native framework isn't copied to /Contents/Frameworks, only MyApp.app/Frameworks/MyFramework.framework.
    2. I do not have issues running codesign --force --sign "my signature ID" "MyApplication.app" --deep on that app bundle... I simply get iOSTest.app: replacing existing signature. Also I'm not quite sure why you're trying to manually run the codesign --deep.

    Could you please provide us a test case or different instruction to reproduce this?

  2. added
    need-infoWaiting for more information before the bug can be investigated
    iOSIssues affecting iOS
    on Nov 30, 2018
  3. added this to the Future milestone on Nov 30, 2018
  4. pp111 commented on Nov 30, 2018

    @pp111
    Author

    Hi,

    the project is for Mac, not iOS.

  5. pp111 commented on Nov 30, 2018

    @pp111
    Author

    I added a test case.

    As you can see in the test case, the native framework that is in the Release/Test.app/Contents/Frameworks/MMTabBarView.framework has the file MMTabBarView directly in the root instead of a symlink to it like in the original library.

  6. VincentDondain commented on Nov 30, 2018

    @VincentDondain
    Contributor

    Ah yes I can confirm the issue with Xamarin.Mac and your test case. Your framework is different than mine because it's using symlinks.

    I do see that when building for release, our build steps seem to replace the MMTabBarView binary symlink by the actual file.

    I also got:

    codesign --force --sign XXX Test.app --deep
    Test.app: bundle format is ambiguous (could be app or framework)
    In subcomponent: /Users/vidondai/Downloads/Test/Test/bin/Release/Test.app/Contents/Frameworks/MMTabBarView.framework
    

    I was also able to confirm that Xamarin.iOS behaves correctly with a .framework with symlinks like yours. It's not removing the symlinks (as expected).

    Change this to a macOS only issue.

    Thanks a lot.

  7. added
    bugIf an issue is a bug or a pull request a bug fix
    macOSIssues affecting macOS
    and removed
    iOSIssues affecting iOS
    need-infoWaiting for more information before the bug can be investigated
    on Nov 30, 2018
  8. spouliot commented on May 12, 2021

    @spouliot
    Contributor

    That was likely fixed in the .xcframework support (late last year) even if it seems (user report) stable d16-9 does not have all the fixes.

    Using main we can see Contents/Frameworks/MMTabBarView -> Versions/Current/MMTabBarView so the symlinks are preserved.

    $ tree /Users/poupou/Downloads/Test/Test/bin/Release/Test.app
    /Users/poupou/Downloads/Test/Test/bin/Release/Test.app
    └── Contents
        ├── Frameworks
        │   └── MMTabBarView.framework
        │       ├── MMTabBarView -> Versions/Current/MMTabBarView
        │       ├── Resources -> Versions/Current/Resources
        │       └── Versions
        │           ├── A
        │           │   ├── MMTabBarView
        │           │   └── Resources
        │           │       ├── AdiumGradient.png
        │           │       ├── AquaTabCloseDirty_Front.png
        │           │       ├── AquaTabCloseDirty_Front_Pressed.png
        │           │       ├── AquaTabCloseDirty_Front_Rollover.png
        │           │       ├── AquaTabClose_Front.tiff
        │           │       ├── AquaTabClose_Front_Pressed.tiff
        │           │       ├── AquaTabClose_Front_Rollover.tiff
        │           │       ├── AquaTabNew.tiff
        │           │       ├── AquaTabNewPressed.tiff
        │           │       ├── AquaTabNewRollover.tiff
        │           │       ├── AquaTabsBackground.png
        │           │       ├── AquaTabsDown.png
        │           │       ├── AquaTabsDownGraphite.png
        │           │       ├── AquaTabsDownNonKey.png
        │           │       ├── AquaTabsSeparator.png
        │           │       ├── AquaTabsSeparatorDown.png
        │           │       ├── Info.plist
        │           │       ├── SafariAWATClose.tiff
        │           │       ├── SafariAWATClosePressed.tiff
        │           │       ├── SafariAWATCloseRollover.tiff
        │           │       ├── SafariAWATFill.tiff
        │           │       ├── SafariAWATLeftCap.tiff
        │           │       ├── SafariAWATRightCap.tiff
        │           │       ├── SafariAWAddTabButton.png
        │           │       ├── SafariAWAddTabButtonPushed.png
        │           │       ├── SafariAWAddTabButtonRolloverPlus.png
        │           │       ├── SafariAWBG.png
        │           │       ├── SafariAWITClose.tiff
        │           │       ├── SafariAWITClosePressed.tiff
        │           │       ├── SafariAWITCloseRollover.tiff
        │           │       ├── SafariAWITLeftCap.tiff
        │           │       ├── SafariAWITRightCap.tiff
        │           │       ├── SafariIWATClose.tiff
        │           │       ├── SafariIWATClosePressed.tiff
        │           │       ├── SafariIWATCloseRollover.tiff
        │           │       ├── SafariIWATFill.png
        │           │       ├── SafariIWATLeftCap.tiff
        │           │       ├── SafariIWATRightCap.tiff
        │           │       ├── SafariIWAddTabButton.png
        │           │       ├── SafariIWBG.png
        │           │       ├── SafariIWITClose.tiff
        │           │       ├── SafariIWITClosePressed.tiff
        │           │       ├── SafariIWITCloseRollover.tiff
        │           │       ├── SafariIWITLeftCap.tiff
        │           │       ├── SafariIWITRightCap.tiff
        │           │       ├── TabClose_Dirty.tiff
        │           │       ├── TabClose_Dirty_Pressed.tiff
        │           │       ├── TabClose_Dirty_Rollover.tiff
        │           │       ├── TabClose_Front.tiff
        │           │       ├── TabClose_Front_Pressed.tiff
        │           │       ├── TabClose_Front_Rollover.tiff
        │           │       ├── TabNewMetal.png
        │           │       ├── TabNewMetalPressed.png
        │           │       ├── TabNewMetalRollover.png
        │           │       ├── en.lproj
        │           │       │   └── InfoPlist.strings
        │           │       ├── overflowImage.tiff
        │           │       ├── overflowImagePressed.tiff
        │           │       └── pi.png
        │           └── Current -> A
        ├── Info.plist
        ├── MacOS
        │   └── Test
        ├── MonoBundle
        │   ├── System.dll
        │   ├── Test.exe
        │   ├── Xamarin.Mac.dll
        │   ├── config
        │   ├── libmono-native.dylib
        │   └── mscorlib.dll
        ├── PkgInfo
        └── Resources
            ├── AppIcon.icns
            ├── Assets.car
            ├── MainMenu.nib
            ├── MainWindow.nib
            └── runtime-options.plist
    
    12 directories, 74 files
    

    https://gist.github.com/spouliot/b749d8d0c33489a90da050a8a9c84a47

  9. xfortin-devolutions commented on May 17, 2021

    @xfortin-devolutions

    I've had to update Sparkle in my application and encountered the same issue. This is especially weird since older Framework (that have not been updated) do not have this issue. Any idea when this will be fixed in an official version?

  10. ghost locked as resolved and limited conversation to collaborators on May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixmacOSIssues affecting macOS

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions