I can build Armv7 + Arm64 architecture but not Armv7 alone - xamarin

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.

Related

Why Error MT5210: Linking fails for debug ARM64 Builds

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.

"Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib" with Xcode 8?

My project requires OpenSSL libraries crypto and ssl. After updating Xcode to 8.2.1, compiling my project fails.
In my project Build Settings, in Linking, I have -lssl -lcrypto -lxml2 that indicates to load those libraries. Going back to my app Build Settings, I add /usr/local/opt/openssl/lib/ in the Library Search Paths to tell Xcode where to look.
Hurray, it compiles, builds and run properly. Cool.
BUT
When launching the app on a different mac, the app crashes, with this linking error:
Dyld Error Message:
Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Applications/MyApp.app/Contents/MacOS/MyApp
Reason: image not found
That means the app is trying to load the open ssl libraries that might not be present on that mac. There might be just an older version, or that folder might not exist at all? So that's definitely a no-solution.
Here lies my issue, I have no idea how to solve this problem.
Removing -lssl -lcrypto from the linking doesn't help, as the has errors during linking.
I guess I need a way to tell Xcode to look there when compiling only. Would that be possible?
If you don't wish to ship libraries and deal with making sure the linker can find them, you can link your code against a static library.
Using the code in this question as a linking example, I compiled with this command:
cc -I/opt/homebrew/Cellar/openssl#1.1/1.1.1q/include -o Link14 Link14.cpp /opt/homebrew/Cellar/openssl#1.1/1.1.1q/lib/libcrypto.a -lc++
This uses system libraries for most things, but the static version of libcrypto in libcrypto.a for the encryption. You can add multiple by placing them on the compile/link line.

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.)

Why isn't my static library in XCode building for the x86_64 architecture?

Premise:
I'm trying to build a static library of C to be referenced from a Swift project through an objective-c bridging-header. I built the static library, included it in my project, Sourcekit recognizes the function I want to call from the Static library, but I am still getting errors (detailed below).
I followed the Wenderlich Tutorial for creating a static library in XCode. When I generate the universal binary, and run lipo command:
lipo -info libMyStaticLib.a
I get:
Architectures in the fat file: libMyStaticLib.a are: armv7 armv7s i386 arm64
I figured out it wasn't building the x86_64 architecture because when I linked to it in my project that requires the library, I got the error:
ld: warning: ignoring file
/Users/jamesmart/SourcetreeProjects/MyProject/libMyStaticLib.a, missing
required architecture x86_64 in file
/Users/jamesmart/SourcetreeProjects/MyProject/libMyStaticLib.a (4 slices)
Undefined symbols for architecture x86_64:
"_helloWorld", referenced from:
__TFC7MyProject16BridgePlayground12sendIntToGetfS0_FT_T_ in BridgePlayground.o
ld: symbol(s) not found for architecture x86_64
I have seen the similar StackOverflow questions:
XCode 6.1 Missing required architecture X86_64 in file for extern library
XCode 6.1 Missing required architecture X86_64 in file
And I have tried the solutions listed, but nothing seems to be able to build that darn x86_64 architecture. I've also tried building my static library to many target devices:
Just tried to link pictures but I don't have enough reputation, sorry...
But I've tried targeting simulators and iOS Device, neither option solves this.
"Build active architecture only" is set to "No" in my static library build settings and also is passed as a parameter to the xcodebuild function in my Run Script build phase:
xcodebuild -target SegmentationLib ONLY_ACTIVE_ARCH=NO -configuration
${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}"
BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target SegmentationLib -configuration ${CONFIGURATION} -sdk
iphonesimulator -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
My "Valid Architectures" in Build settings are currently set to armv7, armv7s, and arm64 - Although I have tried only setting it to armv7 per someone's suggestion, and that didn't work either.
I am using XCode version 6.2 and am on OSX Yosemite 10.10.2.
Can anyone help with this?

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!

Resources