I converted my project from swift 3 to swift 4 and am using the latest version of xcode 9. On building, I get the following error :
Undefined symbols for architecture arm64:
"__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from:
__T06SpotMi8CameraVCC12capturePhotoyypF in CameraVC.o
"__T012AVFoundation39_AVCapturePhotoSettingsSwiftNativeTypesPAAE016availablePreviewc11PixelFormatG0SaySo8NSNumberCGfg", referenced from:
__T06SpotMi8CameraVCC12capturePhotoyypF in CameraVC.o
ld: symbol(s) not found for architecture arm64
I am out of clues. Any help will be much appreciated.
Cheers!
There is a bug in XCode9. Apple inadvertendly made some functions in AVFoundation private.
Workaround:
Change availablePreviewPhotoPixelFormatTypes to __availablePreviewPhotoPixelFormatTypes in your source.
Same goes for the following:
supportedColorSpaces -> __supportedColorSpaces
supportedFlashModes -> __supportedFlashModes
availableRawPhotoPixelFormatTypes -> __availableRawPhotoPixelFormatTypes
availablePhotoPixelFormatTypes -> __availablePhotoPixelFormatTypes
Then it might compile!
Good Luck!
Related
The Issue
I'm trying to compile an iOS test project with the NDI v3.0 SDK and I'm running into Apple Mach-O Linker (ld) Errors.
It's a static framework (libndi_ios.a) that you are to link your binary to, and reference the headers in order to use their C/C++ API in our ObjC++ code.
I am copying sample code of theirs that simply creates a NDIlib_send_instance_t for use. As soon as I attempt to compile this code the build fails with this linker error:
Undefined symbols for architecture armv7:
"NDI_multicast::send::packetize::~packetize()", referenced from:
std::__1::__shared_ptr_emplace<NDI_multicast::send::packetize, std::__1::allocator<NDI_multicast::send::packetize> >::~__shared_ptr_emplace() in libndi_ios.a(send_server.o)
std::__1::__shared_ptr_emplace<NDI_multicast::send::packetize, std::__1::allocator<NDI_multicast::send::packetize> >::~__shared_ptr_emplace() in libndi_ios.a(send_server.o)
std::__1::__shared_ptr_emplace<NDI_multicast::send::packetize, std::__1::allocator<NDI_multicast::send::packetize> >::__on_zero_shared() in libndi_ios.a(send_server.o)
NDI_multicast::send::send(NDI_multicast::send::config_multicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
NDI_multicast::send::send(NDI_multicast::send::config_unicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
NDI_multicast::send::~send() in libndi_ios.a(NDI_multicast_send.o)
"NDI_multicast::send::packetize::packetize()", referenced from:
ndi::reference::send::server::send(ndi::reference::buffer_pack const&, ndi::reference::send::connection*) in libndi_ios.a(send_server.o)
NDI_multicast::send::send(NDI_multicast::send::config_multicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
NDI_multicast::send::send(NDI_multicast::send::config_unicast_t const&) in libndi_ios.a(NDI_multicast_send.o)
"NDI_multicast::send::packetize::operator()(std::__1::function<std::__1::pair<unsigned char const*, unsigned long> (unsigned long, unsigned long)>)", referenced from:
ndi::reference::send::server::send(ndi::reference::buffer_pack const&, ndi::reference::send::connection*) in libndi_ios.a(send_server.o)
NDI_multicast::send::operator()(NDI_multicast::send::buffer_source_t&, std::__1::pair<int, int>, std::__1::function<void (bool)>) in libndi_ios.a(NDI_multicast_send.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Reproducing
You can reproduce this error by following the steps below. I'm currently using Xcode 9.4 (and I've tested on the latest beta with the same results)
The steps I have taken to get this error:
Install the NewTek NDI SDK from their website here
Create a new Xcode project for a single view Objective-C iOS app
Rename the ViewController.m to ViewController.mm (So it's compiled as Objc++)
Add /NewTek NDI SDK/include to Header Search Paths
Add /NewTek NDI SDK/lib/iOS to Library Search Paths
Add the libndi_ios.a under the "Link Binary With Libraries" in "Build Phases".
Add this code to the ViewController.mm:
NDIlib_initialize();
NDIlib_send_create_t NDI_send_create_desc;
NDI_send_create_desc.p_ndi_name = "My Audio";
NDI_send_create_desc.clock_audio = true;
// (Without this line, everything compiles fine...)
NDIlib_send_instance_t pNDI_send = NDIlib_send_create(&NDI_send_create_desc);
This will fail with the error above.
One thing that I found interesting was that using other code from their samples, such as for receiving video, worked as expected. The issue only exists when using the NDIlib_send_create API.
Does anyone have any tips, or ideas to lend?
You can find the NewTek iOS SDK by requesting it on their website here.
use nariakiiwatani's ofxNDI static library version.
https://github.com/nariakiiwatani/ofxNDI/blob/master/libs/NDI/lib/iOS/libndi_ios.a
I solved same problem by his static library version.
After contacting support at NewTek about this issue, and linking to this post, they have updated (or are in the process of updating) the library that is included in the SDK. I believe that it will be posted on their website shortly.
Thanks to both Lightlive.dev and emrahgunduz for your suggestions 🙌
The app I've been working on uses an external library, pdlib, which has it's own externals (.c files) which I've been importing via the bridging header #import "Uzi.c" and calling in my main Swift file via Uzi.c's setup function Uzi_setup() in my ViewController class. I've had no problem with this until after updating to new public Xcode 8 a few days ago (I had no problem with Xcode 8 Beta 1 over the Summer).
Here are the 7 errors I get, listed under a single "Mach-O Linker Error" umbrella:
Undefined symbols for architecture x86_64:
"_Uzi_bang", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_class", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_float", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_new", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_pause", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_resume", referenced from:
_Uzi_setup in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Those undefined symbols are 6 functions and a class declare from Uzi.c. Here's a link to the whole c file: https://github.com/electrickery/pd-miXedSon/blob/master/hammer/Uzi.c
I've tried every solution I've found online for dealing with similar problems, with no solution yet... I tried changing the "Architecture" and "Valid Architecture" settings to only armv7 and armv7s (no arm64) and changed "Build Active Architecture Only" to "No". These step seem to help others in similar situations, but they didn't work for me (and taking away arm64 causes additional errors to appear).
XCode 8 is pretty recent (the public version was released Sept. 13), so there are virtually no other questions about this upgrade causing a similar problem.
Any help would be greatly appreciated!
Solved by #danomatika on GitHub: https://github.com/libpd/libpd/issues/149
"You generally shouldn't include/import an implementation file aka .c, .cpp, .m, etc. This is what is causing the duplicate symbol issue.
This is what the "forward function declaration" in the header file is for: to tell the compiler that a function exists and what data it takes/returns. The compiler then assumes the actual implementation of the function exists in an implementation file. If it can't be found, then you get an "undefined symbol error." If you somehow end up declaring the function twice, aka include both a header with the forward declaration and the implemetaton of the function itself in the .c file, then you get a "duplicate symbol error."
This is all lower-level stuff that is only really an issue since Pd externals are designed around being dynamic libraries, so are not built or provided with headers which include the function declarations. This is why you have to do a little extra work and do it yourself.
Their are two easy fixes for this, both of which involve declaring the required function you want to call from the .c file in a header file.
Simply declare the function in the bridging header:
void uzi_setup();
Create a header, say Externals.h, and declare all of the externals stuff there:
// forward declare setup functions only found in .c implementations
void uzi_setup();
// convenience wrapper function
void externals_setup() {
uzi_setup();
}
Then import the file in your bridging header:
#import "Externals.h"
And in swift, you can now do:
externals_setup()
I use custom static frameworks to package my modules, such as A, B, C..., and A is a foundation layer, so B & C depend on A, they all use a symbol in A named "Semaphore".
Now I add A, B, C into my App "DemoX", DemoX only use B & C directly, when linking there is an error.
Changed: DemoX depends on a static library "libM" which uses A directly.
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Semaphore", referenced from:
objc-class-ref in libM.a
objc-class-ref in B
objc-class-ref in C
ld: symbol(s) not found for architecture i386
Actually, I use "nm" command to show the symbols in A, it has "_OBJC_CLASS_$_Semaphore".
So, how to solve this?
Thanks!
I solved this.
It's all my fault, this error occurs in release only, because I compile A with "Symbols Hidden by Default" YES, so others can't see all the symbols A has. Set it to NO, all is good.
Need to generate QR code from iOS for different strings. Tried out the following library:
**jverkoey-ObjQREncoder-e1841fe**
being able to generate QR Code .. but this code cannot be read by any readers.
**iOS-QR-Code-Generator**
Following the documentation provided But facing linking problem when i am trying to add the 'kuapay-iOS-QR-Code-Generator' to generate QRCode. I followed the way that is written in the github project
"To build your own project from this template you must attace the libz.dylib library to your target in Xcode. You must also drag the QRDraw and libpng folder files into your project. Update the Header Search path to look in the libpng folder in your target build settings menu."
But it give me 6 error message. These are -
Undefined symbols for architecture i386:
"CQR_Encode::EncodeData(int, int, bool, int, char*, int)", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"CQR_Encode::~CQR_Encode()", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"_OBJC_CLASS_$_FileManager", referenced from:
objc-class-ref in RootViewController.o
"QRDrawPNG::draw(char*, int, int, unsigned char (*) [177], void*)", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"CQR_Encode::CQR_Encode()", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"vtable for QRDrawPNG", referenced from:
QRDrawPNG::QRDrawPNG() in RootViewController.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can anyone help me with this? OR suggest a better QRcode generator for iOS device?
Thanks a lot!
This issue is caused because you are using c++ code silently in your app , use .mm instead of .m in your RootViewController .
Check you have the file Barcode.mm, qr_draw_png.mm, QR_Encode.mm linked to your project target. Also you may be add "-fno-objc-arc" flag.
I cannot compile my project for the device or simulator anymore. I get 13 Apple Mach-O-Linker errors. It all started after I failed attempt to use sharekit. Here is the log from the error:
ld: warning: directory not found for option '-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks'
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_NSURLRequest", referenced from:
objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in main.o
"_objc_msgSendSuper2", referenced from:
-[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileViewController didReceiveMemoryWarning] in Brandsonic_Web_mobileViewController.o
-[Brandsonic_Web_mobileViewController dealloc] in Brandsonic_Web_mobileViewController.o
"_objc_setProperty", referenced from:
-[Brandsonic_Web_mobileAppDelegate setWindow:] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate setViewController:] in Brandsonic_Web_mobileAppDelegate.o
"__objc_empty_vtable", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
_OBJC_CLASS_$_SecondView in SecondView.o
"_objc_msgSend", referenced from:
_main in main.o
-[Brandsonic_Web_mobileAppDelegate application:didFinishLaunchingWithOptions:] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate GOOGLE] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate YOUTUBE] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate WIKI] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileViewController webView:shouldStartLoadWithRequest:navigationType:] in Brandsonic_Web_mobileViewController.o
...
"__objc_empty_cache", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
_OBJC_CLASS_$_SecondView in SecondView.o
"_OBJC_CLASS_$_NSObject", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
"___CFConstantStringClassReference", referenced from:
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
...
"_OBJC_CLASS_$_NSKeyedUnarchiver", referenced from:
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSUserDefaults", referenced from:
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSURL", referenced from:
objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
'
How do I fix this? Please help.
For every one with an similar error.
If that happens you normally can remove the "Path" under Point
target->Build Settings->Library Search Paths
This error can occur when a framework is added to a project more than once.
You can fix this by removing the duplicate. To find it, select the framework in the Xcode project navigator and choose Show in Finder. Then clean and build your project.
This can also be caused if you're missing framework header files or a reference to them.
In that case, you should trying removing the SDK or framework and adding it again.
Good luck.
If you installed dependencies using CocoaPods, make sure you open your XCode project by clicking on your .xcworkspace file, and not the .xcodeproj file.
It seems like the project file may have been corrupted somehow.
The most sure way to fix this is to create a new project, and move your files and old info.plist over on top of it.
The next most likely way to fix this is to create a new target in your current project, and see if that will compile (if you have any special flags from the old target you'll want to copy them).
Also you could try compiling for Release vs. Build and if one of them works look at all of the compiler options and see what is different.
If you added a header search path for Sharekit, perhaps try clearing out the whole header search path and see if that fixes things. Also make sure your project is still including frameworks that a brand new project includes (UIKit and NSFoundation, possibly others).
Add the .m file to compile source page.
steps:-
clicking on he project in the navigation menu
select the target
select build phases
Select the + button and add the file in compile sources.
Hope that helps anyone with this problem
The problems are the spaces in your path:
xcode uses the following switch for the linker:
-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks
and since it is not quoted it won't work. ( It is looking for the folder "/Users/bbrandy95/Documents/Broken"
You should rename the directories, or look through the project settings and add quotes to the directories. (But this might be tricky to find)
I too had the same problem with 45 same kind errors, when I add the libxml2.dylib into my project the errors disappeared.
In some cases your library Search Path is empty.Because there are many Apple-mac-o linker errors.
See my answer also at.
Apple Mach-O Linker Error using Core Data classes in OCUnit
I had this issue, now for my circumstances selecting a more recent iOS version as the deployment target rectified this for me. My project was set to deploy to iOS 5 by default and changing this to 7 (the most recent) did the trick.
For anyone new to iOS development this can be done by clicking on your XCode project file in the navigator > deployment info > deployment target and selecting the appropriate version from the drop down menu.
I'm sceptical that this will solve some of the issues that others are having but there may be a few people out there in the same boat as me.
It's because the project inserted the core data's xcdatamodeld file in compile sources. Select your project -> Build Phases -> Compile Sources and delete projectName.xcdatamodeld file.
And also check if you have imported .m file instead of .h file, it also gives the same linker error. Check all the #import codes.
And check if you have added core data frame work in library and imported core data .h file. Check for creation of NSManagedObject and import it's file.
Just try it and reply me if still any error.
I had the same problem,
I just simply set the Build Option -> Enable Bitcode to NO
I faced this problem with my self developed cocoapod.
Error was: Apple Mach-O Linker errror
It turned out, that I had defined a protocol and implemented a protocol extension. One method of the protocol extension was public, but the protocol itself was not. And this caused the Apple Mach-O Linker error.
Example:
protocol MyProtocol { var field: String { get} }
extension MyProtocol { public func giveMeSomething() -> String }
public class MyClass: MyProtocol {}
In the description the error mentioned MyClass referenced from MyProtocol -> MyProtocol referenced from giveMeSomething()...
So, the solution was to make Myprotocol also public
Hope that helps someone.