Google SignIn iOS practice log

Google Sign-in for iOS

1.Download GoogleSignIn SDK
https://developers.google.com/identity/sign-in/ios/sdk/
There are two ways to get the SDK, CocoaPod or direct download,
Personally I preferred the download way.
0.Download SDK
Follow the official document procedure
https://developers.google.com/identity/sign-in/ios/start

2.Get configuration file
https://developers.google.com/mobile/add?platform=ios&cntapi=signin&cntapp=Default%20Demo%20App&cntpkg=com.google.samples.quickstart.SignInExample&cnturl=https:%2F%2Fdevelopers.google.com%2Fidentity%2Fsign-in%2Fios%2Fstart%3Fconfigured%3Dtrue&cntlbl=Continue%20with%20Try%20Sign-In

2.EnableSignin

 

3.Copy to project directory first then “pull” into xcode project
Basically just pull the configuration file into the xcode project  and it is OK.
But you will gonna thank me for this lousy procedure when there are multiple configuration files in one xcode project.
3.Download plist
4.Configure xcode project-level parameters
https://developers.google.com/identity/sign-in/ios/sign-in?configured=true

Put REVERSED_CLIENT_ID into Project -> Target -> Info -> URL Types
Put bundle id into Project -> Target -> Info -> URL Types

4.URLTypes

 

5.Modify source code
There will be only one file to be modified – AppDelegate

The most important statement is to set [GIDSignIn sharedInstance].clientID = CLIENT_ID(in configuration)

 

 

 

 

Posted in iOS development | Leave a comment

How to fix – There was an internal API error

There was an internal API error

XCode build app 至 iPhone 時出現此錯誤

解決方法:

Target->Build Setting->Product Name

Remove any “weird” characters and keep there only English characters.

Posted in iOS development | 2 Comments

簡單學日語 2.0 上架了

簡單學日語 2.0 上架了

https://itunes.apple.com/tw/app/jian-dan-xue-ri-yu/id907920405?mt=8

iOS 的 app 真麻煩

iOS 的版本只要一升級

就得回頭 revise 所有的 app

要不然就會莫名其妙的閃退

日前心血來潮看了一下這個 app

才發現早就閃退到不行

只好趕快改一改再上架更新

Posted in 簡單學日語 | 2 Comments

Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil

Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil

 

Symptom: Normal but crash in iOS 7 device.

Possible reason : Use some “Baseline” constraints (Only supported after iOS 8) in storyboard.

Solution : Remove any “Baseline” constraints of that page crashed in storyboard.

Posted in iOS development | Leave a comment

XCode SVN is not under version control

That is the keyword I Googled for solution and no luck.

I’m too old to learn new source control mechanism like Git so I stuck on SVN with XCode.

It works perfect usually but sometimes it show “xxx is not under version control”.

For me, the reason is some special character in file name , in my case , the @ character.

I googled and tried to fixed this issue but no luck.

And today, finally, I solved this issue with one single step, simple and straight.

Open “Terminal” application, go to the project folder and keyin this

svn commit -m “Happy SVN”

And you’ll see all the files (including file name with @ character) are committed successfully.

I don’t know why the commit won’t succeed in XCode, but I’m happy that it works in command line mode.

 

Update on 2016/03/02:

Sometimes you have to make those @xx.png files the Add status (with A in the right) in Xcode first before you do the command-line svn commit.

Posted in iOS development | Tagged , , , , , , | Leave a comment

Custom URL schemes practice

Let’s define something in this scenario :

1.Receiver app – to be invoked via custom URL

2.Sender app – who wants to invoke the app

3.Custom URL scheme – define as “happygo”

 

 

For Receiver app, here’s what to do:

1.Define the url scheme in Project/Targets/Info/URL Types as follow

螢幕快照 2016-02-04 下午12.20.51

2.AppDelegate.m – Two methods to be implemented.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 return YES;    //must return YES
 }
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
 //Check if the scheme was valid
 if ([[url scheme] isEqualToString:@"happygo"]) {
 NSString *query = [url query];
 NSArray *queryComponents = [query componentsSeparatedByString:@"&"];

 for (int i=0; i<[queryComponents count]; i++) {
 NSArray *oneParam = [[queryComponents objectAtIndex:i] componentsSeparatedByString:@"="];
 NSString *sValue = @"";
 NSString *sKey = [oneParam objectAtIndex:0];
 if (oneParam.count==2) {
 sValue = [oneParam objectAtIndex:1];
 }
 }
 //Here is what you want to do, write here.
 return TRUE;   //return TRUE because of valid scheme
 }
 return FALSE;   //invalid scheme, skip process
 }

 

 

For Sender app, here’s what to do :

1.Add the following to info.plist

<key>LSApplicationQueriesSchemes</key>
 <array>
 <string>happygo</string>
 </array>

2.Invoke the receiver app via URL form, sample source code as follow

NSString *sURL = [NSString stringWithFormat:@"happygo://www.domain.com?name=Good&phone=123123"];
 NSURL *myURL = [NSURL URLWithString:sURL];

 if ([[UIApplication sharedApplication] canOpenURL:myURL]) {
 [[UIApplication sharedApplication] openURL:myURL];
 } else {
 NSLog(@"--bad url--");
 }

Actually, you can even invoke the app via Safari Browser.

Just input the URL in Safari, press GO, and the receiver app will be invoked.

Posted in iOS development | Leave a comment

iOS Watchkit Development – paired device unavailable for development

I had this problem twice, I googled the same article to do the same actions to fix.

Here I wrote down to remember myself.

Error : “paired device unavailable for development” showed in XCode when new to Apple Watch

Fix steps :

  1. Unpair my watch
  2. Reboot both iPhone and apple watch
  3. Pair them again, and setup my watch as a new one
  4. Plug (unplug first) iPhone to Mac
  5. On apple watch, say Trust the computer when it asks
  6. Unplug and plug again
  7. Close and open XCode
  8. Open the project and wait a few seconds

Good luck.

Posted in iOS development | 3 Comments

Icon only UITabbar, no title at all.

1.Clear the title attribute to empty.

2.Set the Image Insect attribute of the Tabbar item as follow

tabbarinsect

And you’re good to go.

Happy Tabbaring…

Posted in iOS development | Leave a comment

Set UITabbar tintColor via StoryBoard

I found that it’s really weird to set UITabbar tintColor.

It won’t work if you change the Tint attribute in the View section.

tint_notwork

You have to add the attribute by yourself to make it work. Check this out.

tint_work

Happy Tabbaring !!

Posted in iOS development | Leave a comment

Add existed XCode project to SVN repository

I’ve been bothered by this issue for a long time.

And finally I’d decide to find the best practice today to do this job.

Here are the steps:

Step 1.

Create SVN repository, for example, http://svn.domain.com/myrepo

Step 2.

Create XCode project, Assume the project path is Documents/iosprojects/milkshaker

Step 3.

Open OS X app Terminal  which is command line mode.

Step 4.

In terminal, cd to the parent directory of your project directory (Documents/iosprojects in this example)

cd /Users/yourname/Documents/iosprojects

Step 5.

The most import step, svn import (NOT ADD) as following command

svn import -m “New Import milkshaker/ http://svn.domain.com/myrepo

The syntax is

svn import -m “<remark message> <project directory>/ <SVN URL>

Key in the userid and password and you’re good to go.

Step 6.

After step 5 was done.

Open XCode app, try Source control->Check out

Key in the SVN URL, userid and password to checkout the project to local directory.

 

That would be all I want to share, happy SVNing !!

Posted in Misc | Leave a comment