iphone .objc_class_name error - iphone

I've been fighting this framework error for days now. I have included the MessageUI framework from the iphone3.0sdk and imported the header file(MessageUI/MessageUI.h)
Anyone know what this error means?
collect2: ld returned 1 exit status
symbol(s) not found
literal-pointer#_OBJC#__cls_refs#MFMailComposeViewController
".objc_class_name_MFMailComposeViewController", referenced from:
Here is some output from the build log:
ld warning: in /Users/me/iphone/myApp/MessageUI.framework/MessageUI, missing required architecture i386 in file
Undefined symbols:
".objc_class_name_MFMailComposeViewController", referenced from:
literal-pointer#__OBJC#__cls_refs#MFMailComposeViewController in myViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

You forgot to link to the MessageUI.framework or you're linking to the wrong version.
Here's the right way to add frameworks:
Double-click your target
Select the main tab
Add the framework by pressing the plus-button in the frameworks section
Now you should be able to build for the simulator and the device.
Edit:
The warning from ld looks like you copied the MessageUI.framework from the simulator SDK to your project directory. Delete it and ld should find the right one (the one in your current SDK).

You accidentally copied the iPhone SDK Framework into your project directory (on disk). Open your project directory (where you keep the project on disk) and delete the iPhone SDK Framework directory.
Rebuild.

Related

error on AdMob integration

