Xamarin iOS - Binding Project - Warning - ios

Am using
Xamarin Studio - 4.0.4 (build 2)
Mono - 2.10.11
Xamarin.iOS - 6.3.5.43
Mac OS X - 10.8.2
When building the wrapper binding class, I get a warning saying 'System.Runtime.CompilerServices.ExtensionAttribute' is present in multiple assemblies. Its just a warning, but builds the .dll file.
Target GenerateBindings:
Tool /Developer/MonoTouch/usr/bin/btouch execution started with arguments: /unsafe /d:DEBUG ApiDefinition.cs /s:StructsAndEnums.cs /tmpdir:obj/Debug/ios/ /sourceonly:obj/Debug/ios//sources.list
warning CS1685:
The predefined type System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies. Using definition frommscorlib'
/Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll (Location of the symbol related to previous warning)
/Library/Frameworks/Mono.framework/Versions/2.10.11/lib/mono/2.0/System.Core.dll (Location of the symbol related to previous warning)
But when using the created binding class in another project, it gives the error saying
Compiling to native code -
'error MT5202: Native linking failed. Please review the build log.'
In the build log
ld: file not found: /var/folders/w4/xsz8x8vx0_51hjxj474r1_fxhlq7x3/T/tmp9aef74.tmp/libPrint.a
collect2: ld returned 1 exit status
Note : libPrint.a is my static library
-Update-
When binding the libPrint.a file to the wrapper class, the .a file should be added to the project and not inside the 'Resources' folder. This solved the issue am facing.

Does libPrint.a support the architecture you are building your iOS project for?
IOW, if you are compiling for Simulator, your libPrint.a needs to support i386.
If you are compiling for device, it needs to support whatever ARM arch you are targeting.

The warning is because of the ambiguity for System.Runtime.CompilerServices.ExtensionAttribute' in multiple assemblies.
Keeping the warning aside, the real problem is when adding libPrint.a file.
Its a small silly mistake. The docs of xamarin clearly explain it.
It should be added to the project and not inside the 'Resources' folder.
This solved the error I'm getting when using the .dll file for a project.

Related

Native linking error could not create compact unwind for XXX does not use standard frame (MT5209)

I’m working on Xamarin and trying to install an iOS app on my iPad.
I want to link an Ada static library.
So I have a libMyLibrary.a + libgnat.a file and a C header code (MyLibrary.h).
In Xamarin, I created a binding library project and added my library.
In Xamarin, I added the above project as a reference to my iPad app.
To communicate with the library I used the P/Invoke with a DllImport(“__Internal”) and an assembly for my lib (so I don’t have any MTouch arguments) :
[assembly: LinkWith(“libMyLibrary.a”, SmartLink=true, ForceLoad=true)]
[assembly: LinkWith(“libgnat.a”, SmartLink=true, ForceLoad=true)]
But when I deploy it to the iPad I have a lot of native linking errors:
Native linking error: warning: could not create compact unwind for XXX does not use standard frame (MT5209)
I tried to use the monotouch arguments but no success:
-Wl,-no_compact_unwind ! see ld: warning: too many personality routines for compact unwind to encode and https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/279914
LDFLAGS="-Wl,-no_compact_unwind : see https://bugzilla.mozilla.org/show_bug.cgi?id=1188030#c14
Any ideas?
Configuration:
iOS 10.3.2
Xamarin 6.3
Deployment target 10.3
After struggling around with this for a few days, we came up with something working.
The exact directives we've given to Monotouch are as follows:
-gcc_flags "-L${ProjectDir} -lMyLibrary -lgnat -force_load ${ProjectDir}/libMyLibrary.a -Wl,-no_compact_unwind"
Notice that :
the gnat lib file is put aside libMyLibrary.a
libMylibrarry is referenced twice in the command
And ... voilà !
Apprently, I didn't add it properly at the first time...

Manual import of Twilio into Swift

I'm building a framework target to be used across multiple apps I am developing and I'm trying to include the Twilio SDK (TwilioCommon & TwilioConversationsClient) in this common framework target.
To do so, I had to create a modulemap to define a module from the headers. Ok, great. Everything seems to work fine. Except I'm getting an excessive number of warnings when following this model:
ld: warning: ignoring linker optimzation hint at _cftmdl_128_neon+0xF0 because ldrInfoC.offset == 0
ld: warning: ignoring linker optimzation hint at _cftmdl_128_neon+0xFC because ldrInfoC.offset == 0
ld: warning: ignoring linker optimzation hint at _cftmdl_128_neon+0x108 because ldrInfoC.offset == 0
....
....
I believe I've adhered to the Manual install for iOS page fairly well and I've created a minimal project on github to replicate this behavior.
Anyone able to spot mistakes? Is this a bug in the way the library was linked?
Versions and things:
XCode 7.2.1, Swift 2
TwilioCommon 0.2.0
TwilioConversationsClient 0.22.0
This question is remarkably similar to this one:
How do I resolve linker warning "ignoring linker optimzation hint at" in XCode?
If you're compiling the WebRTC library by yourself using build
scripts, the warnings are generated because of a missing parameter in
GYP_DEFINES.
In order to fix the warnings, the WebRTC library needs to be compiled
again with the parameter clang_xcode=1 in the GYP_DEFINES setting,
like below (only an example):
export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=arm64
clang_xcode=1" More about the issue can be found here, on the Chromium
forums: https://bugs.chromium.org/p/webrtc/issues/detail?id=5182
--
If you're not compiling the WebRTC library yourself, and instead
installing the WebRTC library from a 3rd party source, I don't believe
there is a fix as the warnings are stemming from the static library.

