Paul Peelen
Paul Peelen

Reputation: 10329

XMLRPC-iOS for iOS project

I am gettings insane, I can't figure it out.

I have downloaded and tries to build XMLRPC for iOS. I triend with https://github.com/eczarny/xmlrpc and https://bitbucket.org/kdbdallas/xmlrpc-ios/wiki/Home The first one, the original one, doesn't have an iOS target. the second one should have, but even that one doesn't seem to work.

I build XMLRPC-iOS lib using XCode the following way:

When I build my own project I get:

ld: warning: ignoring file /Users/paulp/Documents/ios/iPhone/ios-account/Account/external/XMLRPC/libXMLRPC_iOS.a, file was built for archive which is not the architecture being linked (i386) Undefined symbols for architecture i386:
"_OBJC_CLASS_$_XMLRPCRequest", referenced from: objc-class-ref in MyAPI.o
"_OBJC_CLASS_$_XMLRPCConnectionManager", referenced from: objc-class-ref in MyAPI.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

How is that possible? The XMLRPC-iOS settings are set to:

Can someone explain for me how I can build and use the XMLRPC-iOS library in my own application? Thanks!

Upvotes: 6

Views: 6879

Answers (3)

mja
mja

Reputation: 5066

it worked for me; here is exactly what i did.

  • Create new project (called RpcTest)
  • Download the forked project from bitbucket, extracted the zip in my RpcTest directory, so my directory looks like this:

directory structure

  • Drag the XMLRPC-iOS.xcodeproj into my Xcode project (under Frameworks group, but this doesn't matter)
  • Now, to the build settings. Add kdbdallas-xmlrpc-ios-f28a13cc16ae under User Header Search Paths (uncheck recursive) in your project's Build Settings; now build your project (cmd+B)
  • go to Build Phases tab, expand Target Dependencies, add XMLRPC-IOS project, expand Link Binary With Libraries, add libXMLRPC_iOS.a. enter image description here

Now you should be able to include any xmlrpc header and use the lib.

Hope that helps.

EDIT Download via Dropbox. be advised: incomplete implementation, just a demo that xmlrpc works! ;)

Upvotes: 10

maheswaran
maheswaran

Reputation: 417

May i know what target you are setting ? for example three target available, if you using for iOS, please select libXMLRPC then build then select the libXMLRPC.a files from the build and then link it to our project. then it will run.

Upvotes: 0

yonel
yonel

Reputation: 7865

I've used the first one you mention https://github.com/eczarny/xmlrpc with success in an iPhone project.
Should be working. (was some time ago)

[EDIT]
Some more details : I imported XMLRPCResponse and XMLRPCEventBasedParser (+ all related classes to get them working from the project).

Then, here's the code to parse a response (I was doing the request by hand):

NSURL* url = [NSURL URLWithString:@"http://www.xxxxxxxxx.fr/xmlrpc.php"];
NSMutableURLRequest* urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
NSString* param = [NSString stringWithFormat: @"<param><value><double>%f</double></value></param><param><value><double>%f</double></value></param><param><value><double>%.0f</double></value></param><param><value><int>1</int></value></param>",
                   request.coordinate.latitude,
                   request.coordinate.longitude,
                   request.radius/1000.0];
NSString* xmlrpcReq = [NSString stringWithFormat:@"<?xml version=\"1.0\"?><methodCall><methodName>geoSearch</methodName><params>%@</params></methodCall>", param];
[urlRequest setHTTPBody:[xmlrpcReq dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse* response;
NSError* error;
NSData* content = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
XMLRPCResponse* rpcResponse = [[XMLRPCResponse alloc] initWithData:content];
if ([rpcResponse faultCode]==0) { 
     NSArray* result = (NSArray*)[rpcResponse object];

Cheers Lionel.

Upvotes: 0

Related Questions