xcode 适用于 iOS 项目的 XMLRPC-iOS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7362892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XMLRPC-iOS for iOS project
提问by Paul Peelen
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/xmlrpcand https://bitbucket.org/kdbdallas/xmlrpc-ios/wiki/HomeThe first one, the original one, doesn't have an iOS target. the second one shouldhave, but even that one doesn't seem to work.
我已经下载并尝试为 iOS 构建 XMLRPC。我尝试使用https://github.com/eczarny/xmlrpc和https://bitbucket.org/kdbdallas/xmlrpc-ios/wiki/Home第一个,原始的,没有 iOS 目标。第二个应该有,但即使是那个似乎也不起作用。
I build XMLRPC-iOS lib using XCode the following way:
我通过以下方式使用 XCode 构建 XMLRPC-iOS 库:
- download, unzip, open in xcode
- Go to menu Product > Archive
- In organized I choose "Share" on the latest build
- I save it in my own project folder. Include it in the project.
- 下载,解压,在xcode中打开
- 转到菜单产品 > 存档
- 在组织中,我在最新版本中选择“共享”
- 我将它保存在我自己的项目文件夹中。将其包含在项目中。
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)
ld: 警告: 忽略文件 /Users/paulp/Documents/ios/iPhone/ios-account/Account/external/XMLRPC/libXMLRPC_iOS.a, 文件是为归档而构建的,这不是被链接的架构 (i386) 未定义的架构符号i386:
“_OBJC_CLASS_$_XMLRPCRequest”,引用自:MyAPI.o 中的 objc-class-ref
“_OBJC_CLASS_$_XMLRPCConnectionManager”,引用自:MyAPI.o 中的 objc-class-ref ld:未找到架构 i386 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
How is that possible? The XMLRPC-iOS settings are set to:
这怎么可能?XMLRPC-iOS 设置设置为:
- SDKROOT = iphoneos5.0
- ARCHS = $(ARCHS_STANDARD_32_BIT) = armv7
- IPHONEOS_DEPLOYMENT_TARGET = 5.0
- VALID_ARCHS = armv6 armv7k armv7f armv7
- OTHER_CODE_SIGN_FLAGS = armv7k armv7f armv6 armv7
- GCC_VERSION = com.apple.compilers.llvmgcc42
- SDKROOT = iphoneos5.0
- ARCHS = $(ARCHS_STANDARD_32_BIT) = armv7
- IPHONEOS_DEPLOYMENT_TARGET = 5.0
- VALID_ARCHS = armv6 armv7k armv7f armv7
- OTHER_CODE_SIGN_FLAGS = armv7k armv7f armv6 armv7
- GCC_VERSION = com.apple.compilers.llvmgcc42
Can someone explain for me how I can build and use the XMLRPC-iOS library in my own application? Thanks!
有人可以为我解释如何在我自己的应用程序中构建和使用 XMLRPC-iOS 库吗?谢谢!
回答by mja
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:
- 创建新项目(称为 RpcTest)
- 从bitbucket下载分叉的项目,解压到我的RpcTest目录下,所以我的目录是这样的:
- 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-f28a13cc16aeunder User Header Search Paths(uncheck recursive) in your project's Build Settings; now build your project (cmd+B)
- go to Build Phasestab, expand Target Dependencies, add XMLRPC-IOSproject, expand Link Binary With Libraries, add libXMLRPC_iOS.a.
- 将 XMLRPC-iOS.xcodeproj 拖到我的 Xcode 项目中(在 Frameworks 组下,但这无关紧要)
- 现在,到构建设置。 在项目的构建设置中的用户标题搜索路径(取消选中递归)下添加kdbdallas-xmlrpc-ios-f28a13cc16ae;现在构建你的项目(cmd+B)
- 转到Build Phases选项卡,展开Target Dependencies,添加XMLRPC-IOS项目,展开 Link Binary With Libraries,添加libXMLRPC_iOS.a。
Now you should be able to include any xmlrpc header and use the lib.
现在您应该能够包含任何 xmlrpc 标头并使用 lib。
Hope that helps.
希望有帮助。
EDITDownload via Dropbox.be advised: incomplete implementation, just a demo that xmlrpc works! ;)
通过 Dropbox编辑下载。请注意:不完整的实现,只是一个 xmlrpc 工作的演示!;)
回答by yonel
I've used the first one you mention https://github.com/eczarny/xmlrpcwith success in an iPhone project.
Should be working. (was some time ago)
我已经在 iPhone 项目中成功使用了你提到的第一个https://github.com/eczarny/xmlrpc。
应该工作。(是前一段时间)
[EDIT]
Some more details :
I imported XMLRPCResponse and XMLRPCEventBasedParser (+ all related classes to get them working from the project).
[编辑]
一些更多细节:我导入了 XMLRPCResponse 和 XMLRPCEventBasedParser(+ 所有相关的类以使它们从项目中工作)。
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.
欢呼莱昂内尔。
回答by maheswaran
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.
我可以知道你设定的目标是什么吗?例如三个可用的目标,如果您使用的是 iOS,请选择 libXMLRPC 然后构建,然后从构建中选择 libXMLRPC.a 文件,然后将其链接到我们的项目。然后它会运行。