Our Xamarin.iOS release build is failing with MTOUCH : error MT5213: Duplicate symbol. This error started happening recently and is likely due to a nuget package somewhere but the funny thing is none of those APIs look familiar at all. I've tried investigating the source but can't find where they're getting included.
I've tried.
1. Downgrading Xamarin forms from latest version to the last point version 2.5xxxx
2. Removing all nuget packages added since our last update in July.
3. Adding --registrar:static
4. Adding -gcc_flags -dead_strip which reduce the errors but still results in this error
___2018-08-24T22:01:20.5791820Z clang : error : linker command failed with exit code 1 (use -v to see invocation) [/Users/vsts/agent/2.136.1/work/1/s/Client/projectName.Client.Forms/iOS/projectName.Forms.iOS.csproj]
2018-08-24T22:01:20.5920220Z error MT5209 : Native linking error : reference to symbol (which has not been assigned an address) _WebPInitYUV444Converters in '_CustomSetup' from /Users/vsts/agent/2.136.1/work/1/s/Client/projectName.Client.Forms/iOS/obj/iPhone/Release/mtouch-cache/WebP.a(libwebpdecode_la-io_dec.o) for architecture armv7 [/Users/vsts/agent/2.136.1/work/1/s/Client/projectName.Client.Forms/iOS/projectName.Forms.iOS.csproj]
2018-08-24T22:01:20.6050340Z MTOUCH : error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -dead_strip [/Users/vsts/agent/2.136.1/work/1/s/Client/projectName.Client.Forms/iOS/projectName.Forms.iOS.csproj]
2018-08-24T22:01:20.6130420Z MTOUCH : error MT5202: Native linking failed. Please review the build log. [/Users/vsts/agent/2.136.1/work/1/s/Client/projectName.Client.Forms/iOS/projectName.Forms.iOS.csproj]
2018-08-24T22:01:20.6148240Z
2018-08-24T22:01:20.6180880Z 60 Warning(s)
2018-08-24T22:01:20.6215590Z 4 Error(s)
various --linkskip options to suspect nuget dlls .
How do I get the full error? Can i by pass these ? Here's the a portion of the log file, any help/pointers is greatly appreciated.
2018-08-29T07:57:46.1674730Z duplicate symbol _WebPMultRows in:
2018-08-29T07:57:46.1761750Z /Users/vsts/agent/2.138.6/work/1/s/Client/projectName.Client.Forms/iOS/obj/iPhone/Staging/mtouch-cache/WebP.a(libwebpdspdecode_la-alpha_processing.o)
2018-08-29T07:57:46.1944120Z /Users/vsts/agent/2.138.6/work/1/s/Client/projectName.Client.Forms/iOS/obj/iPhone/Staging/mtouch-cache/liblibwebp.a(alpha_processing.o)
2018-08-29T07:57:46.2117500Z duplicate symbol _WebPMultARGBRows in:
2018-08-29T07:57:46.2265350Z /Users/vsts/agent/2.138.6/work/1/s/Client/projectName.Client.Forms/iOS/obj/iPhone/Staging/mtouch-cache/WebP.a(libwebpdspdecode_la-alpha_processing.o)
Possible reasons for this error:
The same native library is included twice.
Two distinct native libraries happen to define the same symbols.
A native library is not correctly built, and contains the same symbol
more than once. You can confirm this by using the following set of
commands from a terminal (replace i386 with x86_64/armv7/armv7s/arm64
according to which architecture you're building for):
for more information you can access link error-messages
What worked for me was adding the following to mtouch arguments in all configurations, specifically for release|iphone (simulator was working prior)
--registrar:static -gcc_flags "-framework libSkipSharp -dead_strip"
This link was instrumental including a lot trial and error: https://learn.microsoft.com/en-us/xamarin/ios/troubleshooting/mtouch-errors#mt5xxx-gcc-and-toolchain-error-messages
Related
After updating the Firebase libraries, I'm getting the following errors:
MTOUCH : error MT5210: Native linking failed, undefined symbol: _APMAnalyticsConfiguration. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
Blockquote
MTOUCH : error MT5210: Native linking failed, undefined symbol: _APMAppMeasurementOriginFirebase. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
MTOUCH : error MT5210: Native linking failed, undefined symbol: _APMIsAnalyticsCollectionDeactivated. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
MTOUCH : error MT5210: Native linking failed, undefined symbol: _APMIsAnalyticsCollectionEnabled. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
MTOUCH : error MT5210: Native linking failed, undefined symbol: _APMMonitorLogTagOptionKey. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
MTOUCH : error MT5210: Native linking failed, undefined symbol: _APMSafelistedEventsOptionKey. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
I've tried the following:
Deleting obj and bin folders
Cleaning the project
Initializing Firebase core (Firebase.Core.App.Configure();)
I've tried all linker behavior options.
I'm referencing the following Firebase libraries:
Xamarin.Firebase.iOS.Analytics (6.4.1)
Xamarin.Firebase.iOS.CloudMessaging (4.3.0)
Xamarin.Firebase.iOS.Core (6.6.6)
Xamarin.Firebase.iOS.DynamicLinks (4.0.8)
Xamarin.Firebase.iOS.Installations (1.1.1)
Xamarin.Firebase.iOS.InstanceId (4.3.3)
Does anyone know how to solve this?
Unfortunately, there isn't much that you can do in this case. The error is related to incorrect linking. The guys from Xamarin have messed up the bindings after one of the upgrades. You can read more about using native libraries in Xamarin here & more specifically here.
However, you can still do something to help - isolate which package caused the issue and from which version onwards it happens. Then, report it at the official GitHub repository for Google APIs here.
P.S. I have gone through the issues and haven't seen this exact list of errors. There have been (and still are) a lot of binding issues, which are waiting to be fixed. So, in order to speed things up, discuss it with the devs from the issue and hopefully, they will be able to resolve it quickly.
I'm facing the below errors when enabling the AppCenter crash and analytics in the App.xaml.cs file like below,
protected override void OnStart()
{
AppCenter.Start("android={my secret code};" + "ios={my secret code}", typeof(Analytics), typeof(Crashes));
}
If comment on this code, I didn't get any errors.
Native linking failed. Please review the build log.
linker command failed with exit code 1 (use -v to see invocation)
Duplicate symbol in: /Users/macbook-02/Library/Caches/Xamarin/mtbs/builds/MyProject.iOS/fa397694646d06672e8f8c7f7683e7fe/obj/iPhoneSimulator/Debug/mtouch-cache/AppCenterCrashes.a(MSCrashesCXXExceptionHandler.o) (Location related to previous error)
Duplicate symbol in: /Users/macbook-02/Library/Caches/Xamarin/mtbs/builds/MyProject.iOS/fa397694646d06672e8f8c7f7683e7fe/obj/iPhoneSimulator/Debug/mtouch-cache/libHockeySDK.a(BITCrashCXXExceptionHandler.o) (Location related to previous error)
1 duplicate symbol for architecture x86_64
Native linking failed, duplicate symbol: ''___cxa_throw''.
Native linking failed. Please review the build log.
I try to fix it by the answer given in the below links but that's not resolving my issue,
Native linking failed, duplicate symbol: '_main' while adding native Binding Dll and Xamarin.Firebase.iOS.Database
https://github.com/xamarin/GoogleApisForiOSComponents/issues/111
I think you need to have a check with whether adding the App Center SDK to your solution .If you have followed up that , remember to add reference in project:
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
Then clean your project and rebuild it .
This happens when the native linker encounters duplicate symbols between all the native libraries. You can see detailed information on this error here https://learn.microsoft.com/en-us/xamarin/ios/troubleshooting/mtouch-errors#mt5212-native-linking-failed-duplicate-symbol- .
Try changing the Link type in your iOS project properties:
Right click iOS project > Properties
in iOS Build tab change Linker Behavior to Link Framework SDKs Only
I am creating Binding DLL for Xamarin.Mac using the Binding project in visual studio Mac.
I am able to build Binding DLL successfully, However while going to use that binding DLL in Xamarin.Mac project then it returns bellow error.
MMP : error MM5109: Native linking failed with error code 1. Check build log for details.
Error Detail :
Building: CompatibleToXamarinForms.Mac (Release|iPhone) Build started
23-10-2018 17:16:33.
Project
"/Users/XYZ/Desktop/John/Agora/CompatibleToXamarinForms/CompatibleToXamarinForms.Mac/CompatibleToXamarinForms.Mac.csproj"
(Build target(s)):
Target _CoreCompileImageAssets:
Tool /Applications/Xcode.app/Contents/Developer/usr/bin/actool execution started with arguments: --errors --warnings --notices
--output-format xml1 --output-partial-info-plist
...
"___gxx_personality_v0", referenced from:
-[AgoraLiveTranscoding init] in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
-[AgoraLiveInjectStreamConfig init] in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
-[AgoraPublisherConfiguration toJsonString] in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
agora::rtc::RtcEngineEventHandlerIosImpl::onMediaEngineLoadSuccess()
in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
____ZN5agora3rtc28RtcEngineEventHandlerIosImpl24onMediaEngineLoadSuccessEv_block_invoke
in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
agora::rtc::RtcEngineEventHandlerIosImpl::onMediaEngineStartCallSuccess()
in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
____ZN5agora3rtc28RtcEngineEventHandlerIosImpl29onMediaEngineStartCallSuccessEv_block_invoke
in AgoraRtcEngineKit(libagora_rtc_sdk.a-x86_64-master.o)
...
ld: symbol(s) not found for architecture x86_64
clang : error : linker command failed with exit code 1 (use -v to see invocation)
MMP : error MM5109: Native linking failed with error code 1. Check build log for details. Done building target "_CompileToNative"
in project "CompatibleToXamarinForms.Mac.csproj" -- FAILED.
Done building project "CompatibleToXamarinForms.Mac.csproj" -- FAILED.
Build FAILED.
/Users/XYZ/Desktop/John/Agora/CompatibleToXamarinForms/CompatibleToXamarinForms.Mac/obj/iPhone/Release/mmp-cache/registrar.m(36313,17):
warning G7AC58F0F: method 'deviceBrowserView:selectionDidChange:' in
protocol 'IKDeviceBrowserViewDelegate' not implemented [-Wprotocol]
/Users/XYZ/Desktop/John/Agora/CompatibleToXamarinForms/CompatibleToXamarinForms.Mac/obj/iPhone/Release/mmp-cache/registrar.m(39971,2):
warning GB7F1753F: method possibly missing a [super
splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:] call
[-Wobjc-missing-super-calls] clang : error : linker command failed
with exit code 1 (use -v to see invocation) MMP : error MM5109: Native
linking failed with error code 1. Check build log for details.
2 Warning(s)
2 Error(s)
Time Elapsed 00:00:22.65
---------------------- Done ----------------------
Build: 2 errors, 2 warnings
Can you please someone help to resolve this issue.
Couple of things which I found from the above error
You are trying to select iPhone for xamarin.mac project which is not a correct binding. Might be you have created a binding project supported for mac and you are trying to build with iPhone configuration or the other way.
Did you select the same architecture while building the binding library (say the .a file) in xcode which is same as that of your xamarin iOS project?
check these both, you will get the answer.
From the error log it looks like you're missing some frameworks or libraries that your native library needs to function.
If that is a Agora MacOS SDK (AgoraRtcEngineKit.framework) it would need several frameworks and libraries added as linker flags.
Frameworks:
CoreMedia
CoreAudio
SystemConfiguration
QTKit
CoreWLAN
Foundation
AVFoundation
VideoToolbox
AudioToolbox
IOKit
Libraries:
libresolv
libc++
How do I know?
Usually, native libraries provide sample applications and this is where you can see which frameworks and libraries are required:
To be sure, please go to Visual Studio For Mac 2017 preferences and set the build log verbosity to diagnostic and post the failed build log to gist.github.com
I've added Microsoft Solver Foundation via Nuget to a Xamarin iOS project but it fails to build with this message:
Build FAILED.
MTOUCH : warning MT5215: References to 'gdiplus' might require additional -framework=XXX or -lXXX instructions to the native linker
MTOUCH : warning MT5215: References to 'gdi32' might require additional -framework=XXX or -lXXX instructions to the native linker
MTOUCH : warning MT5215: References to 'user32' might require additional -framework=XXX or -lXXX instructions to the native linker
MTOUCH : warning MT5215: References to 'libX11' might require additional -framework=XXX or -lXXX instructions to the native linker
MTOUCH : warning MT5215: References to 'winspool' might require additional -framework=XXX or -lXXX instructions to the native linker
MTOUCH : warning MT5215: References to 'libcups' might require additional -framework=XXX or -lXXX instructions to the native linker
MTOUCH : warning MT5215: References to 'kernel32' might require additional -framework=XXX or -lXXX instructions to the native linker
clang : error : linker command failed with exit code 1 (use -v to see invocation)
error MT5209 : Native linking error : framework not found Carbon
MTOUCH : error MT5202: Native linking failed. Please review the build log.
7 Warning(s)
3 Error(s)
I'm just starting out with Xamarin and I haven't seen these issues before. Does anyone know how I can fix them?
Here's a screenshot
I'm not sure if Mircosoft Solver has been updated recently, but my understanding is that it's internal reliance on Linq assemblies meant that it didn't work with the MonoFramework properly.
I've not seen any reference to anyone that's successfully linked the assemblies correctly. I'm not entirely sure if Solver can actually be linked with Xamarin at the moment.
looking at your exception logs above it's pushing the assembly build to the native linker, and it's hitting exceptions with certain dlls. In most native linker cases you would have to wait for the xamarin team to push out an update. But I don't think Solver Foundation is on their list.
Example of native linker bugs
I am working on building a Swift library and am hosting it on GitHub.
All was going fine until I added BluetoothKit to the project. I then got an Apple Mach-O Linker Error:
ld: warning: directory not found for option '-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk/Developer/Library/Frameworks'
ld: /Users/calebklevetertest/Library/Developer/Xcode/DerivedData/Napalm-dblvhbjdwovurocsvzrzaxzkjjyw/Build/Products/Debug-iphonesimulator/Napalm.framework/Napalm compiled with older version of Swift language (2.0) than previous files (3.0) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From reading the error it appears the issue somehow stems from the fact I am using Swift 3, but I can't figure out how to fix it.
I did convert BluetoothKit to Swift 3 when I added it.
There is one class that uses BluetoothKit and it is called NPFBluetooth.
A couple things to note are 1) Even though the class is public, the compiler gives an error of 'unresolved identifier', 2) The class does not show in the auto-complete and 3) All the other classes work fine.
I ran into the error migrating to swift3. As it turns out Xcode keeps copies of built frameworks and moving to swift3 is apparently not a cue to rebuild those (even after finding out it was built using swift2.... no let's throw a vague error instead...)
The solution is to delete the content of your 'derived data' folder.
Works for frameworks installed with Carthage and cocoapods.....
Go to your build settings and switch the target's settings to ENABLE_BITCODE = YES for now.
It's working for me ;)