Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Linker Error on Build #1393

Closed
hollyschilling opened this issue Jul 9, 2020 · 10 comments · Fixed by #1440
Closed

[BUG] Linker Error on Build #1393

hollyschilling opened this issue Jul 9, 2020 · 10 comments · Fixed by #1440
Labels
Milestone

Comments

@hollyschilling
Copy link

hollyschilling commented Jul 9, 2020

Building a Xamarin Forms (currently 4.7.0.1080) project fails when using SkiaSharp 2.80.0.

error MT5209 : Native linking error : framework not found libSkiaSharp
MTOUCH : error MT5202: Native linking failed. Please review the build log.

Steps to reproduce:

  1. In Visual Studio for Mac, create a new Xamarin Forms app using Blank Forms App template.
  2. Upgrade NuGets on all 3 projects, Android, iOS, and Common. (Xamarin Forms -> 4.7.0.180; Xamarin Essentials -> 1.5.3.2)
  3. Add SkiaSharp.Views.Forms (2.80.0) NuGet to the shared project.
  4. Add a reference to SkiaSharp new SKCanvasView(); to MainPage.xaml.cs to prevent the Linker from pruning out SkiaSharp.
  5. Perform Build All.

SkiaLinkerDemo.zip

Expected Behavior

App should build and be able to launch.

Actual Behavior

Build for iOS fails with linker errors.

Basic Information

  • Version with issue: 2.80.0
  • Last known good version: 1.68.3
  • IDE: Visual Studio for Mac v8.6.5
IDE/OS information (click to expand)
Visual Studio Community 2019 for Mac
Version 8.6.5 (build 23)
Installation UUID: 06132a91-56f5-4cdb-afc7-6be5f4773937
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 610000104

Mono Framework MDK
Runtime:
	Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
	Package version: 610000104

Roslyn (Language Service)
3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

NuGet
Version: 5.6.0.6591

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.1.301/Sdks
SDK Versions:
	3.1.301
	3.1.300
	3.1.202
	3.1.200
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	3.1.5
	3.1.4
	3.1.2
	2.1.19
	2.1.18
	2.1.17
	2.1.16

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

Updater
Version: 11

Apple Developer Tools
Xcode 11.5 (16139)
Build 11E608c

Xamarin.Mac
Version: 6.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:04-0400

Xamarin.iOS
Version: 13.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

Xamarin Designer
Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

Xamarin.Android
Version: 10.3.1.4 (Visual Studio Community)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: **REMOVED**
	Supported Android versions:
		None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

Microsoft OpenJDK for Mobile
Java SDK: **REMOVED**
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:42:50 UTC

Android Device Manager
Version: 16.6.0.96
Hash: 6e8b80b
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:43:28 UTC

Build Information
Release ID: 806050023
Git revision: 5289d413b99fddfc20b4ecf3e445ccb822213427
Build date: 2020-06-18 12:08:30-04
Build branch: release-8.6
Xamarin extensions: 5289d413b99fddfc20b4ecf3e445ccb822213427

Operating System
Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
    Tue May 26 20:41:44 PDT 2020
    root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
@mattleibow
Copy link
Contributor

Looking at the sample, seems that it can't find the native library. It appears that the app is pulling the managed library, but not the framework.

This is probably related to #1296 where the native library is not embedded. This fixes issues with upgrades, but seems to break the case where the skiasharp packages were not also installed into the app project.

I'll have a look at using the buildTransitive folder as well (#1041 and #1057).

But, the easiest and quickest solution is to just install the package into iOS as well.

@inforithmics
Copy link

I had the same problem I fixed it by
Disabling following Build options in the Debug Configuration:

  • Enable incremental builds
  • Enable device-specific builds

afterwards it worked.

@tstuts
Copy link

tstuts commented Jul 23, 2020

@mattleibow We're seeing a similar issue in our Xamarin.Mac app. After going from 1.68.3 to 2.80.1 we no longer get libSkiaSharp.dylib in the app bundle. Adding the SkiaSharp package to our app project directly does work as a workaround. Do you want a repro?

@mattleibow
Copy link
Contributor

Hi folks, I think I know what to do for this issue. I'll update with the next release.

But, installing SkiaSharp into the head projects is a good workaround for now.

@freever
Copy link

freever commented Aug 23, 2020

I have installed 2.80.2-preview19 into ALL my projects.

The line paint = new SKPaint(); throws a type load exception on Android:
"libSkiaSharp.so assembly: type: member:(null)"
at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_compatpaint_new()
at SkiaSharp.SKPaint..ctor () [0x00000] in :0

EDIT: reverting to 1.68.3 makes the problem go away

@taublast
Copy link
Contributor

taublast commented Sep 2, 2020

