2015年7月28日 星期二

XCode6 製作Static Framework

1.New Project -> Framework & Library -> Cocoa Touch Framework

2.在專案中建立Class

3.在專案設定檔中,選擇TARGET -> Build Phases, 將步驟2新增的Class h檔加入
「Headers」區塊
4.點擊專案Target,Edit Scheme, 「Run」build Configuration 選擇「release or debug」,此設定將決定輸出的framework版本

5.Compiler裝置選擇「iOS Device」,並且進行Compiler

6.在XCode專案結構列表中找到「Products」資料夾,點擊右鍵「Show in finder」,即可看到framework實體檔案,前往此資料夾「上一頁」即可看到Debug & Release兩個版本資料夾 經過上述步驟可以產出Release or debug .framework檔案 

以下步驟為合併兩個.framework,以便開發時不需更換framework 

1.在framework專案中設定「TARGET」->「Build Setting」-->「Linking」->「Mach-O Type」改為「Static Library」(專案使用framework時可以不需加在 Embedded Binaries區塊中)

 2.在framework專案中「New Target」,選擇「Aggregate」 

3.在Aggregate Target中選擇「Build Phases」, add Script 

4.輸入下列Script

 FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"

 DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework" 

UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${FRAMEWORK_NAME}.framework" 

FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"

 rm -rf "${UNIVERSAL_LIBRARY_DIR}"

 mkdir "${UNIVERSAL_LIBRARY_DIR}"

 cp -R "${SIMULATOR_LIBRARY_PATH}/Headers" "${UNIVERSAL_LIBRARY_DIR}/Headers"

cp -R "${SIMULATOR_LIBRARY_PATH}/Modules" "${UNIVERSAL_LIBRARY_DIR}/Modules"

cp -R "${SIMULATOR_LIBRARY_PATH}/Info.plist" "${UNIVERSAL_LIBRARY_DIR}/Info.plist" 

lipo -create "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -output "${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}"

 5.Run即可輸出合併的framework, 名稱為「專案名稱.framework」

2014年10月28日 星期二

Objective-c AFNetwork POST 巢狀結鋯

在POST  巢狀參數時,會發生raw data 參數index跑掉的問題

修改AFURLRequestSerialization.m    AFQueryStringPairsFromKeyAndValue function

2014年8月25日 星期一

CAAniamtion TimingFunction 參數調整

由於CAAnaimation 內建Ease function實在太少,可透過 functionWithControlPoints,調整出曲線 function,做出Q彈的動畫

ease function 參考圖:

圖片link:
https://camo.githubusercontent.com/893dc398d7fe5aa586b82631f65b4c2f4b47d147/687474703a2f2f692e696d6775722e636f6d2f65384f637368762e706e67




調整參數產生器:

http://netcetera.org/camtf-playground.html


範例:

CATransition *transtion = [CATransition animation];
    transtion.duration = 1.0f;
    [transtion setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:0.8f :0.0f :0.2 :3.0f]];
    [transtion setType:@"cube"];
    [transtion setSubtype:kCATransitionFromBottom];
    
    [label.layer addAnimation:transtion forKey:@"transtionKey"];



2014年8月20日 星期三

Git 移除資料夾遇到 Operation not permitted


刪除資料夾
git rm -r --cached "資料夾名稱"

另外:刪除所有該delete的檔案

git rm $(git ls-files --deleted)

2014年6月9日 星期一

Mac 簡易架設 Git Server

Mac 簡易架設 Git Server

參考來源:
1.http://git-scm.com/book/zh-tw/%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E6%9E%B6%E8%A8%AD%E4%BC%BA%E6%9C%8D%E5%99%A8

2.http://blog.longwin.com.tw/2011/03/build-git-env-share-over-ssh-2011/

3.https://www.youtube.com/watch?v=o1x-WRZrTTo

Server:

1. cd ~  (跳到Home目錄底下)
2. mkdir gitrepo.git (在Home目錄建立名為 gitrepo.git的資料夾

3. cd /gitrepo.git (進入資料夾)
4. git init --bare (--bare代表將.git隱藏目錄放到資料夾根目錄,此動作完成Server端初始化)
5. 將Client端public key 內容寫入 /.ssh/authorized.keys 裡面
7. vi ~/.ssh/authorized.keys(進入authorized.keys 寫入client public key)
6. 在 OS 共享設定打開「遠端登入」,例如:「若要從遠端登入此電腦,請輸入「ssh apple@10.1.1.199」。」

Client 製作public key

1. ssh-keygen -t rsa  (產生 id_rsa.pub 公鑰在 .ssh目錄底下)
2.將產生的公鑰檔案「 id_rsa.pub」寄給Server,讓Server加入到authorized.keys中


Client 端建立Repository

1. cd ~  (跳到Home目錄底下)
2. cd Desktop (跳到桌面)
3. mkdir local_repository(在桌面建立一個資料夾放置本地Repository)
4. cd local_repository(進入local_repository 資料夾)
5. vi test (新增一個檔案test,  編輯檔案時 shift + q  可跳出輸入項目,w儲存  q離開  q! 儲存離開)

6. git add . (將檔案「test」加入stage)
7. git commit -m 'initial upload'
8. git remote add origin apple@10.1.1.199:gitrepo.git(加入remote,由於遠端Repository在Home目錄底下,在冒號後方加入遠端Repository名稱 )
9. git push origin master (將本地端Repository 推上遠端)


Client temp clone and modify Repository

1. cd /tmp(進入temp)
2. cd clone git clone apple@10.1.1.199:gitrepo.git (從遠端複製repository到local tmp)
3. cd gitrepo (進入tmp底下gitrepo資料夾)
4. vi test2 (新增「test2」 檔案)
5. vi test (修改「test」檔案內容)
6. git add .
7. git commit -m 'user 2 first time commit'
8. git push


Client User1 Pull Repository

1. cd ~  (跳到Home目錄底下)
2. cd Desktop (跳到桌面)
3. cd local_repository(進入local_repository 資料夾)
4. git pull oringin master(將遠端Repository拉回)




2014年4月14日 星期一

UIView Rotation Forever

CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animation];
theAnimation.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,0,1)],
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(3.13, 0,0,1)],
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(6.26, 0,0,1)],
nil];
theAnimation.cumulative = YES;
theAnimation.duration = 1.0;
theAnimation.repeatCount = 5;
theAnimation.removedOnCompletion = YES;

