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

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.

Related

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

How do I keep files not associated with the project in XCode 4 without generating a warning

I recently upgraded to XCode 4 and adjusting. I have a folder called "Unused" in which I keep some .h and .m files. They are basically code which are no longer associated with the project and I keep them because they serve as a reference. The compiler doesn't look what it sees in there so I change the .h and .m files to .h.txt and .m.txt. However, I get this warning:
warning: no rule to process file '$(PROJECT_DIR)/Classes/AddViewController.m.txt' of type text for architecture i386
Does anyone have any solution for this?
Thanks.
Select the target in XCode, then in the Build Phases tab, under Compile Sources, remove the unused files that you don't want. XCode will only compile the files listed.
If you don't want the files to link, you can select the relevant file on the left side project navigator, then go to your right side bar and select the File inspector (left most icon on top right bar), then scroll down to "Target Membership" and unclick the checkbox so the file is not associated with any of your targets.

Why should your constant implementation file be added to your frameworks target?

I was reading an old post on here: Constants in Objective-C which talks about how to set up a file for your constants when doing iPhone dev in objective C. One of the responses (which got a lot of helpful votes) says that "Constants.m should be added to your application/framework's target so that it is linked in to the final product."
My question is, how do you do this, and what is accomplished by this? Does this make it so you don't have to import the constants file in the files you need to use it for?
Also, does the same method talked about in the response apply to integer constants, etc?
Thanks.
It makes it so that the constant values are available in the linked binary. Your header file will be included by reference (since you #import it) but the compiler needs to know that you want that .m file to be part of the final binary.
In XCode 4, choose your project from the top of the Project Navigator (the file tree view tab on the left). Select your target from the list of targets that appears in a new column to the right of the Project Navigator. Select the Build Phases tab on the right. Open up the Compile Sources item. Here are all of the files that are being compiled to build your binary. Make sure your constants file is in here. If it is not, find it in the Project Navigator and drag it into the Compile Sources pane.
In Xcode 4, beside the method Seamus mentioned, you can also select that .h file, open right view (at the top-right conner, there're three), in the first tab there's target membership, select the target you want to add it to and you're set.
You have to make sure you #import and also the file has to be in build target. #import make sure your complier know where to look for, include the file in target make sure when complier go and look, there's that file (The file won't be include in your build if it's not part your building target even it's in your project).

XCode cannot find foundation.h or UIKit.h after MediaPlayer.framework is added

As soon as I add the MediaPlayer.framework into a new program, XCode absolutely shits its pants. Under supporting Files, PROJECTNAME-Prefix.phc starts red-flagging both #import and #import
Why is it doing this? I have tried to create a new project and re-adding the Framework, but even if that is all I have done, it gives 4 errors on the first failed build.
if you are using xcode4 don't slide the framework in the project: it edit the framework search path and do the error you describe.
Try deleting the framework search path in project "build setting" and for adding the framework use "target" "build phase" "link binary with library".
hope it help and sorry for my poor english.

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