How to add Google Drive API in Swift iOS Application? - ios

I have an application written in Swift which already uses the SwiftyDropbox API.
I installed SwiftyDropbox with cocoapods and the use_frameworks! keyword.
And now, when I add this pod 'Google-API-Client' to my Podfile, I get a Duplicate definition error in my Google Drive API when I tried to build my project.
So, I've decided to follow the Google Drive guide : https://developers.google.com/drive/ios/quickstart?ver=swift
But it seems this guide is deprecated, because there is no file named GTL.xcodeproj or GTMSessionFetcher.xcodeproj in the files we download by following this tutorial. And all the steps they describes seems to be inconsistent.
So I don't know what can I do to work with SwiftyDropbox and Google Drive API in my iOS project.

Just looked into the repo, it had an update last Jan 13 that may have affected the naming of the xcodeproject.
Currently, the Step 3.b project will then be
google-api-objectivec-client/Source/GTLCore.xcodeproj
gtm-session-fetcher/Source/GTMSessionFetcherCore.xcodeproj
Hopefully this is a bit of help with importing the project.

Related

What is a correct bridging header for Flurry?

I’m trying to integrate Flurry using CocoaPods in my Swift project. "pod install" downloads Flurry in the project files, but I can’t set a correct path in the bridge-file for FlurrySDK (everything is fine with all other obj-c dependencies).
Where/how can I find a correct import path?
When you are using latest CocoaPod to install external dependencies to Xcode Project, you don't really need the bridging header to expose Objective-C methods to Swift. See below screenshots once to understand it clearly.
Creating and Installing Pods.
Importing Flurry SDK in a Swift class.
Hope this helped. Thanks.

Google Speech To Text Api using Objective C

I am using GoogleSpeechRecongnization api within my project for Speech To Text.
I have copied all required files and installed pod from sample of Google for Speech To Text Api. Also copied these 2 files AudioController, SpeechRecognitionService from the Sample Code to implement the feature.
Now when I compiled my code, I received errors as in attached image.
While same steps and files are working perfectly in demo app with the custom interface, created by me.
Please help me to fix these in my main project. Thanks
The SpeechRecognitionService require google service to be linked which lies in the google folder of the sample Project, please add that too in your project, it should be working..
See where is google folder here
Cheers.
Check demo project supported architectures in build settings...
I think you need to add missing architecture in your build settings
Maybe it's in your project and maybe it's in the Pods project

Carthage and GoogleMap

Is it possible to install GoogleMap SDK via Carthage?
I only saw the tutorial for Cocoapods only.
Or I only can install manually if I am using Carthage?
According to Carthage docs:
The only supported origins right now are GitHub repositories (both GitHub.com and GitHub Enterprise)
Carthage actually builds binary framework from the sources it checkouts from the specified repository. Developer needs to link this built binary frameworks to the project afterwards.
Google already provides you with the binary version of GoogleMaps framework instead of sharing sources. Therefore all you have to do is just download this binary from official website and link it to your project without using Carthage. So you can say that Google has already done Carthage work for you so you don't have to use Carthage to build GoogleMap framework. And I believe you even couldn't if you want to because GoogleMaps source code is not open.
Hope my answer will be helpful for you.
Carthage supports linking directly to binary assets.
If you go to the "Manual Integration" section in the documentation page, you'll notice the download link looks something like this:
https://dl.google.com/dl/cpdc/d308af63f78a5a1a/GoogleMaps-3.1.0.tar.gz
So all you have to do is create a local JSON file called something like GoogleMaps.json, and put the following in it:
{
"3.1.0" : "https://dl.google.com/dl/cpdc/d308af63f78a5a1a/GoogleMaps-3.1.0.tar.gz"
}
Then, in your Cartfile, add:
binary "GoogleMaps.json" ~> 3.1.0
Voila!
Was just about to find out how to improve upon Shai's answer. You can simply add
binary "https://googlemaps.github.io/google-maps-ios-utils/GoogleMapsSDK-iOS.json" ~> 3.8.0
into your Cartfile
I used Leone Parise github repo for google maps 2.7 https://github.com/leoneparise/GoogleMaps-Carthage
He has Google Places and Google Place Picker too, but not up to date. If you want to use those, I've them uploaded to 2.7 version here:
https://github.com/danitinez/GooglePlaces-Carthage
and here
https://github.com/danitinez/GooglePlacePicker-Carthage
Cheers!

Using Google Maps SDK with Parse.com Project iOS Swift

