Why Error MT5210: Linking fails for debug ARM64 Builds - xamarin

I'm seeing errors in my logs like
MT5209 ignoring file libmono-native-unified.a file is universal (armv7,armv7s,arm64) but does not contain the x86_64 architecture Native linking
However I'm trying to build the project for iOS in debug mode, so it should be using arm64 as the architecture, so I'm not sure why it's trying to use x86_64 at all. This implies it's building for a simulator instead of the selected device.

As you can see my debug iPhone configuration is set to ARM64 (correct)
And only the simulator is set to x86
SOLUTION - If I swap the build configuration from 'Debug' to 'Debug|iPhone' it compiles just fine, e.g.
FROM
TO
So why 'Debug' and platform 'iPhone' doesn't work and 'Debug|iPhone' does I'm not sure.

Related

building for UIKitForMac, but linking in .tbd built for macOS

I'm trying to compile my iOS app to work on macOS and after checking the Mac checkbox, I'm getting this error on compile:
d: building for UIKitForMac, but linking in .tbd built for macOS, file '/Users/jan/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks//GLKit.framework/GLKit.tbd' for architecture x86_64
Any idea what it means and how to fix it?
Though I've not had this particular error I have had similar ones when trying to port from iPad to UIKitForMac. UIKitForMac appears to be the iOS SDK built for x86_64 when you're linking with frameworks. As a result it shouldn't be trying to pull the x86_64 files from the macOS SDK.
I'd be tempted to check over your 'architectures' and 'valid architectures' settings in Xcode to make sure that any settings you have are deleted and switched back to the standard ones.
Remove architectures

ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together

I want to build my app with Bitcode enabled. As far as I know all my 3rd party library dependencies are Bitcode enabled. But when I do a build, I get this error:
ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
How do I fix this?
I had erroneously set my DEBUG and TEST configurations to build with Bitcode, and this was what caused the above error. Enabling Bitcode only for RELEASE fixed it:
(Your App and any embedded framework targets should look like this—don't enable Bitcode at all on your test and UI testing targets.)

I can build Armv7 + Arm64 architecture but not Armv7 alone

Building a unified API app (after migration) with Armv7 + Arm64 architecture works fine, and the app runs well on iPhone 5 and iPhone 6. but it fails to run on iPhone 4S due to incompatible architecture.
Trying to build it with only Armv7 architecture fails.
These are the errors I get:
Error MT5210: Native linking failed, undefined symbol: _res_9_init. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210)
Error MT5210: Native linking failed, undefined symbol: _xmlDocGetRootElement. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210)
And 6 more like these...
how can I compile this on Armv7 only?
The solution:
Armv7 build failed due to missing link flags in the Oyala binding linkWith file.
After fixing the flags (LinkerFlags="-lstdc++ -lz -lxml2 -lresolv") the Armv7 build was completed with no errors.
It still doesn't explain why Armv7+Arm64 (the fat build) did not fail.
It just skipped the Oyala build.
This is probably a Xamarin bug.
This looks like a bug in Xamarin.iOS, it's not including certain libraries in the fat (armv7+arm64) build, while those (problematic) libraries cause problems in the armv7-only build.
That said, I believe the build problems will be solved by adding -gcc_flags -lxml to the additional mtouch arguments in the project's iOS Build options.
In addition I recommend filing a bug (http://bugzilla.xamarin.com) for the difference in the fat vs thin builds.

Error when trying to archive xcode project

My project runs fine when I run it using the iPhone simulator, and when I run it on a device. When I try to archive it for submission, I get this error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This was directly before the error and I'm not sure if it's related:
ld: file is universal (2 slices) but does not contain a(n) armv7s slice: /Volumes/Macintosh HD/Users/dog94a/Google Drive/Capstone/Backups/Approach/Approach/GMaps/GoogleMaps.framework/GoogleMaps for architecture armv7s
The default behavior of the Debug build configuration is to only build the active architecture (Build Active Architecture Only build setting is YES). This is not the case for the Release build configuration, which will build all architectures supported by your Valid Architectures build setting. What this means is that you're likely not targeting an armv7s device during your Debug builds (iPhone 5, latest iPad, etc), so you're not attempting to build that architecture until you do an archive which uses the Release build configuration by default.
The error indicates that your project is configured to create a binary that has armv7s instructions for when it runs on devices of that type, but the GoogleMaps.framework binary you're trying to link against was not built with an armv7s slice. To fix this, you either have to update to the latest version of the GoogleMaps.framework and hope they built it with armv7s enabled, or remove armv7s from your Valid Architectures build setting (obviously the former is preferable).
Once I have included a framework and at compile time nagged the linker for armv7. Now you have armv7s, which is the iphone5?
Solution to my problem it was: remove all files from that framework.
Compile that framework ( double check at Valid architectures settings to be there the desired architecture
Re-add the newly compiled framework.
Try and maybe it helps or even solve your problem too!

Cocos2d 2.x ARC issue on device

I'm working on a game that has cocos2d with ARC.
The game builds & runs fine in Simulator, but when I build for device I get Apple Mac-O Linker Errors, saying that I'm missing the libraries for libcocos2d.a etc.
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libcocos2d.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libCocosDenshion.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libkazmath.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/liblibpng.a'
When I go to the folder where the file is missing I only see jellyfish.app.
I don't have much experience in this kind of issues & I'm not clear why this happens,
I checked how to start the project from TinyTimGames & LearnCocos2D, still not clear what I'm doing wrong.
I've solved the issue, the builds for the binaries were somehow ignored by XCode because they were for another architecture, by settings the build settings for the cocos2d target Build For Active Architectures Only to NO, the issue dissapeared.
Sounds like you'll have to add these libraries to the Link Binary With Libraries build phase.
See my tutorial on Enabling ARC for Cocos2D projects for details.
It's strange that it would work for the Simulator though, since it's using the same target. I wouldn't rule out that the device is incompatible, you'll have to have at least a 3rd generation (iPhone 3GS) device running iOS 4.0 or higher.

Resources