My app uses Hpple. I've included, TFHpple.h, TFHpple.m, TFHppleElement.h, TFHppleElement.m, XPathQuery.h & XPathQuery.m. Also included ${SDKROOT}/usr/include/libxml2 and -lxml2.
I have this tiny bit of code:
NSData *data = [[NSData alloc] initWithContentsOfFile:#"example.html"];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:data];
When I try to run it, I receive this error:
"_OBJC_CLASS_$_TFHpple", referenced from:
objc-class-ref in test.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't know how to solve this. Any ideas?
What exactly do you mean by "I've included" those files? The error indicates that you didn't add TFHpple.m to your target's "Compile Sources" build phase.
Related
The codes are like this:
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[])
{
#autoreleasepool {
// insert code here...
NSLog(#"Hello, World!");
}
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:#"Hi there."];
[alert runModal];
return 0;
}
What I want is: when called from command line, this program pops up an alert box, when I close the alertbox. The program exits.
But when building, it complains like this:
Ld /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug/KeyCatcher normal x86_64
cd /Users/hanfei/Desktop/KeyCatcher
setenv MACOSX_DEPLOYMENT_TARGET 10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug -F/Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug -filelist /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Intermediates/KeyCatcher.build/Debug/KeyCatcher.build/Objects-normal/x86_64/KeyCatcher.LinkFileList -mmacosx-version-min=10.9 -fobjc-arc -fobjc-link-runtime -framework Foundation -Xlinker -dependency_info -Xlinker /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Intermediates/KeyCatcher.build/Debug/KeyCatcher.build/Objects-normal/x86_64/KeyCatcher_dependency_info.dat -o /Users/hanfei/Library/Developer/Xcode/DerivedData/KeyCatcher-hijnrqhwiafuxtdjmdubtsijyhwh/Build/Products/Debug/KeyCatcher
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_NSAlert", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I choose the template for new project, I select command line tool instead of CoCoa Application as I just need CoCoa to display an alertbox. Does anyone have ideas about this..
That's because NSAlert is not #imported.
AppKit.h is not included by default when you create a command line tool , as you can see in the link, AppKit imports NSAlert.h.
EDIT:
First, to compile you need to add the Cocoa framework in your project.
Second, all the code should be enclosed in the #autoreleasepool section
#autoreleasepool {
// insert code here...
NSLog(#"Hello, World!");
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:#"Hi there."];
[alert runModal];
}
Your code will compile and run, but I think you'll have some other runtime errors.
I got the same error in C++ project that was using a NSAlert, this worked for me:
1) Adding
#include <Cocoa/Cocoa.h>
2) Adding Cocoa Framework in project->Buld Phases->Link Binary With Libraries.
3) Setting "Type" of all my .cpp files to "Objective-C++ Source" in the most right column in xCode.
you need to add this before main function
#import <AppKit/AppKit.h>
You need to import AppKit as mentioned by others and – as important as the framework – you need a run loop. So insert before the runModal line
[NSApplication sharedApplication];
to launch the "application" and the run loop
I'm trying to get theos working on OSX Mavericks. I recently purchased an iPhone 5s and have since then jailbroken it. Now I am trying to get Theos working so I can start working on some tweaks again. I had it working on OSX Lion and for IOS 5 and 6. I have a very simple program which should display a UIAlert when an application launches. The problem is, when i run the make command in an attempt to compile my code i get this error:
Making all for tweak test...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak test...
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_UIAlertView", referenced from:
objc-class-ref in Tweak.xm.b0410391.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/test.dylib.1cc22e7c.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [test.all.tweak.variables] Error 2
Williams-MacBook-Pro-2:test williamfsmillie$
Here is my code for Tweak.xm:
%hook SBApplicationIcon
-(void)launch{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"TEST" message:#"message...." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
%orig;
}
%end
And my makefile:
export SDKVERSION=7.0
include theos/makefiles/common.mk
TWEAK_NAME = test
test_FILES = Tweak.xm
ARCHS = armv7 arm64
test_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
Thanks!
It's an old question, but still I figured I should answer it for people who have the same question. You need to call objc_getClass for it to work, like this:
UIAlertView *alert = [[objc_getClass("UIAlertView") alloc] initWithTitle:#"TEST" message:#"message...." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
Note that this is not required on the left hand side of the assignment.
Edit your makefile and insert the following at the top:
export ARCHS = armv7 armv7s arm64
export TARGET = iphone:clang:7.0:7.0
Also, link the Foundation framework with your tweak.
To fix the alert issue, you must include UIKit/UIKit.h (Sorry, I can't comment)
You need to include the UIKit framework in your Makefile by adding XXX_FRAMEWORKS = UIKit where XXX is your project name
If you're using iOS 7, you have to hook the correct method: try -(void)launchFromLocation:(int)location.
Because it uses a parameter, your code should look like this:
-(void)launchFromLocation:(int)location {
// your stuff
%orig(location);
}
I would say update your Headers.
Download new set from
rpetrich
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
symbol(s) not found in XCode, Cocoa application
Below is the error information
Undefined symbols for architecture x86_64:
"_NSPasteboardTypeString", referenced from:
_main in main.o
"_OBJC_CLASS_$_NSPasteboard", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
below is the code. Should I include more header?
#import <Foundation/Foundation.h>
#import <AppKit/NSPasteboard.h>
int main (int argc, const char * argv[])
{
#autoreleasepool {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSString *content = [pasteboard stringForType:NSPasteboardTypeString];
NSLog(#"%#", content);
}
return 0;
}
correctly link against AppKit.framework, headers dont contain the 'real' code
I am trying to use JSON to parse the sting that i have got from ASIHttpRequest but i find linker error e.g.
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SBJsonParser", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation
Below is the code that i am using.For more detail i have already added Json classes in the project.
(void)requestFinished:(ASIHTTPRequest *)request{
// Use when fetching text data
NSString *responseString = [request responseString];
SBJsonParser *parser=[[SBJsonParser alloc]init ];
NSDictionary *obj=[parser objectWithString:responseString error:NULL];
NSArray *list=[obj objectForKey:#"lessons"];
// Use when fetching binary data
// NSData *responseData = [request responseData];
}
From the search i found that we have to include the .m Json files in the compile source. We can do this by click on the project->Target->Build Phase->compile source->add the all the json .m files
I'm trying to create an ObjC application that will control iTunes. I need a method that will return an array of all the playlists in iTunes.
I'm getting the most bizarre, unhelpful error message ever... First the code:
#import "MusicControl.h"
#import "iTunes.h"
#implementation MusicControl
- (SBElementArray *) playlists {
// Create iTunes Object
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:#"com.apple.iTunes"];
NSArray *sources = [iTunes sources];
iTunesSource *librarySource = nil;
for (iTunesSource *source in sources) {
if ([source kind] == iTunesESrcLibrary) {
librarySource = source;
break;
}
}
return [librarySource userPlaylists];
}
#end
I have no idea whether the array return is working or not because, after doing some debugging, I found that where this is bombing out is the very first line where I create the iTunes object, which was copied and pasted from Apple's website...
The error I'm getting is:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_SBApplication", referenced from:
objc-class-ref in MusicControl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestion as the what the heck is going on?
This message (and similar ones) means that the linker is looking for some specific symbol, but can't find it. In your case it is SBApplication.
If you have not already done so, you should make sure that you have linked to the ScriptingBridge framework.
To add a framework, click on the project's icon at the top of the left hand bar in Xcode, then select Build Phases. If Link With Binary Libraries is not already expanded, do that and add the framework.
The same procedure can be used for plain libraries (a framework is really just a wrapper around a library, at least for the purpose of this discussion).