"Apple Mach-O linker command failed with exit code 1" - iphone

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];
}

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:
Select YourProjectName
Select TARGETS
Select Build Phases
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:
Remove previous files (both .h and .m)
Click with right click in your project
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.

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.

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.

check if you have any objects that you could previously delete without knowing it
check if your all objects are connected , for example if you have a MapView but without a connection, it crashes down
if this doesn't work, try with cleaning the app, or just restarting your iPhone and Xcode

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.

Related

"_OBJC_CLASS_$_MDAudioPlayerTableViewCell" & linker command failed with exit code 1 (use -v to see invocation) [duplicate]

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];
}
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:
Select YourProjectName
Select TARGETS
Select Build Phases
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:
Remove previous files (both .h and .m)
Click with right click in your project
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.
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.
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.
check if you have any objects that you could previously delete without knowing it
check if your all objects are connected , for example if you have a MapView but without a connection, it crashes down
if this doesn't work, try with cleaning the app, or just restarting your iPhone and Xcode
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.

DejalActivityView and indicator view errors

I am trying to integrate dejalactivityview indicator view in my application, and I am running into this error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_DejalActivityView", referenced from:
objc-class-ref in WelcomeMessage.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This library is pretty easy to integrate and I am pretty sure I did everything correctly: added the .m and .h files, my project is ARC enabled and thats how I call the method:
[DejalActivityView activityViewForView:self.view];
Pretty simple, no? Still doesn't work...thanks for the help!
UPDATE:
I tried this:
DejalActivityView *testvc;
[testvc activityViewForView:self.view];
But I am getting an error (before compiling) that "no visible #interface for "DejalActivityView" declares selector 'activityViewForView:self.view'"
OK, I got the same thing just now. It seems if you simply drag the .m and .h files into your project, the .m file won't be added as source to link to your project, hence the link errors. What solved this for me was adding the DejalActivityView.m source file into the "Compile Sources" section under "Build Phases" of the project target. In other words, go to the Project Navigator and click on the uppermost item, then select the "Build Phases" tab, and then add the .m file to the "Compile Sources" section. Build and run your project again, and this time it should not have the linker errors!
what's your class name? make sure u spell correctly if again not work then change the class name. cz it some times that your class name matches with some built in name or some method name in project already in use
Check if you have actually copied the .m and .h files or you are just referencing them. Compiler might not be able to compile these files if you have not copied them to your project folder.
check this for
"no visible #interface for "DejalActivityView" declares selector 'activityViewForView:self.view'"
reply:- No need for a property for the DejalActivityView
please import this file in your viewcontroller .m
#import "DejalActivityView.h"
and write this code in viewdidload and check
[DejalActivityView activityViewForView:self.view];
if you have any error after that implement the download this from this link and implement , i use and work my code

Undefined symbols for architecture armv6, Updating to iOS 4.3

