iPhone 的 Thrift 框架
我目前正试图让我的目标 c 生成的文件在我的 iPhone 项目中进行编译。基本上它一直告诉我以下四个导入没有这样的目录:
Thrift/TProtocol.h Thrift/TApplicationException.h Thrift/TProtocolUtil.h Thrift/TProcessor.h
我遵循 Thrift wiki 上的所有说明,并在 XCode 中下载并编译了 Thrift 框架,但没有特定于 iPhone 开发的信息。我几乎可以肯定这是 iPhone 项目特有的问题,因为如果我在 XCode 中创建一个新的命令行项目,我可以很好地导入这些文件。
I'm currently stuck trying to get my objective c generated files to compile in my iPhone project. Basically it keeps telling me there is no such directory for the following four imports:
Thrift/TProtocol.h
Thrift/TApplicationException.h
Thrift/TProtocolUtil.h
Thrift/TProcessor.h
I'm following all the instructions on the Thrift wiki and have downloaded and compiled the Thrift framework in XCode but there is no information specific to iPhone development. I'm almost certain it's a problem specific to an iPhone project because if I create a new command line project in XCode, I can import those files just fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在保留了某种巫师的服务后,我已经弄清楚如何让 Thrift 与 iPhone/iPad 一起工作(或者至少让它可以编译)。
首先,您想使用此命令而不是从 wiki 获取 Objective-C 文件:
然后,转到 New Project,选择 Framework & 来创建一个新的 Xcode 项目。库和 Cocoa 框架。单击“创建”并将其保存在合适的地方。右键单击目标并选择添加 ->新目标。选择 Cocoa Touch,然后选择静态库。给它起一个好听的名字。转到信息中目标的“构建”选项卡,将 Base SDK 更改为 iPhone 设备(我使用的是 3.2,但您可以使用任何版本),并将架构更改为“标准”(armv6 armv7) 或“优化”(armv7)。在 General 选项卡下添加 Foundation 和 Cocoa 框架。
将从 svn 存储库获取的所有文件和文件夹拖到项目中的 Classes 文件夹中。选中复制项目框并选中两个目标旁边的框。分别从静态库的 Copy Headers 和 Compile Sources 文件夹中删除 TSocketServer.h 和 .m。您现在可以构建静态库(以及可选的框架)。
打开您想要在其中使用 Thrift 的项目,然后转到目标的 info 中的 General 选项卡。将您刚刚创建的静态库添加到链接库列表中。它应该命名为 libYOUR_TARGET_NAME.a。在“构建”选项卡下,转到“标头搜索路径”并将路径添加到刚刚创建的 Thrift 项目,然后选中“递归”框。
最后,您只需要更改 Thrift 生成的代码中的导入语句,只需删除括号并将其替换为引号即可。您现在可以再次构建 iPhone 项目。
After retaining the services of some kind of sorcerer I have figured out how to get Thrift to work with the iPhone/iPad (or at least get it to compile okay).
First, you want to grab the objective-c files with this command instead of from the wiki:
Then, make a new Xcode project by going to New Project, selecting Framework & Library and Cocoa Framework. Click create and save it somewhere nice. Right click on Targets and select Add -> New Target. Choose Cocoa Touch and then Static Library. Give it a nice name. Go to the target's Build tab in info and change the Base SDK to iPhone Device (I'm using 3.2 but you can use whatever) and change Architectures to either Standard (armv6 armv7) or Optimized (armv7). Under the General tab add the Foundation and Cocoa frameworks.
Drag all of the files and folders you got from the svn repository into the Classes folder in the project. Check the copy items box and check the boxes next to both targets. Remove TSocketServer.h and .m from the Static Library's Copy Headers and Compile Sources folders respectively. You can now build the Static Library (and Framework optionally).
Open the project you want to use Thrift in and go to your target's General tab in info. Add the Static Library you just created to the Linked Libraries list. It should be named libYOUR_TARGET_NAME.a. Under the build tab go to Header Search Paths and add the path to the Thrift project you just created and check the recursive box.
Finally you just need to change the import statements in the Thrift generated code by simply removing the brackets and replacing them with quotes. You can now build you iPhone project again.
尝试将这些 .h 文件添加到您的 Xcode 项目中。
Try adding those .h files to your Xcode project.