I'm trying to add this iOS lib PTImageAlbumViewController to an existing project that I'm working on and I'm getting compile errors. There is a sample project included and its dependent on a couple of other libs. The sample project works just fine but I can't get it migrated to my own project without errors. I tried pulling the files direct from the project by dragging them from project to project but its still not working
Is there something I'm missing?
Undefined symbols for architecture armv7:
"_OBJC_METACLASS_$_NetworkPhotoAlbumViewController", referenced from:
_OBJC_METACLASS_$_PTImageAlbumViewController in PTImageAlbumViewController.o
"_OBJC_CLASS_$_NIPhotoAlbumScrollView", referenced from:
_OBJC_CLASS_$_PTImageAlbumView in PTImageAlbumView.o
"_OBJC_CLASS_$_NetworkPhotoAlbumViewController", referenced from:
_OBJC_CLASS_$_PTImageAlbumViewController in PTImageAlbumViewController.o
"_NIPathForBundleResource", referenced from:
-[PTImageAlbumViewController viewDidLoad] in PTImageAlbumViewController.o
"_OBJC_METACLASS_$_NIPhotoAlbumScrollView", referenced from:
_OBJC_METACLASS_$_PTImageAlbumView in PTImageAlbumView.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What it can't find is the nimbus files.
If you have added the nimbus and SDURLCache files to your project, then it should just be a matter of making sure they're included in your application's target.
Make sure ALL the files got into your project and are in the right target. For example, the first error is regarding NetworkPhotoAlbumViewController.m. Is that file in your project and in the right target?
If so, the one other possibility is that it's simply not building for this architecture for some reason. You can find out by navigating the tree from your DerivedData directory down to where the object files are stored and using nm to search the object files for the missing symbols.
Example on my machine:
cd /Users/username/Library/Developer/Xcode/DerivedData/AlbumDemo-eyqszubjyqhczreurkblqktoxjja/Build/Intermediates/AlbumDemo.build/Debug-iphonesimulator/AlbumDemo.build/Objects-normal/i386
nm NetworkPhotoAlbumViewController.o | grep _NetworkPhotoAlbumViewController
00000000 t -[NetworkPhotoAlbumViewController shutdown_NetworkPhotoAlbumViewController]
0000e0fc s -[NetworkPhotoAlbumViewController shutdown_NetworkPhotoAlbumViewController].eh
0000cde8 S _OBJC_CLASS_$_NetworkPhotoAlbumViewController
0000c9b4 S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._activeRequests
0000c9bc S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._highQualityImageCache
0000c9b0 S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._queue
0000c9b8 S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._thumbnailImageCache
0000cdfc S _OBJC_METACLASS_$_NetworkPhotoAlbumViewController
0000cfe0 s l_OBJC_$_INSTANCE_METHODS_NetworkPhotoAlbumViewController
0000d084 s l_OBJC_$_INSTANCE_VARIABLES_NetworkPhotoAlbumViewController
0000d0e0 s l_OBJC_$_PROP_LIST_NetworkPhotoAlbumViewController
0000d100 s l_OBJC_CLASS_RO_$_NetworkPhotoAlbumViewController
0000cfb8 s l_OBJC_METACLASS_RO_$_NetworkPhotoAlbumViewController
The fact that these symbols do not have a "U" in the second column means that they are defined in this object file. You can find the meaning of all the nm output from the nm man page.
Sometimes when you create a new Class file Xcode doesn't add it to the "Compiled Sources"
Select Project Icon > Targets > Build Phases > Compile Sources
And click the + button to add the Class *.m file.
Related
I've done this before, several years ago with Xcode 5 or 6. Now using Xcode 8 or 9, I seem to be missing someting.
No matter what I've done, when I try to build and link my project, I get the Linker message:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_MyClass", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is not a duplicate question. It is not an architecture issue.
None of the other results I've found on S-O or google resolve this issue.
I'm obviously missing some build settings, but cannot figure out which one(s).
Between build attempts I've cleaned the build folder, and deleted DerivedData. Quit and restarted Xcode. Created a new set of projects with a new workspace and walked through the steps outlined below.
I'm writing in objective-C for this project if that matters (I don't think it does)
My question is what did I forget?
What I did --
Create a project for my framework and static library
a) create the project for a cocoa-touch framework - let's call it mySDK which creates mySDK.framework
b) Add a target for a cocoa-touch static library - let's call it SDK which creates libSDK.a
c) optionally build both targets -- they build fine
d) close the project
Create a project for my application - myApp - then close the project
Create a workspace - myWorkspace -- and open the workspace
Drag both project files from #1 mySDK and #2 myApp into the workspace
Build the framework and static library (both build and create the targets successfully)
Add the static library to myApp
a) Select myApp and go to build phases
b) Open Link Binary with Libraries
c) Drag from the library build products libSDK.a into the link binaries pane, set to "Required"
The library now appears in the Frameworks group-area in the myApp
7) Select the myApp project and go to build-settings
Add to Header Search Paths = "$(SRCROOT)/../mySDK/mySDK"
This resolves compile errors in finding the headers
Now I ask, why do I need to do anything else, shouldn't Xcode figure the rest out?
Various solutions or tutorials I've reviewed suggest adding:
Other Linking Flags = -ObjC
Library Search Paths = $(BUILT_PRODUCTS_DIR)
Library Search Paths = "$(SRCROOT)/../mySDK"
Changing Skip Install from YES to NO
Installation Build Product Location = $(BUILT_PRODUCTS_DIR)
I've tried all of these in different combinations.
Once I added the library to myApp I see that the Frameworks/libSDK.a file changes from red to black when I build the library so something in the workspace/project knows I built the library and it sees it.
So why when I try build myApp, do I still see the liner error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_MyClass", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Nothing I have done seems to clear that error. I am pulling my hair out trying to find a solution.
I have also checked that it is building all the appropriate architectures, confirmed it using 'lipo -info'
Xcode obviously knows about the library, why isn't it linking?
My app also compiled with no problem but would hit an error while linking to the static library. My library was based on C++.
I had 2 problems to fix in my case:
The headers lacked proper extern "C" declarations for C functions in a C++ file.
One .cpp file did not #include its matching header so the extern "C" would be properly applied to the compiled version.
The linker had issues because the compiler used a mangled name for the function due to the mistakes. Later confirmed this by looking in the .a file with a text editor. I found my function with "_Z11" prefixed and "v" suffixed.
There was another clue: the error was reporting the missing function name with an underscore at the front.
Undefined symbols for architecture arm64:
"_myCFunction", referenced from:
SwiftModule.swiftFunction () -> () in MySwiftClass.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm trying to make a single view application for iOS and tvOS with MobileVLCKit.
I downloaded files from git.
I ran ./buildMobileVLCKit.sh with -f key and got a framework ("MobileVLCKit.framework" folder containing MobileVLCKit binaty and Headers subfolder).
I temporary put the framework into ~/Desktop/FrameworkFolder/
I created new project in XCode, chose "File->Add files" and located the framework.
Added Framework Search Path in Project Options (~/Desktop/FrameworkFolder/, recursive).
Added #import into ViewController.h file.
Added VLCMediaPlayer *vPlayer = [[VLCMediaPlayer alloc] init]; into ViewController.m -> viewDidLoad method.
This is my binary:
imac:~ vlad$ file ~/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit: Mach-O universal binary with 5 architectures
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture armv7): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture armv7s): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture i386): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture x86_64): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture arm64): current ar archive random library
When I try to build and run the project I'm getting two types of errors:
If I'm working with AppleTV project:
ld: in /Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit(VLCMediaPlayer.o), building for tvOS, but linking in object file built for iOS, for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I'm working with iOS project:
Undefined symbols for architecture x86_64:
"_AVAudioSessionCategoryPlayback", referenced from:
_Start in MobileVLCKit(audiounit_ios.o)
_Pause in MobileVLCKit(audiounit_ios.o)
"_AVAudioSessionModeMoviePlayback", referenced from:
_Start in MobileVLCKit(audiounit_ios.o)
_Pause in MobileVLCKit(audiounit_ios.o)
"_AudioComponentFindNext", referenced from:
_Start in MobileVLCKit(audiounit_ios.o)
"_AudioComponentInstanceDispose", referenced from:
_Stop in MobileVLCKit(audiounit_ios.o)
— at the begining, and:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Showing first 200 notices only
— at the end of output. And 155 critical errors between.
I have tried to use precompilled framework as well, same result.
The questions are:
What am I doing wrong?
How can I solve this issue and successfully
build and run the project(s)?
Thank you for any help!
The reason of ld and clang errors was that the Framework and the Library has been built wrong.
The reason of multiple errors during working with iOS project is that required system frameworks has not been included.
I built the static library using XCode and the issue has been solved!
I'm using xmmp library in a project .When i am adding library folder in my project then i got this error xmpp 'libxml/xmlversion.h' file not found after at Google i get this solution Goto Projects -> Build Settings and add “$SDKROOT/usr/include/libxml2 ” to Header search path it's work perfectly .But now new problem is arise . New three errors append . List are bellow :
ld: warning: directory not found for option '-L/Users/Mac-Devs/Documents/Ferrakkem/DivineIosDialer/../../g729'
Undefined symbols for architecture x86_64:
"_dns_free_resource_record", referenced from:
-[XMPPSRVResolver processRecord:length:] in XMPPSRVResolver.o
"_dns_parse_resource_record", referenced from:
-[XMPPSRVResolver processRecord:length:] in XMPPSRVResolver.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I solved my problem by adding libresolv.tdd at "Link Binary With Libraries".
For XCode8 in my build settings, I added /usr/local/opt/libxml2/include, to my User Header Search Paths.
I also added Select recursive->Yes, from the Pull down in the same row, as you added the above search path.
I'm trying to integrate MetatoneOSC into a brand new Swift iOS project.
What I've done so far:
Create new iOS Swift Project
Drag folder full of .h and .m files into Xcode project
Create a functioning bridging header (autocomplete now works for methods in the library) - #import "MetatoneOSC/F53OSC.h"
Put the following code in ViewController.swift:
let client = F53OSCClient.init()
The build fails with the following error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_F53OSCClient", referenced from:
type metadata accessor for __ObjC.F53OSCClient 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)
Each new class I use in my code creates a duplicate error, with a different class name after $_F53OSC in the error message.
I have tried setting up a new Objective-C project to make sure it's not a bridging error, and I get exactly the same error. Anyone know how I can resolve this?
This generally means you forgot to compile the relevant .m file. In you "Build Phases > Compile Sources" step for the target, make sure you've included all the relevant files. This doesn't always happen automatically if you just drag them into the project.
I am trying to use SBSRemoteNotificationClient.h file of SpringBoardServices framework downloaded from GitHub. I directly drag and dropped downloaded SBSRemoteNotificationClient.h file into Xcode and tried to compile it. But I am facing below error during compiling.
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_SBSRemoteNotificationClient", referenced from:
objc-class-ref in MyClass.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I added #import "SBSRemoteNotificationClient.h" to my MyClass.m file.I also added path of SBSRemoteNotificationClient.h in Build Settings -> Search paths -> User Header Search paths like this /Users/awsuser006/Desktop/iphone-private-frameworks-master/SpringBoardServices/
But I am facing above mentioned error. Is this the right way of using .h files of private frameworks?
This is a linker error. The header was correctly parsed, but the framework symbols were not found. Make sure you are linking the SpringBoardServices framework.
Use
find /Applications/Xcode.app/ -name 'SpringBoardServices.framework'
to find it, then add -framework SpringBoardServices and -F /the/path/returned/by/find/ (without SpringBoardServices.framework at the end of the path) to your compilation flags.
Adding the framework using Build Phases > Link Binary With Libraries > (+) in your Xcode project may also work.
Find the framework symbols
Drag & drop them into Link with binaries...