22

I'm trying to install Google Cloud Messaging for my iOS application (using swift). I've added it to my Podfile like so:

# Uncomment this line to define a global platform for your project
# platform :ios, '8.2'
use_frameworks!

target 'Project' do
    pod 'Alamofire', '~> 1.2'
    pod 'Google/CloudMessaging'
end

target 'ProjectTests' do

end

Now when I try to install the dependencies, I get an error (see below). It worked fine before I added GoogleCloudMessaging. I tried to make a new project and add it there instead to see if it worked, and I got the same error.

Analyzing dependencies
Downloading dependencies
Installing Alamofire (1.2.3)
Installing GGLInstanceID (1.0.0)
Installing Google (1.0.7)
Installing GoogleCloudMessaging (1.0.3)
Installing GoogleInterchangeUtilities (1.0.0)
Installing GoogleNetworkingUtilities (1.0.0)
Installing GoogleSymbolUtilities (1.0.0)
Installing GoogleUtilities (1.0.1)
[!] The '<Project name>' target has transitive dependencies that include static binaries: (/Users/User/Documents/Test/Pods/GGLInstanceID/Libraries/libGGLInstanceIDLib.a, /Users/User/Documents/Test/Pods/Google/Libraries/libGGLCloudMessaging.a, /Users/User/Documents/Test/Pods/Google/Libraries/libGGLCore.a, /Users/User/Documents/Test/Pods/GoogleCloudMessaging/Libraries/libGcmLib.a, /Users/User/Documents/Test/Pods/GoogleInterchangeUtilities/Libraries/libProtocolBuffers.a, /Users/User/Documents/Test/Pods/GoogleNetworkingUtilities/Libraries/libGTMSessionFetcher_full.a, /Users/User/Documents/Test/Pods/GoogleNetworkingUtilities/Libraries/libGTMSessionFetcher_core.a, /Users/User/Documents/Test/Pods/GoogleSymbolUtilities/Libraries/libGSDK_Overload.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_iPhone.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_core.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_UIFont+LineHeight.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_SystemVersion.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_StringEncoding.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_RoundedRectPath.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_Regex.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_NSStringXML.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_NSStringHTML.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_NSScannerJSON.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_NSDictionary+URLArguments.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_KVO.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_GTMURLBuilder.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_DebugUtils.a, /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTM_AddressBook.a, and /Users/User/Documents/Test/Pods/GoogleUtilities/Libraries/libGTMStackTrace.a)

Any idea how I can fix this? Would it be possible to install GCM without Cocoapods?

Dan
  • 569
  • 2
  • 4
  • 15
  • Actually for me, I was running an older version of CocoaPods. Then updated it using `gem install cocoapods`. That resolved my issue. Please have a look at http://stackoverflow.com/questions/31090681/ios-pod-install-gcm/31981415#31981415 – Sauvik Dolui Aug 17 '15 at 18:02

6 Answers6

7

Update

With Cocoapods V 0.38.2 it is now possible to use GMC, or any other Objective-C frameworks with Swift frameworks like Alamofire

Make sure that you use use_frameworks! in the podfile

# Uncomment this line to define a global platform for your project
# platform :ios, '8.2'
use_frameworks!

target 'Project' do
    pod 'Google'
    pod 'Google/CloudMessaging'
    pod 'Alamofire'
end

target 'ProjectTests' do

end

Old Answer

I'm using a Swift project too and i'm only using Objective-C frameworks, because Swift & Objective-C frameworks didn't work for me yet.

Try install GCM only without use_frameworks! and without the Alamofire framework (written in Swift)

# Uncomment this line to define a global platform for your project
# platform :ios, '8.2'

target 'Project' do
    pod 'Google'
    pod 'Google/CloudMessaging'
end

target 'ProjectTests' do

end

I ran into some problems when I'm importing GCM in the bridging header file. I'm curious if you encounter the same problems.

Solution for Google Cloud Messaging when the BridingHeader or GGLInstanceIDDelegate is not working, is to install 'Google' pod 'Google'

Gerrit Post
  • 1,247
  • 13
  • 25
  • Removing Alamofire and the us_framework! tag did indeed fix the issue. Did you have any fix for that? Otherwise I'll just add Alamofire manually. – Dan Jun 19 '15 at 08:48
  • 1
    For now i don't have an solution for that problem. It seems that Cocoapods is not supporting Objective-C and Swift frameworks at the same time [http://stackoverflow.com/a/29495412/2826164](http://stackoverflow.com/a/29495412/2826164). At least, it is not working for me. I am using Alamofire and other swift frameworks manually for now. – Gerrit Post Jun 19 '15 at 09:09
  • 1
    CocoaPods supports Swift and Objective-C frameworks just fine. The real issue is Google's pods not supporting being built as a framework in the first place, as mentioned by @maleandr. – Jon Shier Jun 29 '15 at 05:38
  • I have the same problem with google analytics and flurry with alamofire. has anyone found a way to use them both from cocoapods? – Esqarrouth Jul 22 '15 at 12:36
  • 1
    @Esq update cocoapods to V0.38.2 and you're able to use Google Objective-C frameworks with Swift frameworks – Gerrit Post Sep 18 '15 at 21:35
3

I removed the use_frameworks! from PodFile and it's working as expected.

Edi
  • 1,900
  • 18
  • 27
2

I met same problem with Google/Analytics pod.

This issue may be resolved in the latest version of CocoaPods.

See this: https://github.com/CocoaPods/CocoaPods/issues/3194

Satoshi Suzuki
  • 116
  • 1
  • 3
  • @TobiMcNamobi sorry, I thought same and I tried, but I could not add a comment due to my reputation is low... – Satoshi Suzuki Jul 29 '15 at 07:56
  • 2
    This issue seems to have been fixed in the newest version of CocoaPods 0.38.2. Just run a `gem install cocoapods` to get latest version. – Adam Johns Aug 14 '15 at 16:16
  • @SatoshiSuzuki this answer is being [discussed on meta](http://meta.stackoverflow.com/questions/306974/declined-naa-flag-although-the-answerer-agreed-to-flag). – ryanyuyu Sep 28 '15 at 15:15
1

There is problem with Google/CloudMessaging pod itself. This pod cannot be build as framework, because of some static dependencies. You can try Carthage to build you swift dependencies.

Maleandr
  • 91
  • 1
  • 7
1

I had a similar problem. My pod was 0.37.2 . I updated to 0.38.2 as mentioned in https://github.com/googlesamples/google-services/issues/22. got it solved .

Martin Jacob
  • 356
  • 1
  • 7
  • 16
-2

Remove the pod from which are showing in warning and issue gona solve