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 | 4 Comments

簡單學日語 2.0 上架了

簡單學日語 2.0 上架了

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


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

NSString *sURL = [NSString stringWithFormat:@"happygo://"];
 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


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.


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


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,

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/

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

UILabel 動態高度 Dynamic Height

UITableViewCell 有 heightForRowAtIndexPath 可以指定


若是「想以文字內容決定 UILabel 的高度」


先用「文字,字型和寬度」(這點要事先決定,不然沒辦法算)計算出 UILabel 的高度

然後再用這個算出來的高度去 initWithFrame



+(float) getHeightForText:(NSString*) text withFont:(UIFont*) font andWidth:(float)width {
CGSize constraint = CGSizeMake(width , 20000.0f);
CGSize title_size;
float totalHeight;

SEL selector = @selector(boundingRectWithSize:options:attributes:context:);
if ([text respondsToSelector:selector]) {
title_size = [text boundingRectWithSize:constraint
attributes:@{ NSFontAttributeName : font }

totalHeight = ceil(title_size.height);
} else {
title_size = [text sizeWithFont:font
totalHeight = title_size.height ;

CGFloat height = MAX(totalHeight, 40.0f);
return height;

Posted in iOS development | Leave a comment