使用同一个库的两个版本

使用同一个库的两个版本

问题描述:

我在iOS项目中工作,其中包含由另一家公司创建的静态库。
该库包含旧版AFNeworking,我没有任何源文件。

I'm working in a iOS project that includes a static library created by another company. The library include an old version of AFNeworking and I don't have any source files.

现在我需要使用更新的(并且更少的bug) afneworking的版本,但我不能在项目中包括同一个类两次(当然),因为所有的重复符号。

Now i need to use a more recent (and less bugged) version of afneworking, but i cannot include the same class twice in the project (of course) because all the "duplicate symbols".

我知道更换版本是不可能的包含在库中,但是如何在旧库中包含另一个版本?

I understand that it's impossible replacing the version included in the library, but how can i include another version along the old one?

在我的项目中包含之前,有一种(简单)方法可以重构整个框架吗?

There is a (easy) way to refactor the entire framework before include in my project?

谢谢

你必须重新打包静态库删除嵌入的AFNetworking文件。

You'll have to repackage the static library to remove the embedded AFNetworking files.

用以下内容解压缩库:

$ ar x libwhatever.a

并重新打包,包括除AFNetworking对象文件以外的所有文件:

And re-package it, including all files except the AFNetworking object files:

$ ar cr libwhatever.a file1.o ... fileN.o

然后,您必须将可执行文件与新的AFNetworking静态库链接,并希望没有API更改会破坏 libwhatever.a 。如果有,那么我怀疑你能做多少。

You will then have to link your executable with the new AFNetworking static library and hope that there haven't been API changes which will break the code in libwhatever.a. If there are then I doubt there is much you can do.