Im working on a project (xcode 6.3+, swift) using Parse SDK (parse.com) to handle data.
Recently, we decided to use the google maps sdk to provide user with directions using the direction API. As you can use this API without the google map I started integrating it. It's my first time with cocoapods so I followed the instruction and started playing with.
pod init to create the pod specs file
here is my config coming from google Starting Guide
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'
pod install, then launching the project using the .xworkspace
I directly try to build the project and it returns 34 errors.
the type of error is always the same: Apple Match-O Linker Error
So I start looking at google cause I did the same thing on a blank project and everything was working really good.
I start to find information about the fact that using Parse SDK causes conflicts with the -ObjC linker Flags that GoogleMaps needs to work. most of the answers give two potential solutions:
1. addind the Facebook-iOS-SDK framework
tried this using the framework given by facebook, as well as using cocoapods. not working. I still got errors.
2. Force Loading the GoogleMaps framework by replacing the -ObjC flag by the following
-force_load $(PROJECT_DIR)/Pods/GoogleMaps/Frameworks/GoogleMaps.framework
this returns an error as well:
so now Im quite lost about the way to solve this. Is there anybody that found a way to integrate GoogleMaps SDK with Parse?
UPDATE
I tried a different approach by injecting GoogleMaps without cocoapods. To do this I used this method: GoogleMaps without CocoaPods
It seems to integrate itself properly, but the -ObjC flag remains. Using
-force_load $(PROJECT_DIR)/GoogleMaps.framework/GoogleMaps
is now responding but causing duplicate symbols for architecture x86_64errors.
can't seems to find a way to fix that.
You need to do this
Click on your project (targets)
Click on Build Settings
Under Framework search paths (set your framework path)
Following information for getting framework search paths
Right click on your framework folder (for ex: GoogleMaps.framework)
select Get info
copy the path from General->where and paste this path in your framework search path (path should contain in single line)
Good luck
Ok so I managed to find working solution both for integrating GoogleMaps Sdk and Parse with and without cocoapods. However, the use of the -ObjC flags by GoogleMaps forced me to integrate the FacebookSDK to the equation. I couldn't find a way to make this working without it
So this config is working with xcode 6.3+ and it required to use and older version of the Facebook SDK (when not using cocoapods)
With CocoaPods
1/. Add the Parse SDK as described on their website (existing project version)
2/. Add extra Frameworks (AdSupport, Account and Social) as well as libstdc++.6.dylib
3/. Open terminal to the root folder
4/. $ pod init
5/. open Podfile and replace content with the following:
use_frameworks!
platform :ios, ‘8.0’
pod 'GoogleMaps'
6/. $ pod install then $ pod update
7/. download FacebookSDK from this link
8/. Add FBSDKCoreKit and FBSDKLoginKit Frameworks to your project
9/. build your project.
If some error occurs, you may have to delete ParseFacebookUtils.framework from your project and keep only ParseFacebookUtilsV4.
Without CocoaPods
So this is quite the same procedure except that instead of using pods to install GoogleMaps SDK, you will integrate it manually by using the link mentionned in the question, or by going to GoogleMaps podspecs and access the source url to download the last one.
Make sure to add GoogleMaps.framework, as well as the GoogleMaps.bundle which you can find by right-click on GoogleMaps.framework /show in finder under Resources. Drag and drop to the project and make sure it's linked to the project build settings / Copy Bundle Resources
Also, make sure to have all the required framework and libraries listed on the link provided in the question.
Add the -ObjC flag under Build Settings / Other Linker Flags
When it comes to integrate the FacebookSDK, I've noticed that using the latest version isn't working. Apparently, it was prepared to work with xcode 7. Do work around this, just download an older version here
Add FBSDKCoreKit and FBSDKLoginKit to the project and you should be good to go.
Hope that help someone cause it was a pain to make this work...

Integrating YouTube Data API v3 iOS

I am trying to integrate the YouTube Data API v3 for iOS into my project. In the end all I want to do is upload videos from all instances of the app to a company owned youtube channel, and get the URL to be able to embed the videos in a website. I can't figure out how to integrate the client library for iOS though. I get compile errors, or ARC issues that I can't figure out how to resolve. The files are found here: https://code.google.com/p/google-api-objectivec-client/source/checkout
In short this is what I did:
In my project I added the GTLYouTube_Sources.m, GTLCommon_Sources.m and GTLNetworking_Sources.m.
Make sure that Build Phases -> Compile Sources the compiler flag '-fno-objc-arc' is set for these three files. This should fix your ARC issues.
You may need to set some search paths in your Build Settings if the compiler complains that it can't find a file.
Hope this helps!
I had issues but with a combination of google's page + a youtube tutorial I was able to get things working, I still don't know how to search yet but here are my notes on the subject:
This file points in the right direction - https://code.google.com/p/google-api-objectivec-client/wiki/BuildingTheLibrary
This video is better - https://www.youtube.com/watch?v=q7m3qCsQBEE
As per my comment on the video stream - "
I did this tutorial and receive 9 linker errors referencing the derived data folder and that "file was built for archive which is not the architecture being linked (x86_64)" but have "Standard Architectures" selected in the Build Settings for the project (armv7,arm64). This is using Xcode 6 but I can try on Xcode 5.1.1 if needed (though I don't think this issue will abate as it supports the 64bit architecture as well. Going into the GTL Project and selecting the GTLTouchStaticLib and changing the architecture over to Standard removed the linker errors and the build succeeded! https://www.dropbox.com/s/f6tc6t33r5k5021/Screenshot%202014-10-10%2012.08.00.png?dl=0”
API Calls may still with 401 despite having an API key due to a known issue - https://code.google.com/p/gdata-issues/issues/detail?id=5770#makechanges to fix is remove the bundle ID from the google console.
i'm giving an updated answer for this question. so it can be helpfull to community.
NOTE:- GTL is converted to GTLR . GoogleLibrary is updated. i Recommend to use cocoapods because it will be simple.(according to me) here is the link for this migration
1) create pod file for your project. by pod init & pod install in your terminal. it will create blank pod installation.(ignore if you have done already)
2) add these pod library name in pod file.
here is the some services that can be useful
pod 'GoogleAPIClientForREST'
pod 'GoogleAPIClientForREST/YouTube' //here '.../YouTube' is the service. you can use ".../Caledar' ,".../Translate" or which you want.
pod 'GTMAppAuth'
3) add these headers (i recommend to create Prefix Header '.pch' for your project.)
#import <GTMAppAuth/GTMAppAuth.h>
#import <AppAuth/AppAuth.h>
#import "GTLRYouTube.h" //here you can change double quotation ("...") with (<...>) if this throws the error "library not found".
4) this step is optional..
select your project target & go to build settings. and search for OtherLinkerFlags and add $(inherited)
NOTE:- if you can use Firebase to use google's service it will be more easy.(i've tried it and it was simple than google developer console. this is my personal opinion.)

Resources