2014年3月21日 星期五

Google AdMob

1.import Framework
  • CoreData.framework
  • AdSupport.framework
  • SystemConfiguration.framework
  • MessageUI.framework
  • AudioToolbox.framework
  • StoreKit.framework
  • CoreTelephony.framework
  • AVFoundation.framework
2.Project → Targets → Build Settings → Other Linker Flags的地方加上「-ObjC」


3.設定測試狀態

- (GADRequest *)createTestRequest{
      GADRequest *request = [GADRequest request];
      request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, @"你的實機ID", nil];
      return request;
}

4.設定loadRequest測試參數

將

[bannerView_ loadRequest:[GADRequest request]];

改為

[bannerView_ loadRequest:[self createTestRequest]];

2014年3月14日 星期五

使用 RegexKitLite iOS Framework

1.下載 RegexKitLite
  • http://regexkit.sourceforge.net/
2.專案新增 libicucore.dylib frameworks

2014年3月13日 星期四

Git + Bitbucket 帳號切換


1.切到目標資料夾下

2.git init (如果是新專案的話)

3.輸入下列

git config user.name "Your Name"
git config user.email "you@example.com"

done

2014年3月12日 星期三

UIView 曲線動畫Sample code

       CGPoint endpoint=[self.view convertPoint:point1 fromView:carBG];
       UIBezierPath *path=[UIBezierPath bezierPath];

        CGPoint startPoint=[self.view convertPoint:point fromView:self.myTableView];
        [path moveToPoint:startPoint];
        //贝塞尔曲线中间点
        float sx=startPoint.x;
        float sy=startPoint.y;
        float ex=endpoint.x;
        float ey=endpoint.y;
        float x=sx+(ex-sx)/3;
        float y=sy+(ey-sy)*0.5-400;
        CGPoint centerPoint=CGPointMake(x,y);
        [path addQuadCurveToPoint:endpoint controlPoint:centerPoint];
       
        CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
        animation.path = path.CGPath;
        animation.removedOnCompletion = NO;
        animation.fillMode = kCAFillModeForwards;
        animation.duration=0.8;
        animation.delegate=self;
        animation.autoreverses= NO;
        animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
        [layer addAnimation:animation forKey:@"buy"];

2014年2月28日 星期五

CCParticleSystemQuad crash Cocos2d V1.1-rc0

移除粒子系統2d框架的bug



修改CCScheduler.m


找到 - (void) removeUpdateFromHash:(tListEntry*)entry

tHashUpdateEntry * element = NULL;
    
    HASH_FIND_INT(hashForUpdates, &entry->target, element);
    if( element ) {
        // list entry
        DL_DELETE( *element->list, element->entry );
        free( element->entry );
        
        // hash entry
        id target = element->target;
        HASH_DEL( hashForUpdates, element);
        free(element);
        
        // target#release should be the last one to prevent
        // a possible double-free. eg: If the [target dealloc] might want to remove it itself from there
        [target release];
    }

2013年10月17日 星期四

ccpSub, ccpNormalize,ccpMult



最近在案子需求,摸了Cocos2d

記錄一下一些數學巨集

參考網址 :http://wisdomskyduan.blogspot.tw/2012/07/ios-tilemap4logic.html


ccpSub(const CGPoint v1, const CGPoint v2):他是回傳一個向量,起始點是v1,終點是v2。

ccpNormalize(const CGPoint v):白話一點是把該向量的大小化作一個單位,而保持方向。

ccpMult(const CGPoint v, const CGFloat s):這是把向量v的大小(說是長度是不是比較好懂?)乘上一個有理數s(有理數是比較數學的講法,跟程式的型別無關)。

2013年4月18日 星期四

蝦爆App 操作影片 & 操作畫面

由於App還在審核中...


先附上操作Demo : http://youtu.be/qM9I08Bztn4


1. 蝦地方 - 介紹台灣北,中,南,東釣蝦場簡易資料,包含地圖,種類,蝦種,營業時間,餌料.

2. 蝦紀錄 - 記錄每次釣蝦結果,包含時間,釣蝦場地點,竿數,隻數,並自動取得使用者目前所在城市名稱.透過拍照的方式將釣蝦文字敘述結合圖片,拍照完成後可按下重拍或者是儲存,並在App內快速上傳到使用者Facebook塗鴉牆上.

3. 蝦知識 - 介紹釣蝦相關知識,包含新手常見問題,量水深,標訊判別,釣組配重...等等,部分資訊會有相關影片可以直接在App裡面瀏覽

4. 蝦小!? - 關於蝦爆App的說明,可在此分業寄信給我.