Cocoa Static Library with ZXing error - ios

My project uses some Cocoa static libraries, one of which is a Zxing Project. I am getting a lot of errors while trying to incorporate this project. Weirdly enough, I was able to create a demo with Zxing in a separate project, without any errors. My main project builds and runs ok, as long as I do not include the Cocoa static library for Zxing.
So the question is, how do I include the ZXing static library to my Cocoa project? How do I configure library (e.g. how do I set the Header Search Paths~~).
Thanks.
Some detail about my project
The Structure
EnjoyMobile
-CustomStaticLibrary.xcodeproj
-ZXingWidegt.xcodeproj
Header search Paths in my -CustomStaticLibrary Target
./zxing/iphone/ZXingWidget/Classes
./zxing/cpp/core/src
The error
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_QRCodeReader", referenced from:
objc-class-ref in libCustomerLibrary.a(CustomerViewController.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Zxing is kind of a painfull integration, also in the newer versions of Xcode Apple added more error checks. I would suggest you to use cococapods for a better integration or this ObjectiveC wrapper here

It's not seeing some of the lib classes. Double check the steps in the README, particularly step 2. If it still fails, post the link command that fails.

Related

Symbol(s) not found & Undefined symbols for architecture x86_64: Visitor Framework

Hi i'm trying to integrate BoldChat framework into IOS react native project.
After integrating via following steps
Project target -Build Phases - Link binary with libraries - Plus
button - framework
While trying to build, im getting below error
Undefined symbols for architecture x86_64:
"_utf8_nextCharSafeBody", referenced from:
-[BC_SRWebSocket _innerPumpScanner] in VisitorSDK
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried removing ,re-adding framework , it's not working.
Even tried creating new project and integrating , still error is same.
please let me know how to resolve this. I have even tried similar stack overflow answers, still error exists.
In most cases this points to one or more missing references to frameworks in the section Linked Frameworks And Libraries in the Targets settings of the app in Xcode.
To find out which framework reference should be added:
Right-click on the error in the build time errors
list Choose 'Reveal in Log',
Search in the log for 'Undefined symbols for architecture x86_64'
A list of undefined 'symbols' (mostly class methods and properties)
is displayed
To find out which framework reference should be added, select such
undefined symbol, right-click and choose Search with Google
In most cases you'll end up in the documentation of Apple, which
should give a clue about the related framework
Add the framework in the section Linked Frameworks And Libraries by
clicking on the + button.
Build the app.
If necessary, repeat this procedure for remaining undefined
'symbols'.
In my case libucucore.tbd is missing . Added that and error is gone.

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.

Xamarin - can no longer debug on device -error MT5211

Until the most recent upgrade I could debug on a device. I now get the following errors:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ZipArchiveDelegate", referenced from:
objc-class-ref in registrar.armv7.o
_OBJC_CLASS_$_MiniZip_ZipArchive_ZipArchive__ZipArchiveDelegate in registrar.armv7.o
"_OBJC_METACLASS_$_ZipArchiveDelegate", referenced from:
_OBJC_METACLASS_$_MiniZip_ZipArchive_ZipArchive__ZipArchiveDelegate in registrar.armv7.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error MT5211: Native linking failed, undefined Objective-C class: _OBJC_CLASS_$_ZipArchiveDelegate. If '_OBJC_CLASS_$_ZipArchiveDelegate' is a protocol from a third-party binding, please check that it has the [Protocol] attribute in its api definition file, otherwise verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
error MT5210: Native linking failed, undefined symbol: _OBJC_METACLASS_$_ZipArchiveDelegate. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
error MT5202: Native linking failed. Please review the build log.
I've cleaned, and rebuilt but with no avail. Any ideas?
It turns out this error is caused by the improved strictness of the new default static registrar:
http://docs.xamarin.com/releases/ios/xamarin.ios_7/xamarin.ios_7.2/#1
http://docs.xamarin.com/guides/ios/advanced_topics/registrar/#Protocols_must_have_the_Protocol_attribute
You can work around the problem temporarily by requesting that Xamarin.iOS use the legacy registrar. To do this, add "--registrar:legacy" under "Project Options -> iOS Build -> Additional mtouch arguments".
The components team has also contacted the authors of the ZipArchive component to let them know about the issues with the new registrar, but they have not yet replied. In case the they do not provide an update soon, you can look at transitioning to an open-source binding for the same library written by the Xamarin components team [1]. One caution with this binding is that the method and class names might be different from the ones in the ZipArchive component, and the namespaces are definitely different. So you will need to update the names in your app accordingly.
[1] https://github.com/mono/monotouch-bindings/tree/master/ZipArchive
Having the exact same issue. But both on zipArchive and SDWebImage.
Uninstalled-re-installed xamarin. Did not help.
Created a solution from scratch, added zipArchive and added to the using section.
The project does not build for device. But building for simulator is fine.
Emailed Xamarin support for help.

linking springboard in iOS tweak

I'm trying to develop a simple ios tweak that uses some springboard components. I've dumped the headers and included the one I need (SBLockScreenNotificationScrollView.h), but when I compile I get a linker error:
Undefined symbols for architecture armv7s:
"_OBJC_CLASS_$_SBLockScreenNotificationScrollView", referenced from:
objc-class-ref in NotificationSwipe.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've tried copying the SpringBoard binary from phone and adding it under Link Binary with Libraries in xcode. Thanks for the help.
When you don't have class implementation or library it defined in you have to obtain the class at runtime. This is what objc_getClass function is for. It returns an objc class at runtime and gives you the ability to use the class without knowing anything about him at compile-time.
Just replace SBLockScreenNotificationScrollView with objc_getClass("SBLockScreenNotificationScrollView").
I suggest you read about objective-C runtime. Developing tweaks requires you to understand at least basics in which case you wouldn't ask this kind of questions.

Xcode gives Apple Mach-O linker error

I just compiled a project and Xcode returns these two errors which don't seem to be my code's fault. How do I fix them?
Undefined symbols for architecture i386:
"_vImageBoxConvolve_ARGB8888", referenced from:
-[UIImage(Blur) boxblurImageWithBlur:] in UIImage+Blur.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Teaching a man (or women) how to fish:
Usually Mach-O Linker Error means you have not included a header file for a function you are using in your code.
Easiest way is to copy that function or method call and paste into Xcode quick search using shift+command+O. This will search all frameworks (and header files), find that function or method call and show you its location (the header in this case):
In this case, this call belongs to the Accelerate framework so on top of your file, enter:
#import <Accelerate/Accelerate.h>
When doing quick search, you might have to get rid of leading underscore. In other words, search for vImageBoxConvolve_ARGB8888
Hope this helps
Google is your friend: someone else fixed this by adding the Accelerate framework to their project (and this does look like a framework error).
https://github.com/rnystrom/RNBlurModalView/issues/5
Make sure you also have the QuartzCore framework included as well, as that is also required by that library.
Apparently vImageBoxConvolve_ARGB8888() is not defined. See if the Accelerate framework is properly included in the project.

Resources