xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.45k stars 511 forks source link

Nest framework problem #5624

Open juepiezhongren opened 5 years ago

juepiezhongren commented 5 years ago

ios's umbrella framework which has a umbrella framework dependence could run on monitor but not on device, any solution? https://github.com/yinchengvy/Hyphenate.iOS.UI.git @rolfbjarne

rolfbjarne commented 5 years ago

Reference: https://xamarinhq.slack.com/archives/C99ER4A1M/p1550568216118800

dyld: Library not loaded: @rpath/MJRefresh.framework/MJRefresh
 Referenced from: /private/var/containers/Bundle/Application/163A7ACD-33D2-4CA7-8FC1-EB41A0700911/XamSample.iOS.app/Frameworks/EaseUI.framework/EaseUI
 Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/163A7ACD-33D2-4CA7-8FC1-EB41A0700911/XamSample.iOS.app/Frameworks/EaseUI.framework/Frameworks/MJRefresh.framework/MJRefresh: code signature in (/private/var/containers/Bundle/Application/163A7ACD-33D2-4CA7-8FC1-EB41A0700911/XamSample.iOS.app/Frameworks/EaseUI.framework/Frameworks/MJRefresh.framework/MJRefresh) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

It seems we're not signing nested frameworks.

dalexsoto commented 5 years ago

@juepiezhongren Thank you for your report!

As a workaround, use this in your yourapp.csproj, you will need to accommodate the path to your needs.

Add after:

<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />

the following:

<Target Name="BeforeCodesign">
    <Exec Command="\usr\bin\codesign -v --force --sign $(_CodeSigningKey) --timestamp=none $(ProjectDir)/$(AppBundleDir)/Frameworks/UmbrellaFramework.framework/Frameworks/SubFramework.framework/SubFramework" />
</Target>

If you have multiple nested frameworks, just duplicate the Exec step as many times as needed.

yinchengvy commented 5 years ago

@dalexsoto Thanks. And I add Condition=" '$(Platform)' == 'iPhone', because this problem only found on iphone device.

<Target Name="BeforeCodesign">
    <Exec Condition=" '$(Platform)' == 'iPhone' Command="\usr\bin\codesign -v --force --sign $(_CodeSigningKey) --timestamp=none $(ProjectDir)/$(AppBundleDir)/Frameworks/UmbrellaFramework.framework/Frameworks/SubFramework.framework/SubFramework" />
</Target>