Cocoapods and Google Analytics transitive dependencies - ios

I'm trying to create a private pod which uses Google Analytics. I include GA trough CocoaPods with pod 'GoogleAnalytics' but it keeps on failing with the transitive dependencies error.
I know there are already a lot of questions regarding this subject, but none of the solutions offered worked out for me.
Looked at Google's analytics site, but that didn't work out. I've seen this closed GitHub issue and scanned this dicussion.
Briefly looked at this small paragraph, which also clearly passes down the transitive annoyance to GA. At the bottom of the paragraph they say:
This eliminates the transitive dependency from the App -> Segment-GoogleAnalytics -> GA to App -> GA.
And of course, checked SO as well.
A little background info:
I use Cocoapods version 1.0.0
My podfile has use_frameworks! (I need that because I use Swift)
I include the GA pod with pod GoogleAnalytics
I also tried it with Google/Analytics and Google/Analytics ~> 1.3
Also tried adding pod Google before the GA pod
and not that it matters, but:
My Xcode version is 7.3.1
Some solutions say that I need a Cocoapods version after 0.36, and that the use of use_frameworks! should fix it. But as far as I know, and see in the generated Pods project, the GA pod still has a static lib (libGoogleAnalytics.a) and no framework.
This discussion has a lot of opinions and solutions, but as I already said, none work for me. Moreover, at the bottom someone said that this is a Cocoapods issue rather then something Google should fix (something with Cocoapods not taking use_frameworks! into account). But I beg to differ, especially since all other pods give me a framework as they should.
I had the error before when using OpenSSL, but fixed that by adding a compiled OpenSSL framework manually to my pod.
So I'm at a loss now. As for how I can fix this...got no clue whatsoever.
Edit
For now I've sort of circumvented the problem by using Carthage with the framework generated here.

Related

FBLPromise crash with CocoaPods and SwiftPM implemented in both

We've been migrating away from CocoaPods since a while, but not every dependency has made the switch. Like Firebase.
I've had a similar question regarding duplicate symbols, but now I'm facing something new, which is probably because I'm using a dependency in both SwiftPM as in CocoaPods.
After running my (sample) project it crashes:
-[FBLPromise firebaseInstallationID]: unrecognized selector sent to instance 0x600003f5a430
with a warning at the top:
objc[93047]: Class FBLPromise is implemented in both
/xxx/SampleProject.app/Frameworks/FBLPromises.framework/FBLPromises (0x10b3f09a8) and
/xxx/SampleProject.app/SampleProject (0x10af736f0).
One of the two will be used. Which one is undefined.
Prior to my update to Firebase SDK v6.26.0 I would only get the first warning, but since the update it crashes.
I saw a doc about how to use Firebase within libraries and a GitHub issue regarding a similar crash. But nothing seems to work to resolve this crash, other then downgrading.
I uploaded a sample project: https://github.com/basvankuijck/SampleProjectFirebaseCrash.
Removing the SwiftPM Promises dependency is not an option, since the actual project is using a SwiftPM dependency that has a dependency to Promises.
The Podfile is nothing that fancy, and the SampleProject just uses one single SwiftPM dependency.
Anyone who has an idea how to let SwiftPM and CocoaPods play nicely together especially with Firebase in the middle?
I faced the exact same problem with Firebase and FBLPromise. For me it arose because I added Firebase/FireStore in podfile but the rest of the FIrebase dependencies from SPM. Among my other SPM dependencies was FBLPromise as well.
To fix it I had to remove the FIrebase package from SPM and then add it again with FIrestore and other dependencies that I could need from Firebase.
No other solution worked for me.

How can I find a GitHub project from my podfile?

I have an iOS application.
I'm using CocoaPods.
I have a podfile with all my pods names.
I want to check changes made on one of the pods in GitHub, but I don't know how to get to my projects page.
How can I find the exact project from my podfile in GitHub?
For example -
One of the pods is GoogleAnalytics, searching "GoogleAnalytics" on GitHub will find multiple results with this exact name written by different developers.
How can I find the GoogleAnalytics from my podfile?
Writing the pod name on CocoaPods will get you to the specs but will not get you to the projects GitHub page.
See the source line in the podspec.
The GoogleAnalytics pod is a binary framework only and does not make its source available on GitHub.
Google analytics was just an example, but after #Paul Beusterien answer I understood that some companies sources may not be available on CocoaPods search, that made me search for the smaller independent developer pods, there I have found links to GitHub.
So the answer - if it helps anyone -
Search on CocoaPods for the links to GitHub, if you can't find it, it's probably big enough to find on google or on that dependency's website.

Private pod with static library in along with swift pod

I'm working on pods development for an iOS dev team (on private repo). My low-level C/Obj-C core pod contains a static library with some headers and is used as dependency in other pods (pushed with --use-libraries).
Now that the iOS team wants to integrate Swift pods, they had to add the use_framework! option in the Podfile of their projects. Of course, they obtained the following error during pod install :
The 'XXX' target has transitive dependencies that include static
binaries
I spent half a day on the web looking for a way to make my pods compatible with the use_framework! option, in vain. This is very frustrating, as Google Services pods are proofs that it's possible to bypass this problem in a clean way (not with the verify_no_static_framework_transitive_dependencies trick) : the main pod and almost all its dependencies contain static libraries, and everything works perfectly along with Swift pods. Exemple with Google/SignIn which depends on Google/Core (vendored_libraries: Libraries/libGGLCore.a) and GoogleSignIn (vendored_libraries: Libraries/libSignIn.a).
Any idea of what I can do to make my pods compatible with the use_framework! option ?
Thank you all,
Cheers,
Tom
I think I found a hack for my problem. This is quite weird, but I'd say it's clean enough to use it in production ;)
I found it here. The idea is simply to include a source file (even an empty one) in your source_files list inside your podspec.
Basically, the source section of my podspec looks like this :
s.source_files = "myLib/Empty.m", "myLib/Headers/*.h"
s.vendored_libraries = "myLib/myLib.a"
The only modification I made is to add "myLib/Empty.m" in the source files (Empty.m is strictly empty). Without it, I systematically have the transitive dependencies error when I pod install. With it, pod install works fine. It worked for me with both Cocoapods 0.0.39 and 1.0.0.beta.4.
Well, looks like it's a not so dirty solution, but I'm not sure it'll work in every case. And it's no good news about the cleanliness of Cocoapods...
As I mentionned in comments earlier, Google seems to have found a cleaner solution. So if anybody have an idea of the real clean solution, please share !
Cheers,
Tom
PS : I think I'll name the file DirtyCocoapodHack.m instead of Empty.m, sure they'll love it in the dev team ;)

Xcode Cocoapods Not Finding Framework Header Files

So I am working on an old Xcode project that was developed by a separate developer and am having build errors when running on my Mac due to Cocoapods. The first error is "The sandbox is not in sync with the Podfile.lock”, which I can fix by removing the various Cocoapods files and the old xcworkspace from the project and running pod install in the terminal to create all of this again. The new issue is that some of the classes cannot find the header files from the podfile's listed frameworks.
My theory is because this is an old project and the old developer didn't put version caps on some of the frameworks in the podfile, is that the project is trying to use old methods / classes that are deprecated in the newest updated frameworks. However I am not sure how to get around this as I tried putting version caps on those frameworks in the podfile without any success.
There are two paths:
You investigate each framework, estimate the approximate pod version that could have been used at the time project was active, and use particular version of each pod (you can find info on configuring pod version here
This solution won't work in 90% of cases, however, as iOS is evolving really fast and old frameworks are most probably outdated and not compatible with latest changes.
You investigate each framework and understand what actually changed. You look at headers that each pod has, understand what actually changed and implement changes in your code.
You start with headers, making sure that you include the right ones, and then start migrating code to the newest versions.
Big projects usually have migration guides.
There are no other options. As soon as any project becomes dependant on external code, it's up to developers to ensure that it's up-to-date.

Is there a way to find out automatically if a third party library has been updated

Im using a couple of libraries I found on GitHub, and I was wondering is there a way to know when a third party library used in an app has been updated? For example, a bug fix.
Must we continuously visit the users repository to find out for our selfs, or does using a dependency manager like Cocoa Pods have this functionality?
Thanks in advance.
Cocoa pods allows you to manage third party library, one feature it has it is pod outdated which checks for new releases of library's and also check if a project has new commits
more info on cocoa pods, see link
example 1 (library with releases only):
say you have AFNetwoking in your project using cocoapods with the following syntax: pod "AFNetworking" if you wanted to just check for updates do pod outdated, or to update the library if there are releases you would do pod update
example 2(library with most recent commits):
there times were you want to get most recent commits regardless of if it stability. On cocoapods you can do pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git'. this gets the most recent commit on git
CocoaPods handles this. Just type pod install every once in a while. It will fetch all available updates for you... I've been using CocoaPods for a long time without problems... You can even create private pods or development pods if you need to.

Resources