Reputation: 1513
I have another problem in my use of RestKit Library.
My goal is to create a specific library for my company, which can be used for all IOS development projects.
For this I created a library in which I imported the library RestKIt. I followed the installation guide for RestKit xCode 4.x.
So I then created a new project in which I imported my library named "m2mBackEnd".
In my test project that uses the library, I did Oppers the following:
1 - I imported the library "m2mBackEnd".
2 - In "Build Settings / Other Linker Flags" I added "-ObjC".
3 - In "Build Settings / User Header Search Paths" I added the folder that contains all '. h'.
4 - In "Build Phases / Target Dependencies" I added the dependency to "m2mBackEnd"
5 - In "Build Phases / Link Binary With Libraries" I added "libm2mBackEnd.a".
But it does not work I encounter errors:
undefined symbols for architecture i386:
"_CFHTTPMessageCreateRequest", referenced from:
-[RKRequest addHeadersToRequest] in libm2mBackEnd.a(RKRequest.o)
"_CFHTTPMessageAddAuthentication", referenced from:
-[RKRequest addHeadersToRequest] in libm2mBackEnd.a(RKRequest.o)
"_CFHTTPMessageCopyHeaderFieldValue", referenced from:
-[RKRequest addHeadersToRequest] in libm2mBackEnd.a(RKRequest.o)
"_kCFHTTPAuthenticationSchemeBasic", referenced from:
-[RKRequest addHeadersToRequest] in libm2mBackEnd.a(RKRequest.o)
"_kCFHTTPVersion1_1", referenced from:
-[RKRequest addHeadersToRequest] in libm2mBackEnd.a(RKRequest.o)
"_SCNetworkReachabilityCreateWithAddress", referenced from:
-[RKReachabilityObserver initWithAddress:] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_SCNetworkReachabilityCreateWithName", referenced from:
-[RKReachabilityObserver initWithHost:] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_SCNetworkReachabilityGetFlags", referenced from:
-[RKReachabilityObserver getFlags] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_SCNetworkReachabilitySetCallback", referenced from:
-[RKReachabilityObserver scheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_SCError", referenced from:
-[RKReachabilityObserver scheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
-[RKReachabilityObserver unscheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_SCErrorString", referenced from:
-[RKReachabilityObserver scheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
-[RKReachabilityObserver unscheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_SCNetworkReachabilitySetDispatchQueue", referenced from:
-[RKReachabilityObserver scheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
-[RKReachabilityObserver unscheduleObserver] in libm2mBackEnd.a(RKReachabilityObserver.o)
"_UTTypeCreatePreferredIdentifierForTag", referenced from:
-[NSString(RestKit) MIMETypeForPathExtension] in libm2mBackEnd.a(NSString+RestKit.o)
"_UTTypeCopyPreferredTagWithClass", referenced from:
-[NSString(RestKit) MIMETypeForPathExtension] in libm2mBackEnd.a(NSString+RestKit.o)
"_kUTTagClassFilenameExtension", referenced from:
-[NSString(RestKit) MIMETypeForPathExtension] in libm2mBackEnd.a(NSString+RestKit.o)
"_kUTTagClassMIMEType", referenced from:
-[NSString(RestKit) MIMETypeForPathExtension] in libm2mBackEnd.a(NSString+RestKit.o)
"_xmlNodeGetContent", referenced from:
-[RKXMLParserLibXML parseNode:] in libm2mBackEnd.a(RKXMLParserLibXML.o)
"_xmlNewParserCtxt", referenced from:
-[RKXMLParserLibXML parseXML:] in libm2mBackEnd.a(RKXMLParserLibXML.o)
"_xmlParseMemory", referenced from:
-[RKXMLParserLibXML parseXML:] in libm2mBackEnd.a(RKXMLParserLibXML.o)
"_xmlFreeDoc", referenced from:
-[RKXMLParserLibXML parseXML:] in libm2mBackEnd.a(RKXMLParserLibXML.o)
"_xmlFreeParserCtxt", referenced from:
-[RKXMLParserLibXML parseXML:] in libm2mBackEnd.a(RKXMLParserLibXML.o)
"_xmlFree", referenced from:
-[RKXMLParserLibXML parseNode:] in libm2mBackEnd.a(RKXMLParserLibXML.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do I miss something? Or done something wrong?
Is it possible to create a library using RestKit?
Thank you for your help.
Upvotes: 0
Views: 3175
Reputation: 24962
The recommended approach for installing RestKit is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation. For best results, it is recommended that you install via CocoaPods >= 0.19.1 using Git >= 1.8.0 installed via Homebrew.
Install CocoaPods if not already available:
$ [sudo] gem install cocoapods
$ pod setup
Change to the directory of your Xcode project, and Create and Edit your Podfile and add RestKit:
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
platform :ios, '5.0'
# Or platform :osx, '10.7'
pod 'RestKit', '~> 0.20.0'
# Testing and Search are optional components
pod 'RestKit/Testing', '~> 0.20.0'
pod 'RestKit/Search', '~> 0.20.0'
Install into your project:
$ pod install
Open your project in Xcode from the .xcworkspace file (not the usual project file)
$ open MyProject.xcworkspace
Please note that if your installation fails, it may be because you are installing with a version of Git lower than CocoaPods is expecting. Please ensure that you are running Git >= 1.8.0 by executing git --version
. You can get a full picture of the installation details by executing pod install --verbose
.
Upvotes: 0
Reputation: 1273
Try Adding CFNetwork.framework to your project's target (resolved the first 6 errors for me)
Upvotes: 0
Reputation: 15296
I hope you would have resolved the issue by this time, If not try the below installation steps
Check whether you completed installation steps as mentioned in the read me file, and added all the frame work mentioned in it, as well as changes mentioned in the Build setting
git submodule add git://github.com/RestKit/RestKit.git RestKit
"$(SOURCE_ROOT)/RestKit/Build"
directory you have added to your project. DO NOT check the Recursive
checkbox."$(SOURCE_ROOT)/RestKit/Build/$(BUILD_STYLE)-$(PLATFORM_NAME)"
directory you have added to your project.-ObjC -all_load
. Dismiss the editor with the Done button.Congratulations, you are now done adding RestKit into your Xcode 4 based project!
You now only need to add includes for the RestKit libraries at the appropriate places in your application. The relevant includes are:
#import <RestKit/RestKit.h>
// And if you are using Core Data...
#import <RestKit/CoreData/CoreData.h>
Upvotes: 3