创建包含 RestKit 库的静态库 [英] Create static library containing RestKit library

查看:51
本文介绍了创建包含 RestKit 库的静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 RestKit 库时遇到了另一个问题.

I have another problem in my use of RestKit Library.

我的目标是为我的公司创建一个特定的库,可用于所有 IOS 开发项目.

My goal is to create a specific library for my company, which can be used for all IOS development projects.

为此,我创建了一个库,在其中导入了库 RestKIt.我遵循了 RestKit xCode 4.x 的安装指南.

For this I created a library in which I imported the library RestKIt. I followed the installation guide for RestKit xCode 4.x.

于是我创建了一个新项目,在其中导入了名为m2mBackEnd"的库.

So I then created a new project in which I imported my library named "m2mBackEnd".

在使用该库的测试项目中,我对 Oppers 执行了以下操作:

In my test project that uses the library, I did Oppers the following:

1 - 我导入了库m2mBackEnd".

1 - I imported the library "m2mBackEnd".

2 - 在构建设置/其他链接器标志"中,我添加了-ObjC".

2 - In "Build Settings / Other Linker Flags" I added "-ObjC".

3 - 在构建设置/用户标题搜索路径"中,我添加了包含所有 '.h'.

3 - In "Build Settings / User Header Search Paths" I added the folder that contains all '. h'.

4 - 在构建阶段/目标依赖项"中,我将依赖项添加到m2mBackEnd"

4 - In "Build Phases / Target Dependencies" I added the dependency to "m2mBackEnd"

5 - 在构建阶段/使用库链接二进制文件"中,我添加了libm2mBackEnd.a".

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?

是否可以使用 RestKit 创建一个库?

Is it possible to create a library using RestKit?

感谢您的帮助.

推荐答案

我希望你此时已经解决了问题,如果没有尝试以下安装步骤

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

  1. 添加子模块:git submodule add git://github.com/RestKit/RestKit.git RestKit
  2. 在 Xcode 中打开要添加 RestKit 的项目.
  3. 关注您的项目并选择查看"菜单 >导航器">项目"以查看项目文件列表.
  4. 将 RestKit.xcodeproj 文件从 Finder 中拖放到.xcodeproj"上.
  5. 点击左侧边栏中的项目名称,在窗口的右侧窗格中打开项目设置视图.
  6. 在中间窗格中,您将看到项目的 PROJECTTARGETS 标题.点击您的项目名称,然后选择顶部的构建设置以打开整个项目的构建设置编辑器.
  7. 找到标题搜索路径设置.双击并添加一个新条目.将搜索路径添加到您已添加到项目中的 "$(SOURCE_ROOT)/RestKit/Build" 目录.请勿选中递归复选框.
  8. 找到图书馆搜索路径设置.双击并添加一个新条目.将搜索路径添加到您已添加到项目中的 "$(SOURCE_ROOT)/RestKit/Build/$(BUILD_STYLE)-$(PLATFORM_NAME)" 目录.
    注意:仅当您使用 DerivedData 时才需要这样做.
  9. 找到其他链接器标志条目并双击它.使用 + 按钮添加新条目并输入 -ObjC -all_load.使用完成按钮关闭编辑器.
  10. 在编辑器窗格中间的 TARGETS 列表中找到您想要添加 RestKit 的目标.选择它以在窗口的右窗格中打开目标设置编辑器.
  11. 点击窗口顶部的构建阶段标签打开构建阶段编辑器.
  12. 点击目标依赖项将二进制文件与库链接项旁边的显示三角形.
  13. 目标依赖项部分,点击+按钮打开目标选择表.单击 RestKit 聚合目标(它会有靶心图标),然后单击添加按钮以创建依赖项.
  14. 将二进制文件与库链接部分,点击+按钮打开库选择表.在这里,我们需要指示目标链接到所有必需的 RestKit 库和几个系统库.选择以下每个项目(一次一个或按住 Command 键一次选择所有项目),然后点击添加按钮:
    • libRestKitCoreData.a - 可选.仅当您使用 Core Data 时才需要.
    • libRestKitJSONParserJSONKit.a
    • libRestKitNetwork.a
    • libRestKitObjectMapping.a
    • libRestKitSupport.a
    • CFNetwork.framework
    • CoreData.framework - 可选.仅当您使用 Core Data 时才需要
    • MobileCoreServices.framework
    • SystemConfiguration.framework
    • libxml2.dylib - 可选.仅当您从 XML 负载映射并将 libRestKitXMLParserLibxml.a 链接到您的应用时才需要.
  1. Add the submodule: git submodule add git://github.com/RestKit/RestKit.git RestKit
  2. Open the project you wish to add RestKit to in Xcode.
  3. Focus your project and select the "View" menu > "Navigators" > "Project" to bring the project file list into view.
  4. Drag the RestKit.xcodeproj file from the Finder and drop it on your "".xcodeproj.
  5. Click on your project's name in the sidebar on the left to open the project settings view in the right pane of the window.
  6. In the middle pane you will see PROJECT and TARGETS headers for your project. Click on your project name, then select Build Settings along the top to open the Build Settings editor for your entire project.
  7. Find the Header Search Paths setting. Double click and add a new entry. Add a search path to the "$(SOURCE_ROOT)/RestKit/Build" directory you have added to your project. DO NOT check the Recursive checkbox.
  8. Find the Library Search Paths setting. Double click and add a new entry. Add a search path to the "$(SOURCE_ROOT)/RestKit/Build/$(BUILD_STYLE)-$(PLATFORM_NAME)" directory you have added to your project.
    NOTE: This is only necessary if you are NOT using DerivedData.
  9. Find the Other Linker Flags entry and double click it. Use the + button to add a new entry and enter -ObjC -all_load. Dismiss the editor with the Done button.
  10. Locate the target you wish to add RestKit to in the TARGETS list in the middle of the editor pane. Select it to open the target settings editor in the right pane of the window.
  11. Click the Build Phases tab along the top of the window to open the Build Phases editor.
  12. Click the disclosure triangles next to the Target Dependencies and Link Binary with Libraries items.
  13. In the Target Dependencies section, click the + button to open the Target selection sheet. Click on the RestKit aggregate target (it will have the bulls-eye icon) and click the Add button to create a dependency.
  14. In the Link Binary with Libraries section, click the + button to open the Library selection sheet. Here we need to instruct the target to link against all the required RestKit libraries and several system libraries. Select each of the following items (one at a time or while holding down the Command key to select all of them at once) and then click the Add button:
    • libRestKitCoreData.a - Optional. Only necessary if you are using Core Data.
    • libRestKitJSONParserJSONKit.a
    • libRestKitNetwork.a
    • libRestKitObjectMapping.a
    • libRestKitSupport.a
    • CFNetwork.framework
    • CoreData.framework - Optional. Only necessary if you are using Core Data
    • MobileCoreServices.framework
    • SystemConfiguration.framework
    • libxml2.dylib - Optional. Only necessary if you are mapping from XML payloads and link libRestKitXMLParserLibxml.a into your app.

恭喜,您现在已将 RestKit 添加到基于 Xcode 4 的项目中!

Congratulations, you are now done adding RestKit into your Xcode 4 based project!

您现在只需要在应用程序的适当位置为 RestKit 库添加包含.相关的包括:

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>

这篇关于创建包含 RestKit 库的静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