I had the same problem I fixed it by
Disabling following Build options in the Debug Configuration:

  • Enable incremental builds
  • Enable device-specific builds

afterwards it worked.

The above is not working for me at all.
"installing SkiaSharp into the head projects is a good workaround for now." solved this.

@inforithmics
Copy link

I had the same problem I fixed it by
Disabling following Build options in the Debug Configuration:

  • Enable incremental builds
  • Enable device-specific builds

afterwards it worked.

The above is not working for me at all.
"installing SkiaSharp into the head projects is a good workaround for now." solved this.

Yes this is the recommanded workaround, the problem was that I had installed Skia.Sharp already in the head projects and it still didn't work. So the workaround is in addition to installing Skia.Sharp in the head projects

@taublast
Copy link
Contributor

taublast commented Sep 2, 2020

Yes have installed SkiaSharp.Views.Forms in head projects for ok result.

@inforithmics
Copy link

I forget to mention that I installed SkiaSharp and SkiaSharp.Views.Forms in the head projects.

Maybe it is an issue with Svg.Skia (because this I use for Svg Images in Skia). I didn't do a Full investigation why it didn't work.
Only did trial and error until it worked.

@mattleibow mattleibow added this to the v2.80.2 milestone Sep 11, 2020
@mattleibow
Copy link
Contributor

Just for future reference, it might be the issue with incremental builds, so we should be disabling them.

FoggyFinder added a commit to verybadcat/CSharpMath that referenced this issue Jun 21, 2021
… customizable (#164)

* Add TextColor property to BaseButton and make MathInputButton's color customizable

The main goal of this commit is to make keyboard colors customizable (per keyboard key) to fit an app's color theme(s). For example, a dark keyboard background with light button texts.

CSharpMath.Forms:
- Refactor BaseButton's constructor.
- Add TextColor property to BaseButton and a bindable TextColorProperty.
- Remove the predefined Red color from MathInputButton.InputToLaTeX(input) for "Backspace" and "Clear".

CSharpMath.Forms.Example (MathKeyboard.xaml):
- Use the TextColorProperty in the Style of "Backspace" and "Clear", setting it to Red.

* Add a few ButtonTests and refactor out use-once functions from BaseButton

Notes:
- I guessed that CSharpMath.Forms needs a Test project of its own.
- It seems to deviate from the current coding style to have such a class, but I needed to make sure that the unit test MathInputButtonsHaveBackTextColorByDefault could detect the "phantom" and thus I added a static class LatexHelper that contains the temporary implementation of a "fake" vphantom. I also added the method SetColor(latex,Xamarin.Forms.Color).

* Fix typo in unit test name MathInputButtonsHaveBlackTextColorByDefault

* ButtonTests: use [ClassData] attribute, use NotNull<T>() extension, include in slnf

- Instead of IEnumerable<MathInputButton> TheMathInputButtons, use the [ClassData] attribute, introducing TestHelper.ComplexClassData<T> that can pass classes instead of ValueType data.
- Instead of using the ! (null-forgiving) operator, introduce and use NotNull<T>() extension that throws a Xunit.Sdk.NotNullException if the object is null and otherwise returns the not-null object. (Note: the namespace deviates from the folder structure, so that it is available everywhere in the test project without the need to add a using statement.)
- Improve logic in Assert of AllMathInputButtonsHaveLatexContent.
- Add CSharpMath.Forms.Tests to CSharpMath.CrossPlatform.slnf.

Maybe the newly created classes can be used in other parts of the solution as well, but I don't feel comfortable deciding that. Most of the code is very compact and adding classes feels like ignoring that coding style. Also, I am not very confident that those classes I have created meet the expected standards. I therefore put them "close to where they are used".

* Update CSharpMath.CrossPlatform.slnf (suggested commit))

Co-authored-by: Hadrian Tang <[email protected]>

* ButtonTests: use the [MemberData] attribute and MathKeyboardInput enum for individual testcases + do some cleaning

