简体   繁体   English

SBJson在非ARC项目中

[英]SBJson in non-ARC project

I am trying to include SBJsonlibrary in my project that does not use ARC. 我试图在不使用ARC的项目中包含SBJsonlibrary。 Since I cannot include source files, I've followed the steps described: here . 由于我不能包含源文件,因此我按照所描述的步骤进行操作: 此处 However I end up with the same problems described in this SO question . 但是我最终遇到了这个SO问题中描述的相同问题。

When I add libsbjson-ios.a to my project, it is shown in red, which I assume means the library is missing. 当我将libsbjson-ios.a添加到我的项目时,它显示为红色,我认为这意味着库缺失。 在此输入图像描述

Although the compiling of the project goes fine, when I try to add #import "SBJson.h" I get "SBJson.h: no such file or directory" error. 虽然编译项目顺利,但当我尝试添加#import "SBJson.h"我得到"SBJson.h: no such file or directory"错误。

How do I solve this? 我该如何解决这个问题? My project is too large and I cannot change everyting to use ARC. 我的项目太大了,我不能改变每一个使用ARC。

you simply need to drag all the files into your project rather than importing the library. 您只需将所有文件拖入项目而不是导入库。 i suggest to see https://github.com/stig/json-framework/ and follow the read me file to install in your project. 我建议看https://github.com/stig/json-framework/并按照自述文件安装到您的项目中。

to use this in your projects 在你的项目中使用它

  1. download the zip file from above link. 从上面的链接下载zip文件。
  2. In the Finder, navigate into the src/main/objc folder. 在Finder中,导航到src / main / objc文件夹。
  3. Select all the files and drag-and-drop them into your Xcode project. 选择所有文件并将它们拖放到Xcode项目中。
  4. Tick the Copy items into destination group's folder option. 勾选将项目复制到目标组的文件夹选项。
  5. Use #import "SBJson.h" in your source files. 在源文件中使用#import“SBJson.h”。

As an aside, a project can use ARC for just some files, so you could have compiled SBJson's classes with ARC and the rest of the project without. 顺便说一下,一个项目可以只使用ARC作为一些文件,所以你可以用ARC编译SBJson的类,而不用编译项目的其余部分。

A better way would be to just use SBJson from CocoaPods if you need to support iOS4. 如果你需要支持iOS4,更好的方法是从CocoaPods中使用SBJson。 Or just switch to NSJSONSerialisation if you don't. 或者,如果不这样做,只需切换到NSJSONSerialisation。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM