Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
I mentioned a while back that I was creating a framework. I took a break to read most of the Apple ObjC document, but now I'm back because I wanted to solve a different problem I'm having, one involving my test application. My framework currently just has a method that starts a timer and calls the method that the user specifies (hopefully) the problem is I can't test it because as soon as I add the line "ESAnimation *animate;" to my program and build/run it says test has exited with status 5. I've been adding and rebuilding/running incrementally, this is definitely the problem point. I have my framework imported, I have the class in it that I'm using imported, it should work as far as I can see, but that line is stopping it from running. Help please?
Nate
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
Code:
#import <Cocoa/Cocoa.h>
#import <ESFramework/ESFramework.h>

@interface AppController : NSObject {
    IBOutlet id field;
    ESAnimation *animate;
}
- (IBAction)button:(id)sender;
- (void)draw;
@end
The implementation just has the two methods, nothing in them.
Now when I take out the problematic line it still doesn't work. I also noticed that it definitely runs the program for a split instant. Right before it says the status 5 message it says program run. I haven't actually used the pointer yet, because I was adding one little thing at a time to find the problem, and this is as far as I got.
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
<_< but that's the line that first started it quitting. I wish I knew how to use the debugger, but all I know how to do is set a breakpoint. I don't even know what to do with the said breakpoint. That being said, I got something when I fooled around with it earlier. I set a breakpoint at that line. I opened the debugger and did build/go. It stopped at that line, I pressed continue. Then, in the following line, I got an error in the bottom bar of the debugger. It says "GDB: Program received signal: "EXC_BAD_ACCESS"."
Here's the line.
0x8fe010c8 <+0120> cmpl $0x1,(%edx) [line 38 in debugger]

While we're on the topic of the debugger, I think I'll go figure out how to use it now...

edit: Oh yeah, and after that line pressing continue doesn't work.
 

darkwing

macrumors 65816
Jan 6, 2004
1,210
0
EXC_BAD_ACCESS means you are trying to access memory that has not been allocated to your application. It's another fancy term for segmentation fault (segfault.)

There are one of two things happening. You are trying to use the pointer without initializing it. However, my suspicion is that since the code given to you where it crashes was assembler (and you aren't building in "deployment" mode right?) it's something internal. I know that in C++ if you add variables to a class you need to rebuild everything that knows about that class otherwise crashes occur. Try making clean and seeing if it works after rebuilding it from that point.

Also try being sure you never use the pointer and just have it declared in your class and see if it still crashes.
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
I've never heard of a segfault but I understand what it is from what you said...

I am in debug mode.

I had tried a clean rebuild earlier... I'm not quite sure what it does but I tried it. I just did it again, no new results. I am not using the pointer at all yet. All I did was declare it.

A pointer shouldn't even need initializing or allocating until I want to use it... I've had empty pointers before without this problem.

edit: I opened the debugger console and this is what it says.
Code:
[Session started at 2008-08-28 11:33:52 -0400.]
dyld: Library not loaded: /Users/nate/Library/Frameworks/ESFramework.framework/Versions/A/ESFramework
  Referenced from: /Users/nate/Desktop/Files/Software development/C/test ESFramework/build/Debug/test ESFramework.app/Contents/MacOS/test ESFramework
  Reason: image not found

The Debugger has exited due to signal 5 (SIGTRAP).The Debugger has exited due to signal 5 (SIGTRAP).
So it's actually a problem with my framework not loading... I'm sure I did it right. It's not in a public place but I told my test program where it is, I built the framework properly, in my test project the header files show up, and the color coding is working correctly for my pointer though someone said that doesn't mean much.
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
I really don't know any details on making a framework. I started a framework project, and through trial and error figured out a few things. I've searched online and I can't figure out any plain tutorial on how to create and use a custom framework. Nothing. So if there's something special to do, I don't know how.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I'm stuck on an iPhone right now so can't copy and paste but I'd suggest the first Google search for Cocoa Framework Tutorial looks good. Assuming you are embedding your framework, not installing it alongside the system ones you need to alter the setting I mentioned above. I'm pretty sure Apple cover this in their framework documentation too.
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
unfortunately that tutorial is really old... some of the stuff wasn't there any more. I found things that looked right and changed what he said to change and it got me as far as I am, but obviously something didn't go right. I'll find the apple documentation eventually... I couldn't find it last time though. Me and google just don't seem to get along <_<
So embedding pretty much makes it a part of an application... I'm not sure that's what I want. When this framework is done I want to share it. I'll have it up on my website. Can I just embed it for now for testing purposes, then share it later just fine?
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Change the build settings for the framework to look like these, especially the Other Linker Flags specifically the -seg1addr flag.
 

Attachments

  • Picture 5.png
    Picture 5.png
    115.7 KB · Views: 828

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You can see the all important @executable_parh there too that will solve your problem: it's that setting that tells the system to load it from inside the app not the system frameworks location.
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
ok mine now looks the same, but what did it do? It didn't solve my problem, I just rebuilt and all that. Please don't just tell me how, tell me why. I found Apple's doc, but it wasn't very helpful.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Without access to the entire thing I don't know what to suggest. The whole framework thing is a little fragile. The @executable_path setting there makes this work by emedding the framework on the app in the correct frameworks folder. Anywhere else and it won't work.

If you posted the entire project someone might be able to help more. Unfortunately my development Mac is down till Saturday afternoon so it can't be me...
 

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
I'll let it rest for now while I worry about other more basic things, such as does every class need to have an init method, and what should that method have? Every time I find something on init methods it just does something like
Code:
- (void)init {
   [super init];
   //initialize object here
   return self;
}
So it's not really helpful...
What I'm doing now is just putting the class into the project, so I can test and learn and implement other things.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
That's basic OO programming: if your class does not override init then the implementation in the superclass will get called. So if all your init does is call init in the superclass then you don't need it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.