I am patching upp an application from iOS 4.2 to 4.3 using new xcode4.
With no changes made, except setting iOS to 4.3, I created entitlements and go!
Message I get is:
Undefined symbols for architecture armv6:"function", referenced from:
Ive tried to Clean the project, reinstalling xcode.
I uninstalled also the xcode4 demo version.
I also tried to set to Optimized armv7.
I would be very happy for some help, I'm stuck. Really.
Thanks very much in advance!
Here's how I got this problem:
I added a .h, .m and NIB from another project by dragging them onto my project navigator. Xcode didn't add them to the Build Phases properly.
My solution for this problem:
Click on the Project icon
Go to the Target in the navigator menu
Click on the "Build Phases" tab
Add the .m file to "Compile Sources" (either drag it across, or use the + button)
Add the .xib or Storyboard file to "Copy bundle resources"
Clean and build
For this type of error, this is what I typically see:
Undefined symbols for architecture armv6:
"_OBJC_CLASS_$_MyCustomController", referenced from:
objc-class-ref in SomeOtherController.o
ld: symbol(s) not found for architecture armv6
Almost every time I see this error it is caused by hidden/invisible characters in the import statement in SomeOtherController.h or SomeOtherController.m. So, look at both your .h and .m file, find the line that looks like this:
#import "MyCustomController.h"
Delete this line and retype it (do not copy/paste it -- you'll just repaste the offending hidden character).
Click on your Project name in the navigation window, choose the target you're building against, go to build phases, make sure the one Xcode's telling you that's missing is in there.
I had the same problem in Xcode5 for iOS7 with the TestFlight SDK. My issue was that the 'Build Active Architecture Only' was set to Debug only.
You can find the setting under 'YourProject'->'Build Settings'->'Architectures' Set the 'Release' option to 'Yes'.
This solved my problem - I hope it helps you, too! :)
I had this problem and I have just solved it.
It was a simple typo in the function name (forgot one letter) that caused the problem in my case.
I had the same problem in Xcode5 for iOS7 with the TestFlight SDK. My issue was that the 'Build Active Architecture Only' was set to Debug only.
You can find the setting under 'YourProject'->'Build Settings'->'Architectures' Set the 'Debug ' option to 'architecure arm7 arms7s'.
This solved my problem - I hope it helps you, too! :)
I had a similar issue popping-up all suddenly - more specifically, I was getting Undefined symbols for architecture armv6: "_OBJC_CLASS_$_CLLocationManager", referenced from: objc-class-ref in MyCLController.o
Note that I had CoreLocation.framework listed in my frameworks (in xcode' Project left nav, under the Frameworks folder); and had previously geolocation working just fine.
I got rid of the issue by re-installing CoreLocation.framework.
If you're not sure how to do that in xcode:
* click on your project in xcode left nav bar
* Go in the General tab of your project settings
* Navigate down - you'll see the list of frameworks installed under Linked Frameworks and Libraries
* Click on the + icon to add the CoreLocation.framework
In my case, I was doing this in a viewcontroller.m
#import <MediaPlayer/MediaPlayer.h>
Without doing Link Binary With Libraries with MediaPlayer.framework. After adding it, it compiled fine

iOS Development: Why can't my linker see my class?

I just added a class to my Xcode project and the linker is giving me this error...
_OBJC_CLASS_$_MyCustomViewController", referenced from:
objc-class-ref-to-MyCustomViewController in MainMenuViewController.o
In MainMenuViewController.h, I have #import "MyCustomViewController.h"
and I have both MyCustomViewController.h and .m files in the project. What are some reasons my linker would have trouble seeing the class?
Thanks so much for you wisdom!
Ensure that your .m files are being included in the chosen target. To do this:
Right-click on "Groups & Files" (above your file list on the left) and click "Target Membership". Checkboxes should appear to the left of many of your files, particularly your .m files. Make sure that MyCustomViewController.m has its checkbox checked, and then rebuild.

Xcode duplicate symbol _main

I'm getting the following error in Xcode 3.2.1 on Snow Leopard 10.6.2 whenever I try to compile any iPhone application generated by Appcelerator Titanium. However, the build error only appears when I select iPhone simulator on the architecture menu and if I select the iPhone device, I am able to run the app on my device .
Further more, the iPhone simulator launches successfully and executes the program directly from the Titanium environment which uses Xcode to build .
Why is this happening ?
ld: duplicate symbol _main in Resources/libTitanium.a(main.o) and /Users/prithviraj/Documents/project/Final/build/iphone/build/Final.build/Debug-iphonesimulator/Final.build/Objects-normal/i386/main.o
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
I can't tell you why this is happening, but I can suggest a workaround. When I commented out the entire contents of the main.m file that was generated for my Titanium project, I was able to compile successfully and run on the Simulator. Let me know if that works for you.
Check to see if you have multiple declarations of main function in your project.
I just spent a couple hours battling this one. It was because I was using the -all_load linker flag. If you are using that flag to get around the category bug, there are some other solutions -- see here.
I had a similar problem. A unit test class was accidentally included in my build. If you search your project for "main(" you'll probably find the duplicate functions.
This happened to me for 2 reasons:
1: Class A calls class B and both had imported the same class. Fix it by importing the class in .m file.
2: Two classes have a constant with the same name (even if the constant is defined in the .m file). Fix it by changing the name of the constants.
I had this problem because I define a file as such:
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
}
And also had a file main.m:
int main(int argc, char* argv[])
{
#autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
return retVal;
}
}
Seems as though there are multiple ways to get into this state. Mine was different. I read a hint where you could drag from a .xib event selector into the .h implementation of your view controller and it would auto-gen your methods. It did - which was cool. I immediately started getting duplicate symbol errors - which was not cool.
I did not have time to dig deep into the linker to see what happened. I created a new view controller, copied the context of my old .xib into the new guy. Deleted the old .h, .m and .xib and built and it worked again. Very odd, very annoying time waste.
There is obviously some bug with this xcode "convenience".
I found this happened when i had an implementation file with a main function in it (say abc.m) and also had another main.m. Once I commented out the main function in abc.m, the project compiled successfully.
Based off what I can tell from these other answers, I'm going to need to be remove a bunch of main methods.
But to do that easily I first need to remove all the gd comments from my files because they are assiduously documented with comments at nearly every other line
This regular expression matches all C multi-line comments including their delimeters & may help you on your journey
/\*((?!\*/).)*\*/
I spent more than an hour in searching for a correct answer but nothing worked for me.
Finally the xcode it self telling something is duplicated, so go to that particular folder(in this case: /Users/prithviraj/Documents/project/Final/build/iphone/build/Final.build/Debug-iphonesimulator/Final.build/Objects-normal/i386/main.o) and delete all the files and also check same in your project whether that particular class/interface is declared twice if yes delete it.
After deletion clean and run the project.
It worked for me hope this helps(-_-).
Delete /Users/{username}/Library/Developer/Xcode/DerivedData folder and build again.