Use two versions of the same library
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.
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 - Download multiple files + monitoring via UIProgressView
- kCFStreamErrorDomainSSL, -9802 when connecting to a server by IP address through HTTPS in iOS 9
- List saved files in iOS documents directory in a UITableView?
- AFNetworking 3.0 AFHTTPSessionManager using NSOperation
- AFNetworking 2.0 multipart request body blank
- Caching on AFNetworking 2.0
3 Solutions Collect From Internet About “Use two versions of the same library”
You’ll have to repackage the static library to remove the embedded AFNetworking files.
Unpack the library with:
$ ar x libwhatever.a
And re-package it, including all files except the AFNetworking object files:
$ ar cr libwhatever.a file1.o ... fileN.o
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.
The best and most proper way of handling this would be to contact the the creator of the static library and get them to resolve the situation. They could resolve it either by updating the embedded version of AFNetworking, removing their dependence on AFNetworking, or adding a prefix for their embedded copy of AFNetworking. The last one is probably a good idea anyway when a third party library embeds a different library, because otherwise it would be impossible to use two libraries simultaneously that both include the same third party library.
You could also refactor the copy of AFNetworking that you include yourself to change the names of classes to have a prefix, although this should be unnecessary, as the static library vendor should have done this themselves already.
Lastly, you could find a different library that accomplishes the same thing as your current one but that doesn’t embed AFNetworking.
I’m afraid this isn’t easy to do. Very few environments allow you to link against two separate versions of the same framework at the same time, and Xcode / iOS is not one of them.
As I see it, you have three options:
1) Link against their library and use the same version of AFNetworking they use.
2) Link against their library, and manually load the newer version of AFNetworking and pull symbols from it. Be warned: this will get ugly fast and future maintainers will wonder what you were smoking.
3) Get them to update their library.
On a side note, I don’t know the circumstances here, but in general they should be providing you with sources. It’s a very backwards practice to provide only a static (static!) library and no way to know what it’s doing inside. You’ll have to sign a software license agreement and whatnot to protect their interests.
- How to programmatically resize an UIButton to the text size and keep a nice padding?
- How do I load and edit a bitmap file at the pixel level in Swift for iOS?
- Custom repeat interval for UILocalNotification
- Is it possible to run iOS simulator on a Mac without Xcode installed?
- how to have 2 different setting page with inappSettings
- Improve process of mirroring server database to a client database via JSON?
- Draw a Custom cell for tableview ( uitableview ) , with changed colors and separator color and width
- Understanding NSRunLoop
- Is there any way to know purchase made by which iTunes account? – iOS
- Log Messages I didn't asked for in Xcode 4.5 with iOS 6.0
- What is “Source Tree” in the Xcode preferences and what can I do with it?
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=armv7 armv7s)
- Parse/Parse.h file not found when Xcode Quits
- Core Data – how to generate CoreDataGeneratedAccessors?
- NSMutableArray Data Attachement With E-mail Body?