Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

handling dependencies for iOS Framework project

I've created iOS Framework project using this method: https://github.com/jverkoey/iOS-Framework

Works pretty neat but I'm a little confused on how to include libraries/frameworks that are needed by my framework to work and, in particular, how to do it so that in case 3rd party client app that uses my framework can include these libs as well without conflicts.

Let's say my framework code needs these two things:

  • FacebookSDK.framework
  • libFlurry.a

The first one is an iOS Framework. When I add it to "Link Binary With Libraries" phase in my Framework and try compile the client project that uses my framework the linker complains about missing symbols - I need to add FacebookSDK to the client project which is great: there is no possibility of conflicts if client apps wants to use Facebook.

However when I do the same with Flurry static library I get duplicate symbols error when compiling client project. Which confuses me a bit, because isn't FacebookSDK.framework just a packaged static library?

ukaszs-iMac:FacebookSDK.framework lukasz$ file Versions/A/FacebookSDK 
Versions/A/FacebookSDK: Mach-O universal binary with 3 architectures
Versions/A/FacebookSDK (for architecture i386): current ar archive random library
Versions/A/FacebookSDK (for architecture armv7):    current ar archive random library
Versions/A/FacebookSDK (for architecture cputype (12) cpusubtype (11)): current ar archive random library

So my questions are:

  1. why a library embedded in framework (like Facebook) is not linked to my Framework project product, whereas library included as .a file is?
  2. how to include .a file in my framework so that it does not produce duplicate symbols error when client app using my framework also needs this particular static library?
like image 302
Łukasz Sromek Avatar asked Apr 14 '14 09:04

Łukasz Sromek


People also ask

How do you manage dependencies in iOS applications?

Manual Dependency ManagementOpen the new Alamofire folder, and drag the Alamofire. xcodeproj into the Project Navigator of your application's Xcode project. Select the Alamofire. xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.

What is a dependency in Swift?

Dependency Injection is a software design pattern in which an object receives other instances that it depends on. It's a commonly used technique that allows reusing code, insert mocked data, and simplify testing.


1 Answers

For the use case you are describing, you should be linking to these external libraries from your application, NOT your own framework. It can be one or the other, but it can't be both.

If you decide that these dependancies belong as the responsibility of the application, you would remove them from "Link Binary With Libraries" and any other explicit linking configuration, and just project your framework project with the path to these frameworks and libraries so it can find the symbols (but not link against them) at compile time (i.e. the path to the libraries should be included LIBRARY_SEARCH_PATHS).

like image 168
quellish Avatar answered Oct 21 '22 09:10

quellish