Using static library in both App and Cocoa Touch Framework targets
NickName:zath Ask DateTime:2015-04-13T06:49:27

Using static library in both App and Cocoa Touch Framework targets

I've created a new "Cocoa Touch Framework" target called MyAppCore in my iPad project called MyApp, with the intention of putting some common code in there. Overall it works great, however, I've encountered problems with adding the static library provided by Google Analytics.

I want to be able to use Google Analytics not only in the MyApp target, but inside of the MyAppCore target as well. In order to make both targets build, I have to link both targets with libGoogleAnalyticsServices.a. That appears to work, but when I run the app, the log is bombarded with messages like these:

Class GAI is implemented in both /path/to/MyAppCore.framework/MyAppCore 
and /path/to/MyApp.app/MyApp.
One of the two will be used. Which one is undefined.

How can I share Google Analytics between the two targets in a successful way?

Copyright Notice:Content Author:「zath」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29595558/using-static-library-in-both-app-and-cocoa-touch-framework-targets

Answers
zath 2015-04-13T10:32:51

I managed to solve this issue by creating a wrapper class for Google Analytics (which is pretty handy to have, anyways) in the MyAppCore target. All access to Google Analytics will go through this wrapper. That way the only target that will use Google Analytics directly is MyAppCore, so I only have to link that target with Google Analytics.\n\nThis does not solve the underlying issue of sharing static libraries between my app target and a Cocoa Touch Framework, but for this purpose it works just as well.",


More about “Using static library in both App and Cocoa Touch Framework targets” related questions

Using static library in both App and Cocoa Touch Framework targets

I've created a new "Cocoa Touch Framework" target called MyAppCore in my iPad project called MyApp, with the intention of putting some common code in there. Overall it works great, however, I've

Show Detail

Wrapping static library in Cocoa Touch Framework

I have a fat static library with 2 architecture slices (armv7, arm64). I'm trying to make it work with swift and wrap it into Cocoa Touch Framework. What I do: Create Cocoa Touch Framework proj...

Show Detail

iOS: When to choose a Cocoa Touch Static Library or Framework?

To begin: I read the other questions here, but they are stating that e.g. Swift cannot be used in a Framework or/and Library or are outdated (5 years old). What are the advantages and downsides of a

Show Detail

Cocoa Touch Framework vs Cocoa Touch Static library

Any comment on Cocoa Touch Framework vs Cocoa Touch Static library? Can you distribute a Framework like a static library without source code?

Show Detail

How to use MagicalRecord Library in cocoa touch framework?

we made a cocoa touch framework which saves and fetches data from a local database. We used core-data and MagicalRecord library for this. When we integrate our framework with some app and try to add

Show Detail

Fat binary validation - (Cocoa [Touch Framework] / [Static Library (converted to framework)]

. Hello, all. I noticed some strange thing. As all you know there are a lot of complaints regarding "unsupported architecture" error message during validation against App Store when using 3rd pa...

Show Detail

Cocoa Touch Static Library - Link with Standard Frameworks

I have created a cocoa touch static that uses standard apple frameworks like MediaPlayer.framework and CoreData.framework. When I link my main project against this static library it throws errors b...

Show Detail

Xcode Transformation static library(.a) to Framework(.Framework)

I have a Cocoa Touch Static Library project(compile as a .a file), i got a mission,create a Cocoa Touch Framework project, which has the same function as Static Library(same file, same resource) ...

Show Detail

Cocoa Touch Framework with third-party static libraries and frameworks

I'm developing a Cocoa Touch Framework which is used a couple of third-party static libraries and frameworks. For some of them I have a source code. For others I'm don't. The issue is when someone ...

Show Detail

Cocoa Touch Framework

I'm building a Cocoa Touch Framework. I started using the Xcode template and then I developed all the logic. I know that the framework must be universal to run on both simulator and device, so I us...

Show Detail