Native linking failed after upgrading to Xcode 11 - xamarin

I upgraded from Xcode 10.2 to Xcode 11 and encountered the following linker error.
Native linking failed, undefined Objective-C class: CTTelephonyNetworkInfo. The symbol '_OBJC_CLASS_$_CTTelephonyNetworkInfo' could not be found in any of the libraries or frameworks linked with your application.
I used the Xamarin.Essential Connectivity module as follow:
result = (Connectivity.NetworkAccess == NetworkAccess.Internet);
There is a change in CTTelephoneNetworkInfo in iOS (https://learn.microsoft.com/en-us/xamarin/ios/release-notes/api-changes/ios-12-14-0-12-99-4)
Could this be the issue? Thanks.

After troubleshooting for 3 days by stripping down the code, nuget packages etc, the cause of "Native linking failed" is the binding library (dll) created and used in the project. I just need to recompile the binding library (a separate project) using Xcode 11 and transfer the new dll into the current project.

Related

Swift had fatal errors constructing the ast context for this module

I upgraded my project to Swift 2 in Xcode 7 beta (7A120f) and get this error when trying to po self at the lldb prompt:
warning: Swift error in module myApp:
Swift had fatal errors constructing the ast context for this module: cannot load underlying module for 'UIKit'
Debug info from this module will be unavailable in the debugger.
I'm then left with a crippled debugger (no values). This happens regardless of where I place a breakpoint. I've tried:
clearing derived data
Product > Clean
restarting xcode
restarting mac
I'm able to create a new project and see debug output in it, so this probably has something to do with how my project was migrated by xcode.
What is the ast context and how can I correct it?
Edit: ast is 'Abstract Syntax Tree'. Still no idea how to fix it though.
I'm having the same issue in my project. The error that lldb spits out when attempting to po an object highlights the issue:
(lldb)po fileURL
warning: Swift error in module <APP_NAME>:
Swift had fatal errors constructing the ast context for this module: <module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/Crashlytics.h"
^
<APP_PATH>/Pods/Crashlytics/Crashlytics.framework/Headers/Crashlytics.h:10:9: error: include of non-modular header inside framework module 'Crashlytics'
#import <Fabric/FABAttributes.h>
^
The Crashlytics.h umbrella header in Crashlytics.framework is importing Fabric/FABAttributes.h, which is not part of the Crashlytics module (i.e. not in its module.modulemap). This is Crashlytics 3.1.0 installed using CocoaPods.
Why Xcode 7 treats this as a fatal error is beyond me (it was just a warning in 6). In Xcode 6 you could work around this sort of "non-modular header include" by enabling the "Allow Non-modular includes in Framework Modules" (CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES) build setting in your application target.
I've had no luck getting the Xcode 7 betas to honor the above flag (rdar://22044453 <-- please dup).
The only solution I've found to get the debugger working is to remove the Crashlytics pod. I comment out the Crashlytics and Fabric pods, run pod install, resume debugging and then reinstall the pods before a release.
I really hope this is fixed in Xcode 7 by the time it comes out of beta.
Check your bridging header and if you have
#import Crashlytics;
(or any other frameworks that cause the error. In my case it was GoogleMobileAds)
try replacing with
#import <Crashlytics/Crashlytics.h>
To fix this I manually migrated all my files and settings to a new xcode project. Nothing else worked. There is probably a better fix but I couldn't spend any more time looking for it.
I had the same issue.
In the most cases this issues appears when you use objective-c frameworks or libraries in Swift project.
The issue was fixed by importing objective-c frameworks or libraries in Bridging-Header only.
#import <SampleFramework/SampleFramework.h>
and remove all imports of this framework from Swift files
import SampleFramework // <-- Remove it
Then Clean and Build.
Make sure that you did this procedure for all objective-c frameworks or libraries in your projects.
Hope this helps!

Unity build to xcode with gives error: Apple Mach-O Linker

I tried to google for the solution. I tried to delete the DerivedData folder but it still doesn't work... Why is this still happening? I am using Xcode version 6.2. Thanks.
Edit: Under the one error has 70 different errors saying various things. There is a warning saying
ld: warning: ignoring file /Users/Kevin Chen/Desktop/Parking Director/Libraries/libiPhone-lib.a, missing required architecture arm64 in file /Users/Mushrooms4Eva/Desktop/Parking Director/Libraries/libiPhone-lib.a (2 slices)
All of the following links and solutions did not work for me:
https://teamtreehouse.com/forum/apple-macho-linker-error-xcode-61
Apple Mach-O Linker Error when compiling for device
Sounds like your library libiPhone-lib.a is not compiled for arm64, but your project is set to be compiled for this architecture.
I think all the errors are triggered by this "warning" as the library is ignored, and therefore you may have a lot of missing references.
Your options:
Get a version of the lib compiled for arm64, or do it yourself, if you have the code
Remove arm64 architecture from your project (which I don't recommend, as you'll need to provide an 64bit build for the App Store, but that's another story)
How to make 64bit builds (available from Unity 4.6.2+)
iOS platform
Other Settings
Scripting Backend => IL2CPP
Architecture => Universal (to target both 32 and 64 bit)
How to build for simulator
Player Settings
iOS platform
SDK Version => Simulator SDK

ld: library not found for (on Simulator only)

Suddenly began getting this error when running my app on iOS 7 Simulator.
ld: library not found for -lacmobileshim
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
On Device this problem doesn't happen and the app runs OK.
Have already searched for this library inside SDK but couldn't find it. Have no idea what's going on cause it was running OK both on Simulator and Devices before and haven't added any additional library to my project.
Is there a way to set Library Search Path in Build Settings just for this library?
Should reinstall SDK be a workaround?
These are the libraries i'm including in my project:
After get the same headache as updated to Xcode 6/iOS 8 sdk, just found a simple way to solve this issue with libacmobileshim.dylib and also other dynamic libraries that were causing the same problem when building the app on simulator. Just delete the dynamic libraries from Build Phases settings and the app is running perfectly again on simulator. Hope it may help someone with the same problem.
libacmobileshim.dylib is in the iOS Device SDK, but it is not in the simulator SDK. External developers should have no need for this library, so I'm confused as to why you're linking against it.
Looking at that list of libraries that you're linking against, I suspect a bunch of them aren't even needed by your project. You should audit that list and eliminate unnecessary linkage.

Undefined symbols for architecture armv7 - Static Library

I'm from Argentina and my English is very limited. Sorry about that.
I tell them about my problem:
I downloaded the SDK for iOS Hikvision cameras from this link: http://www.hikvision.com/en/download_more.asp?id=1207
This includes static library file called "libPlayCtrl.a" and two headers "ApplePlayM4.h" & "PlayM4.h"
The problem is that to include the library in my project, I get the error:
"Undefined symbols for architecture armv7"
I followed the suggestions in this link: Undefined symbols for architecture armv7 and I could not compile the project in any way.
Has anyone worked with this program and can help me?
Thank you.
This question was posted awhile ago. I recently attempted to integrate the HikVision iOS Player SDK for a project as well. I ran into similar errors, symbols not defined for armv7 architecture, as well as a few others. The HikVision documentation for the sdk does not give you the dependent libraries for clean and easy integration. I have included the following libraries, CoreAudio, CoreVideo, AudioToolbox, and OpenAL, as well as the libstdc++.6.0.0.dylib. With all these included in a test project within my environment using XCode 7 with iOS 9 via swift. I created a bridging header (because of swift), imported the ApplePlayM4.h and was able to call the PlayM4_GetPort method. Please note the HikVision library is only compiled for device architectures, amrv7/armv64 and not i386 that is why it won't work in the simulator and only on a physical device.

Xcode 3/4 Compatibility when referencing static libraries

We have multiple development machines, some running Xcode 3.2.5 and others running Xcode 4.2. We have a static library that is referenced by our project. It contains Objective C categories, so we need to use the -force_load flag with the path to the library.
The problem that we are having is that on Xcode 4.2, the library is linked from a different location than the path that we specified in -force_load. This causes duplicate symbol errors since it's trying to link two copies of the same library.
The path Xcode 4.2 links from is:
/Users/USERNAME/Library/Developer/Xcode/DerivedData/PROJECTNAME-ehxeazvigqrpvogkxlkcmdzpisdw/Build/Products/CONFIGURATION-PLATFORM/
whereas the location that Xcode 3.2.5 links from is:
PROJECT_ROOT_OF_STATIC_LIBRARY/build/CONFIGURATION-PLATFORM/
Is there a way to get Xcode 4.2 to use the same locations as Xcode 3.2.5 when linking static libraries so that we can use the force_load linker option? If not, can anyone suggest an alternative solution to get Xcode 3.2.5 and 4.2 to play nicely together?
It sounds to me like you are doing things the hard way.
I've never used -force_load to load static libraries. With the libraries I use, they are all stored as frameworks in a directory on my system which is separate from the project. I then use the XCode standard add frameworks dialogs to bring them into the project and "-ObjC -all_load" to ensure they work and categories are active.
I've successfully move a few projects from XCode 3 to 4 and not had the problem you are mentioning. I suspect that if you can stop using -force_load your problems will go away.

Resources