Xcode 6 linker error - Undefined symbols for architecture armv7

After upgrading to Xcode 6 beta 7 (and now still with Xcode 6 GM) I am unable to link my Swift app. I receive errors such as:
Undefined symbols for architecture armv7:
"_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
...
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have seen the other SO posts that recommend deleting the Derived Data folder and/or using the Clean Build Folder option to get past this error, but that solution didn't help at all in my case. Nothing has changed about my code or the CocoaPods I'm using since Xcode 6 beta 5 which is the last time it worked.
Any ideas?
EDIT:
A full posting of the error log:
Undefined symbols for architecture arm64:
"_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
TFC12MyProject21BarcodeViewController13captureOutputfS0_FTGSQCSo15AVCaptureOutput_24didOutputMetadataObjectsGSQGSaPSs9AnyObject___14fromConnectionGSQCSo19AVCaptureConnection__T_ in BarcodeViewController.o
"__TFSs21_arrayConditionalCastU___FGSaQ__GSqGSaQ0_", referenced from:
TFC12MyProject27SessionsTableViewController17viewWillDisappearfS0_FSbT_ in SessionsTableViewController.o
"__TFSs15_arrayForceCastU___FGSaQ__GSaQ0", referenced from:
__TFC12MyProject7RestApi12tokenMappingfS0_FT_CSo15RKEntityMapping in RestApi.o
__TFC12MyProject28AttendeesTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in AttendeesTableViewController.o
__TFC12MyProject27SessionsTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in SessionsTableViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o
"__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
__TFC12MyProject7RestApi12resetRestKitfS0_FT_T_ in RestApi.o
__TFC12MyProject16BluetoothManager17_startAdvertisingfS0_FT_T_ in BluetoothManager.o
__TFC12MyProject19LoginViewController32registerForKeyboardNotificationsfS0_FT_T_ in LoginViewController.o
__TFC12MyProject19LoginViewController35deregisterFromKeyboardNotificationsfS0_FT_T_ in LoginViewController.o
__TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ in LoginViewController.o
__TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_ in CheckinViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What's happening here has nothing to do with your Derived Data location.
When a swift application is built, it goes through several steps:
Write auxiliary files
Create product structure
Compile swift source for each architecture
Copy resource rules plist
Copy application bridging header
Link against swift runtime libraries for each architecture
Copy application swift module for each architecture
Create the application binary
Copy resources build phase
Copy the swift standard libraries into the application
Package it up
Sign it
Whew! That's a lot. Your build is failing when linking against the swift runtime libraries. They live in Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos inside the Xcode developer directory. Specifically, the library that is not being correctly linked is libswiftCore.dylib. If you use nm on that library, you can see it defines your first missing symbol:
quellish% nm /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib | grep compareNSStringDeterministicUnicodeCollation
00197c8c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
000000000018352c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
You can also use lipo to see what architectures are in the file:
quellish% xcrun lipo -info /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib
Architectures in the fat file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib are: armv7 arm64
It contains armv7 and arm64. It's not the library architecture that's the problem.
Linking against the swift standard library is not working. It's possible that source control or migrating Xcode versions has caused your project file to drop part of the linking step, or it's simply not able to find the libraries it needs to link against. Xcode project files are complex and use a lot of references - it's possible that a merge, etc. caused a critical reference to be come dissociated from the linking step. Without a full build log and a look at your machine it may not be possible to tell.
This library, as you might guess, has nothing to do with the project's derived data location.
The best way to move forward would unfortunately be to recreate the project file. Comparing the build log of the broken project to a swift project that does build correctly may provide some insights, but it may also be a waste of time - something fixable may be the problem, but more likely not.
I would encourage you to file a bug and include the troublesome project file with it.
I have solved my issue by deleting all the data in the ~/Library/Developer/Xcode/DerivedData folder. I read about that in another thread, but ignored it thinking a clean included that process!
I have Updated on Yosemite, Xcode 6.1.
I have updated gem xcodeproj (0.19.4) and cocoapods (0.34.4).
I have resolve my conflict by :
Clearing the Library/Developer/Xcode/DerivedData folder
replace in Target -> Build Settings -> Linking -> Other Linker Flags : $(OTHER_LDFLAGS)
Check in Target -> Build Phases -> Copy Pods Resources : "${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh"
1) I face the same problem but just clear the applications from derived data from User/Library/Developer/Xcode/DerivedData and I am able to run the code.
2) In your case may be, it will run by removing armv7 architecture from build settings. And make sure your compiler is Default Compiler in Build Settings.
Thanks I hope this helpful to you and everyone.
This seems to be caused (for most) by linking a third-party library that does not support the requested architecture.
I had somewhat similar problem (a linker error from Apple's framework). As it turned out, the problem was that I was missing the library LocalAuthentication.framework. I am wondering if maybe you need to delete the Foundation.framework from the Build Phase tab (in the Link Libraries section), and then re-add it? Maybe that will solve the problem?
'Upgraded' to xcode 6 and swift app wouldn't build for simulator yet would build fine on an iPad - Linker error, undefined symbols for i386 for the simulator.
Clearing the Library/Developer/Xcode/DerivedData folder worked for me.
There appears to be a bug in Xcode 6.0.1 that is causing the linker to drop dependencies in existing project files. I have had this same problem across several different projects, new and old, since the 6.0.1 update.
The easy 'fix' is to just trash your entire 'Derrived Data' and all build files (i.e. manually clean the project) and then rebuild after a fresh Xcode restart. Magically, the linker now finds all the missing architectures/symbols.
NOTE: I have had several incompatible v-table crashes caused by this same bug. The C++ linker appears to be generating incomplete linkages, causing absurd errors where there are no real errors to be found. Again, just rebuild from a clean state and .. ta da.. save yourself a LOT of headache and wasted time tracking down a non-issue.
I solved this issue after trying all that was suggested here with no luck.
Like someone said earlier, it's a SourceControl issue.
One of my project files (the one referenced in the error message) was missing from the project browser. However, XCode still had a reference to it (I was going to the class definition when I was selecting "jump to definition" from Xcode GUI).
As a matter of fact, the project.pbxproj was not listing it. This was probably a Git Issue. In any event, I just recreated the file in the same directory it has been recreated and voila.
I am a filly when it comes to iOS Objective C, though I have been coding in several other languages for many years. So I am stabbing around in the dark most of the time with Objective C.
I started having this error, "Undefined symbols for architecture armv7", directly after declaring some "global" variables in my .h file like so:
extern NSString *globalNotes;
extern NSString *globalUserCountry;
I was then referring to these variables from the .m file like so:
globalNotes= #"Error (Marker 1010)";
globalUserCountry= #"No result";
THE FIX - To correct this, I changed them to object properties like so:
#property(nonatomic, strong, readwrite) NSString *globalNotes;
#property(nonatomic, strong, readwrite) NSString *globalUserCountry;
And referred to them like so:
self.globalNotes= #"Error (Marker 1010)";
self.globalUserCountry= #"No result";
That seemed to fix my problem.

DTCoreText Error Message after implementation

i tried to implement DTCoreText. I follow this guide and implemented it as git submodul, but now i get an error when i try to run my app. At the Moment i´m not doing any coding with DTCoreText. I just want to test my app if it works with the new imported Data...but it do not!
I got one warning:
Static Library was rejected as an implicit dependency for 'libDTCoreText.a' because its architectures 'armv7s' didn't contain all required architectures 'armv7'
which is in my opinion the reason for the following error which occour after the warning:
Apple Mach-O Linker Error: no such file or directory: '/Users/-------------/Build/Products/Debug-iphoneos/libDTCoreText.a'
I did not forget to implement the libDTCoreText.a in "Link Binary With Libraries", but it is always red? Is this maybe the Problem?
I had a similar issue and I had to check "Build Active Architecture Only" on each of the Project configurations (Debug, Release and Deployment) and in the Build Settings of the DTCoreText project targets.
https://www.dropbox.com/s/00oktoqgse83sph/Screenshot%202014-08-07%2014.08.47.png
https://www.dropbox.com/s/gcy6ynrzqs8i7c1/Screenshot%202014-08-07%2014.10.39.png

Mach-O Linker error

I am building ipad application in XCode 4. For that, i added some outside frameworks in my project. The code work fine in simulator but showing 24 Mach-O Linker error.
I searched for this topic and get various different reasons for this error but not getting the right one.
Any suggestion will be of great help.
Most likely the library you are using has not been built for arm. For a library to work in the simulator, it must be compiled for i386 architecture. To work on the device, it must be compiled for armv architecture.
To work for both, you need what is called a "fat" binary that contains versions compiled for each of the above. If you don't have that, you will receive the linker errors.
To find out what architectures the library is compiled for, use the following command:
lipo -info mylibrary

Resources