I have Xamarin.iOS project and I'm trying to use Vivalnk sdk (a Swift 5 framework) in it.
I'm attempting to walk through this guide:
https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-swift/walkthrough
Note that I've ignored building native library step as Swift sdk was provided with objective-c headers built-in.
So, I used an objective sharpie to generate ApiDefinitions.cs and StructsAndEnums.cs files.
Once used this command : (Objective c)
sharpie bind --sdk=iphoneos14.2 --output="XamarinApiDef" --namespace="Binding" --scope="/VivalnkSDK.framework/Headers/" "/VivalnkSDK.framework/Headers/VVBleManager.h"
and once used this : (Swift)
sharpie bind -sdk iphoneos14.2 -scope VivalnkSDK.framework/Headers/ VivalnkSDK.framework/Headers/VVBleManager.h
And finally, I used the following command's results:
sharpie bind -sdk iphoneos14.2 -scope VivalnkSDK.framework/Headers/ VivalnkSDK.framework/Headers/VivalnkSDK-swift.h
Then, I created iOS binding library, replaced these files with old ones, and set the build action according to Microsoft's document.
Then, I added Vivalnk framework to Native References, set smartlink to true, and force load to false.
After a successful binding library build, I referenced this iOS binding library to my Xamarin.iOS project and use it but when I bulid Xamarin.iOS project, got 249 errors like following errors:
Could not find or use auto-linked library 'swiftFoundation' (Vivalnk) Native linking
Native linking failed, undefined symbol: nominal type descriptor for Swift.Double. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210) (Vivalnk)
I search a lot on the internet and also tried these:
Set Linker behavior to Link Framework SDKs only.
Install Xamarin.Swift in both projects.
Add this :
-/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Wl,-rpath -Wl,#executable_path/Frameworks
to Linker Flags of native reference in the iOS binding library.
Add this :
--gcc_flags -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Wl,-rpath -Wl,#executable_path/Frameworks
in additional mtouch arguments in the executable project's iOS Build options.
I checked the location of Xcode, it is exactly there.
But none of them worked for me. I tested in both Visual Studio for Mac and windows and nothing changed.
I created a sample project here which contains everything you need to reproduce build errors:
https://github.com/SomayeEbrahimi/Vivalnk.iOS
Environment:
Vivalnk architecture sdk: Arm64
Visual Studio for mac Version: 8.8.4
Visual Studio for windows : 16.8.3
Xamarin.iOS version : 14.6.0.15
XCode Version: 12.2
Swift Version: 5
Update
If I add "Foundation" to frameworks of native reference, those errors will disappear and we will have the following error
Vivalnk.iOS/Vivalnk/error MT5209: Error: in XCode/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCompatibility50.a(Overrides.cpp.o),
building for iOS, but linking in object file built for iOS Simulator, for architecture arm64 (Vivalnk) Native linking
Related
I am using xcode 12.4 and In a macOS/OSX project I am getting a linking error Library not found.
The mac os app is using a C++ library that is being successfully built in the xcode workspace, but the linker fails to find it
I have added that dependency Cpp library in the "Link binary with Libraries" (Build phases)
I think my Library search paths setting in Build Settings is not correct, linker search hardcoded path which was set on different machine where project was first built.
The output of workspace which includes the C++ library is in the Derived data, how can I specify derived data or Build path as variable and use it to point to C++ library folder , so that even on different machine project is built without searching any hard coded library paths ?
Thanks,
Ahmed
I'm trying to update an OpenFrameworks project using the Project Generator.
After updating the project, I'm now getting the following error in Xcode 8.2.1:
clang: error: unknown argument: '-mmacosx-version-min'
That flag is found in the Apple LLVM 8.0 - Custom Compiler Flags section of Build Settings in both my Project and Target:
Anyone have an idea on what the issue may be? I'm on macOS 10.12.1 Sierra.
You can remove the -mmacosx-version-min flag; Xcode uses MACOSX_DEPLOYMENT_TARGET.
MACOSX_DEPLOYMENT_TARGET specifies the minimum version of OS X for the build target.
↳ Configuring a Project for SDK-Based Development
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!
I'm building a C++ project, how do I add a custom compiler argument that Xcode doesn't have? Like -fwide-exec-charset=UCS-2LE. I searched on the internet but only found the solution to xcode 3.x. I'm using Xcode 4.5.2 and the UI is too different.
PS. It's NOT the commandline argument which used when debugging program, it's the g++ compiler argument which used when compiling the source codes.
I am trying to cross-compile a project for the iOS (which is written in windows) and is based on openCV. And then I am trying to use these cross-compiled openCV libs for a specific application (called testApp).
I was first able to successfully cross-compile openCV for the iOS. Then I used these libraries to created another library called testLib.a which was consumed by an application testApp (which also used some openCV functionality).
The testLib.a compiled successfully but, for the testApp I had to add dependency to both testLib.a and the openCV libs (.a files). When I try to compile testApp, I get the following error -
ld: duplicate symbol cv::split(cv::Mat const&, cv::Mat*) in
/Users/suri/Projects/testLib/lib/Debug/libopencv_core.a(convert.o) and
/Users/suri/Projects/testApp/libs/testLib.a(convert.o) for
architecture i386
I can see that this error is probably coming because the openCV libs are added by open testLib as well as testApp. My question is should I try and reorganize the project or is there some other way to fix this issue?
I tried to find where the "split" function might actually be used in testLib but it does not seem to be called. Also, I have checked and every .h in the testLib as well as testApp and they all have a "ifndef" macro.