- NotNull.cs: remove pragma directives and unused namespace usings.
- Rename LatexHelper's vphantom to phantom, as the intention is to also add a tiny bit of horizontal spacing.
- ButtonTests: use the [MemberData] attribute and remove TestHelpers.ComplexClassData. Use the MathKeyboardInput enum as method parameter type, since only xunit-serializable types will result in individual test cases.
- Remove unused linked file from CSharpMath.Forms.Tests.csproj.
- Restore deleted space from commit 4a56307, and remove another white line. (I committed the suggestion to see its result: I didn't understand why the space character seemed to be removed at the start of the line and I thought it had something to do with my Visual Studio settings. Now I know that the suggested change was removing the white line and that the removed space character was not the intention.)

* Rename and move file from TestHelpers/NotNull.cs to /Extensions.cs

* Add ButtonBase.TextColorProperty Xaml Tests to CSharpMath.Forms.Tests

Notes:
- I changed the namespace of Extensions.NotNull and made the class partial, so that it can be linked from any test project.
- I am still in doubt about what is the right folder/project structure for the tests.

Long description of this last comment:
-- The name Xaml refers to the markup language and if code behind stuff should be included in that project, then maybe "UI" is a better name than "Xaml".
-- The class names are very broad: for example, "Test" seems to say that that is the main file that should include all tests. But that is set up only for tests that are shared between Avalonia and Xamarin.Froms. When thinking about creating a file that is for testing Xamarin.Forms only, I bump into the fact that one file is called TestXamarinForms.cs but that file has a completely different purpose than being the container for unit tests.
-- Postponing the decision to restructure - or actually awaiting to hear your preferences - I used external links. I wouldn't mind making the change or even thinking up a new the structure, but without that request I won't do that of course (as a newbie/guest to the project).

* Add MathInputButton_Command unit test and do the suggested cleaning

- Add MathInputButton_Command unit test.
- The global XML Namespace is only needed for the outermost node.
- Move a refactored NotNullExtension into ButtonTests.cs.

* MathInputButton_Command test: use the MathInputButton's Keyboard getter

* MathInputButton_Command test: no variable is needed anymore for the MathKeyboard instance

* Revert "MathInputButton_Command test: no variable is needed anymore for the MathKeyboard instance"

This reverts commit 132e19f.

* Revert "MathInputButton_Command test: use the MathInputButton's Keyboard getter"

This reverts commit fe0f460.

* Add MathButton unit tests that check that the image color is correctly set in the StreamImageSource

Probably needless to say: if ever the font changes, new images can created by adding the following method temporarily to the unit test and copying the result into the test project's "files/buttons" folder:
static void StreamToFile(Stream s, FileInfo f) { using (var fs = f.Create()) { s.CopyTo(fs); }}

* Attempt/test 1: also reference SkiaSharp from the CSharpMath.Forms.csproj

* Attempt/test 2: also reference SkiaSharp from CSharpMath.Forms.Test.csproj

* Attempt/test 3: Reference SkiaSharp & SkiaSharp.Views.Forms from test project (note: my previous commit message stated that I included SkiaSharp, but it was SkiaSharp.Views.Forms)

* Revert "Attempt/test 3: Reference SkiaSharp & SkiaSharp.Views.Forms from test project (note: my previous commit message stated that I included SkiaSharp, but it was SkiaSharp.Views.Forms)"

This reverts commit b43a974.

* Revert "Attempt/test 2: also reference SkiaSharp from CSharpMath.Forms.Test.csproj"

This reverts commit 350fc9b.

* Revert "Attempt/test 1: also reference SkiaSharp from the CSharpMath.Forms.csproj"

This reverts commit 8c486dd.

* Update SkiaSharp and SkiaSharp.View.Forms to 2.80.2 in all referencing projects

Introduces unwanted side effects:
- Warning NU1605 Detected package downgrade: Xamarin.Forms from 4.6.0.772 to 4.3.0.908675.
- A reference to a dll from CSharpMath.Forms.Tests, because somehow referencing the NuGet package wasn't enough. This seems to be a known bug: mono/SkiaSharp#1393.

* Add libSkiaSharp.dll to test project CSharpMath.Forms.Tests

Trying out a variation of workaround 3 from:
mono/SkiaSharp#1041 (comment)

* Revert "Add libSkiaSharp.dll to test project CSharpMath.Forms.Tests"

This reverts commit 593d677.

* Revert "Update SkiaSharp and SkiaSharp.View.Forms to 2.80.2 in all referencing projects"

This reverts commit 31cc12a.

* Customize buttons for MathKeyboardInput even more

- Make the button display Latex related to the enum values of MathKeyboardInput overridable. (Not the math that may be displayed after pressing the button, but only the appearance of the button itself.)
- Use a TextButton as a base class for MathInputButton. Then you have more options than when using a MathButton. (See the Example project, MyMathInputButton.cs where just the text "space" is used.)
- Add another button type related to MathKeyboardInput (but unrelated to LaTeX): ImageSourceMathInputButton. This may help people be creative. (See the Example project, the Clear button now appears as a flame: Controls/ImageSourceMathInputButtons/flame.png.)
- Add a unit tests:
--- ImageSourceMathInputButton_InputProperty_KeyboardProperty_and_Command
--- MathInputButton_KeyboardProperty

* Make blinking Placeholder's Nucleus and ForeColor customizable in both CaretStates (#167)

* Make blinking Placeholder's Nucleus and ForeColor customizable in both CaretStates

* Renaming of Placeholder-related variables + refactor (#167)

- Rename Placholder's "ForeColor" to "Color".
- Use property initializer GlyphInfo.Foreground.
- Restore "readonly field" instead of property getter for LaTeXSettings.Dummy.
- Use the name parts "Resting" and "Active" in the placeholder setting names (instead of "Hiding" and "FullShow" which are related to the caret but do not fit a blinking placeholder).
- Use variable name "placeholder" instead of "ph".

* Add unit tests for customizable placeholder (#167)

* Disable parallelization of customizable placeholder unit tests

Also: verify more in LaTeXSettings_Placeholder_IsNewInstance.

* Add unit test AllCustomizablePlaceholderPropertiesAreResetOnCaretVisible (#167)

Also: in the MockTests class, verify that AttributedGlyphRun sets the GlyphInfo.Foreground to null (default color).

* Unit test CustomizedPlaceholderBlinks: test complete cycle

* Fix failing unit test CaretTimerResetsOnKeyPress

* Use Assert.All instead of Assert.True(enumerable.All(pred))

* Revert "Fix failing unit test CaretTimerResetsOnKeyPress"

This reverts commit 9925952.

* Replace Assert.NotEqual + replace hardcoded strings by constants

* Refactoring and cleaning (of customizable placeholder tests and more)

* Placeholder tests: use Assert.NotSame and async Task

* MathInputButtons with customized placeholders: what you see is what you get in the output

In case MathInputButtons have the same TextColor as the output, the placeholders can be customized by only setting one or more of the LaTeXSetting properties PlaceholderActiveNucleus, PlaceholderRestingNucleus, PlaceholderActiveColor, PlaceholderRestingColor.
In case of different keyboard colors than output colors then the MathInputButton properties PlaceholderActiveColor and/or PlaceholderRestingColor can be used to override the LaTeXSettings. Those two properties use a weird hack: BindableProperties cannot have nullable value types it seems. Nobody will ever use a transparent placeholder, so that is save to use as a replacement for null. The color black should be available, in case the TextColor is not black.

This commit reverts the adding of MyMathInputButton of commit 94ebda2.

The Example project's Editor tab is updated to have a "Change appearance" button on the EditorPage that does a round trip through 3 themes that show different Clear buttons, different colors on the keyboard keys and output, different placeholders on the keyboard and in the output.

A large number of testcases has been added. It does not cover everything however.
The PlaceholderColorsProperties_MathInputButton expects a weird LaTeX string (you see "{}" at index 24):
@"\(\color{blue}{\square }{}^{\color{green}{■}}\)"

* Correct comment

* MathInputButton: only perform the placeholder color logic if defaults are overridden + refactor

- At ButtonDraw: only perform the placeholder color logic if the placeholder properties (of LaTeXSettings or of MathInputButton) are not the default values (null).
- Introduce NullableColorBindablePropertyHelper for nullable color workaround.

* Comment out 2 ButtonTests that have Linux failures

* Use FactAttribute.Skip

* Delete NullableColorBindablePropertyHelper (I am afraid I did not try the right things before - it just works)

* Revert "Delete NullableColorBindablePropertyHelper (I am afraid I did not try the right things before - it just works)"

This reverts commit da8b291.

* Use "foreach" instead of Xamarin.Forms.Internals.ForEach

* First call SetButtonsTextColor and then SetClearButtonImageSource

* Update CSharpMath.Forms.Example/CSharpMath.Forms.Example/Controls/MathKeyboard.xaml.cs

Co-authored-by: FoggyFinder <[email protected]>

* Add unit tests MathButtonTextColorCanChangeMultipleTimes and MathInputButtonTextColorCanChangeMultipleTimes

Also:
- Skip only on Linux via "FactSkipLinux(reason)" instead of a general Fact(Skip = reason).
- Move some helper methods into a separate file ButtonTestsHelper.cs.
- Rename png used in unit tests, using more specific names.

* Introduce interface IButtonDraw for bindablePropertyChanged

- Move ButtonDraw from TextColor setter to TextColorProperty's propertyChanged event.
- If calling ButtonDraw after casting to a base class, the subclass' override of ButtonDraw() is not executed, but via the IButtonDraw interface it is.
- Move NullableColorBindablePropertyHelper to its own file.
- ButtonTestsHelper refactor: extract method imageButton.ImageSourceAsStream().

Example project:
- use PlaceholderBlinks setting in the thrid theme.
- call ButtonDraw during each theme change (this is officially only needed for going from theme 1 to theme 2, but may also fix a not-understood bug).

* Shut CSharpMath.Ios.Tests

* add lock for now

* Create and use method SubStringCount() instead of Regex.Matches().Count

* Customized placeholder colors: add unit test

Co-authored-by: Hadrian Tang <[email protected]>
Co-authored-by: FoggyFinder <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants