9

I am trying to implement the SVProgressHUD activity indicator. I copied the classes to my project and added the following code to my appDelegate but can't figure out why it crashes.

I get they following error and am not sure where to look to fix it:

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SVProgressHUD", referenced from:
objc-class-ref in QuotesAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

Here is the code:

#import "SVProgressHUD.h"

@implementation QuotesAppDelegate


- (void)startLoading
{
    //call this in your app delegate instead of setting window.rootViewController to your main view controller
    //you can show a UIActivityIndiocatorView here or something if you like
    [SVProgressHUD show];
    [self performSelectorInBackground:@selector(loadInBackground) withObject:nil];
}

- (void)loadInBackground
{
    //do your loading here
    //this is in the background, so don't try to access any UI elements
    [self populateFromDatabase];

    [SVProgressHUD dismiss];

    [self performSelectorOnMainThread:@selector(finishedLoading) withObject:nil waitUntilDone:NO];
}

- (void)finishedLoading
{
    //back on the main thread now, it's safe to show your view controller
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}


- (void)applicationDidFinishLaunching:(UIApplication *)application {

[self copyDatabaseIfNeeded];

    [self startLoading];

}
jroyce
  • 2,029
  • 2
  • 22
  • 45

5 Answers5

16

Edit

The answer I provided (see My original answer) only fixes the problem, but it's not the correct solution. For correct solutions see Jim answer

It sounds like SVProgressHUD.m isn't enabled for your target. Click on it in the project navigator in the left-hand pane, then look in the file inspector in the right-hand pane to make sure there's a tick next to the target you are building.

or Parth Bhatt link.

For the sake of completeness

Experimenting a little bit, I found that when you drag and drop file or directory within your project, Xcode (4.3.1) asks you to select the right option to add those files or dir to your project. Make sure that that "Add to targets" option is checked.

If you have missed to check that option, you need to following these steps:

  1. Select YourProjectName
  2. Select TARGETS
  3. Select Build Phases
  4. Add .m classes in Compile Sources section

My original answer

If you dragged those classes in your project, it could be the problem.

To avoid that compiling error, use "Add Files to YourProjectName" instead.

Suppose you have a directory that contains .h and .m files called "SVProgressHUD" in your desktop.

Now you have to:

  1. Remove previous files (both .h and .m)
  2. Click with right click in your project
  3. Select "SVProgressHUD" dir with "Add Files to YourProjectName" (select the following check box options: Destination Copy items... and Folders Create groups for any...)

Hope it helps.

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
  • Thank you and that was it. I dragged the files from the sample project and when I deleted and then added them through Xcode it worked like a charm. – jroyce Mar 21 '12 at 17:39
  • 1
    Dragging classes into your project and adding the files via the menu are the same thing. The options you describe don't fix this problem. It's likely you mistakenly left a target unticked without noticing the first time you tried, and corrected it the second time. The procedure you describe is a red herring. You should understand then fix the problem, not simply remove and re-add files until you get it right. – Jim Mar 21 '12 at 17:40
  • @Jim You are perfectly right. But since I used this workaround this morning, I posted a solution that worked for me. Yes, it's only a workaround and I was unaware of the correct solution. Thank you for your explanation. – Lorenzo B Mar 21 '12 at 17:52
  • It's not a workaround. It only fixes the problem if you enable the target the second time around, which is something you don't mention. It fixed the problem accidentally. Somebody could follow your instructions ten times over and it won't fix the problem unless they tick the target. Also, most of what you say is simply incorrect and the options you describe could lead to unwanted behaviour. This is cargo culting and misleading people into thinking things that aren't true. – Jim Mar 21 '12 at 17:59
  • @Jim For the sake of completeness I added an edit to my question. – Lorenzo B Mar 21 '12 at 20:20
  • @Jim I extended my question to make it more complete. Thank you for your explanation. Regards. – Lorenzo B Mar 27 '12 at 08:06
  • Very helpful thank you, was something I wouldn't have thought of. – lbrendanl Sep 02 '12 at 18:06
  • @flexaddicted: Dint realize such minute things matter. Thanks a lot for the solution :) – Aster Veigas Jan 22 '14 at 08:39
2

It sounds like SVProgressHUD.m isn't enabled for your target. Click on it in the project navigator in the left-hand pane, then look in the file inspector in the right-hand pane to make sure there's a tick next to the target you are building.

Jim
  • 72,985
  • 14
  • 101
  • 108
0
  1. check if you have any objects that you could previously delete without knowing it
  2. check if your all objects are connected , for example if you have a MapView but without a connection, it crashes down
  3. if this doesn't work, try with cleaning the app, or just restarting your iPhone and Xcode
DaveShaw
  • 52,123
  • 16
  • 112
  • 141
dsafa
  • 783
  • 2
  • 8
  • 29
0

Checkout this link. Refer to accepted answer in this link:

Undefined symbols for architecture i386: _OBJC_CLASS_$_SKPSMTPMessage", referenced from: error

If it still doesnt help then refer to Allen Pike's answer in the above link. try removing and adding back QuartzCore framework in your app.

Hope this helps you.

Community
  • 1
  • 1
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
-1

I resolved this issue by changing in Player Settings in the Unity Editor.

menu path: PlayerSettings > OtherSettings > Scripting Backend change to IL2CPP from Mono2x.

Second change was to change the Architecture to universal.

Peter Hornsby
  • 4,208
  • 1
  • 25
  • 44