I Have added Addmob sdk in my project and even added all framework needed. But m getting below error for StoreKit framework even i have added it in my project but still getting error..
ld: warning: directory not found for option '- L/Users/company/Downloads/projectname/GoogleAdMobAdsSdkiOS-6.4.2/Add- ons/GoogleAnalyticsiOS_2.0beta4/Library'
ld: warning: directory not found for option '-L/Users/company/Downloads/projectname/GoogleAdMobAdsSdkiOS-6.4.2'
ld: warning: ignoring file /Users/company/Downloads/StoreKit.framework/StoreKit, missing required architecture i386 in file /Users/company/Downloads/StoreKit.framework/StoreKit (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SKStoreProductViewController", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
"_SKStoreProductParameterITunesItemIdentifier", referenced from:
-[GADOpener openInAppStore:fallbackURLString:] in libGoogleAdMobAds.a(GADOpener.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I search a lot but in every post its sid to add Storkit.. but i have already added it but still getting error. even i have cleaned the project a lot of time.
Just ensure that you have added the following libraries,
1.AudioToolbox
2.MessageUI
3.SystemConfiguration
4.CoreGraphics
Also the frameworks,
1.MessageUI.framework
2.StoreKit.framework
3.SystemConfiguration.framework
According to your error message there is a problem with StoreKit.framework...Please verify that...
Refer: build error when add Admob in iOS app
Add AdSupport.framework, also make it as optional
It says that your StoreKit binary is not build for i386. This should not happen with the default one. Did you download if separately from somewhere? You can find the default here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer‌​/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/StoreKit.framework
Use that.

ignoring file [path] missing required architecture i386 in file

I'm quite new to Xcode and Iphone development and ran into the following problem:
I opened a new project and added *.h and a *.a files (which I recived from a certain device vendor).
I get the following warning:
ld: warning: ignoring file /Users/udi/Desktop/Xcode/Xcode Projects/Scosche/libmyTrekSDK_armv7.a, missing required architecture i386 in file /Users/udi/Desktop/Xcode/Xcode Projects/Scosche/libmyTrekSDK_armv7.a (2 slices)
If I ignore the warning, and try to instanciate the class that is given to me in the header file, I get these errors:
ld: warning: ignoring file [Path/FileName.a], missing required architecture i386 in file [Path/FileName.a] (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_HRMonitor", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
I've checked the Framework Search Pathes (as mantioned in many other posts) and it clear.
More info:
I'm Using Xcode 4.6.1
The files are currently located at project's root folder.
I'm using a Single View Application tamplate.
Appreciate any help
This warning means that you're trying to use library made for Device (ARM) with your Simulator (i386).
You can use this terminal command to create a universal library:
lipo -create lib_arm.a lib_i386.a -output lib_universal.a
More info about lipo command here.
Change your target's "Build Settings > Build Active Architectures Only" to "No"
This is doing the same thing as Dmitry Zhukov's answer but doing it thru Xcode instead of going around its back.
If you are working with a 3rd party code, keep in mind that some SDKs may not work on the simulator. The same build error I have encountered vanished, when I ran the project on the device.

Xcode 4.3.3 missing SenTestingKet.framework causes Undefined symbols "_OBJC_METACLASS_$_SenTestCase"

On my MAC mini osx-snow-leopard xcode4.1 my project can run SenTestingKit.framework tests. Got a MACBook Pro with osx-lion 10.7.4 with xcode4.3. For the same project I cannot run unit tests because SenTestingKit.framework is not to be found. I copy sentestingkit from the Mac mini to "/Applications/Xcode.app/Contents/Developer/Library/Frameworks". Add to each target Framework Search Paths:
$(inherited)
"$(DEVELOPER_LIBRARY_DIR)/Frameworks"
This resolves to "/Applications/Xcode.app/Contents/Developer/Library/Frameworks".
I can add sentestingkit to the project so it compiles. I can't run Product > Test because of this link error undefined-symbol:
Undefined symbols for architecture i386:
"_OBJC_METACLASS_$_SenTestCase", referenced from:
_OBJC_METACLASS_$_Field_MobileApplicationTests in Field_MobileApplicationTests.o
"_OBJC_CLASS_$_SenTestCase", referenced from:
_OBJC_CLASS_$_Field_MobileApplicationTests in Field_MobileApplicationTests.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
I had the same problem by using my class that want to be tested. I got this error:
Undefined symbols for architecture i386:
"_OBJC_METACLASS_$_JsonDictParser", referenced from:
_OBJC_METACLASS_$_MainData in MainData.o
_OBJC_METACLASS_$_JsonObjectClass in JsonObjectClass.o
"_OBJC_CLASS_$_JsonDictParser", referenced from:
_OBJC_CLASS_$_MainData in MainData.o
_OBJC_CLASS_$_JsonObjectClass in JsonObjectClass.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have created an object from my class that I want to test and forgot to tell the „Target Membership“. So I make sure I checked the test class.
E.g. I want to use JsonDictParser class for testing in my JsonTestLogicTest class. So I focus the JsonDictParser.m file, clicked the File Inspector at the right side on the main window, selected Target Membership and checked my class where my testcases are in JsonTestLogicTest.
Or open the .xcodeproject file in the Project Navigator, select the target with the test methods > Build Phases > Compile Sources and add the .m file which includes your classs that you want to test.

error using the code from Mailcomposer from apple sample

I using the code from Apple for MailComposer but when I try to run my app i get a error message and I can't build my app.
The message error I get:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
objc-class-ref in InfoMailComposerViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Know anybody what this means??
thanks in advance
You have to include the MessageUI.framework in your project.
If you are using Xcode 4:
Select the Project then highlight your active Target.
Select the "Build Phases" Tab
Expand "Link Binary With Libraries"
Hit the '+' button
Select MessageUI.framework
The above answer by MarkPowell works like a charm.
I first tried it on the CordovaLib.xcodeproj file.
It did not work, then I tried it at Testing.xcodeproj. Then the errors disappeared and worked magically.

MapKit not working on device but works in simulator

I have added the frameworks (MapKit and CoreLocation) by selecting the Frameworks folder, right clicking, Add > Existing Frameworks.
The app builds in the Simulator (3.1.3) but fails on the Device (3.1.3) with the error:
ld: warning: in
/Development/Sites/iPhone
Projects/SwitchViews/MapKit.framework/MapKit,
file is not of required architecture
Undefined symbols:
"_OBJC_CLASS_$_MKPinAnnotationView",
referenced from:
__objc_classrefs__DATA#0 in NextView.o ld: symbol(s) not found
collect2: ld returned 1 exit status
It seems that I just needed to restart Xcode to get things linked up properly.
It looks like you by accident have selected the "copy to project" checkbox when adding the framework.
Try to delete the framework from your project and add it again, making sure you have selected the default framework path, and that you don't copy it to your project.