2016年8月15日 星期一

Xcode 7.2 安裝CocoaPods

安裝CocoaPods

打開Terminal(終端機),打以下的的指令:
$ sudo gem install cocoapods


1. 用Xcode新增一個專案
2. 用Terminal(終端機),cd .../專案/,打以下的指令
$ pod init
3. 在打上
$ pod install
4. 以上指令跑完後,會新增 專案.xcworkspace,以後就直接開.xcworkspace的檔案

2016年3月7日 星期一

Xcode 7 上架時遇到 憑證無效...

解決方式:
1. 打開Key Chan在 登入 跟 系統 裡面 把 The Apple Worldwide Developer Relations Certification Intermediate Certificate刪除
2. https://developer.apple.com/certificationauthority/AppleWWDRCA.cer 下載後,點兩下安裝
3. Finish.

Xcode 7 上架時遇到 unexpected cfbundleexecutable key ... googleplus.bundle ... 錯誤

解決方式:
在找出你import的googleplus.bundle
1. googleplus.bundle/Info.plist
2. googleplus.bundle/GPPCommonSharedResources.bundle/Info.plist
3. googleplus.bundle/GPPShareboxSharedResources.bundle/Info.plist
請將這三個檔案的Executable file -> string 的值 清除

2016年1月4日 星期一

Ubuntu OpenSSL 更新或安裝

一、確認OpenSSL版本
# openssl version

二、下載你要更新的版本
OpenSSL 下載連結
# wget https://openssl.org/source/openssl-1.0.2d.tar.gz 
# tar -zxvf openssl-1.0.2d.tar.gz -C /usr/local/src

三、安裝
# cd /usr/local/src/openssl-1.0.2d
# ./config
# make
# make install
安裝完後,請移動資料夾
# mv /usr/bin/openssl /root/
# ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

後來在確認是否有更新版本
# openssl version

Xcode 7 使用google+ SDK遇到錯誤

GoogleOpenSource.framework/GoogleOpenSource(GTLDateTime.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

我們只要進入 Build Settings -> Build Options 將 Enable Bitcode 改成NO

2015年12月18日 星期五

Swift 2 Xcode7.1 Facebook SDK + 自訂Facebook Button

一、下載Facebook SDK
二、Xcode開新專案
編輯專案下的info.plist
新增以下設定
Facebook developer key 記得先去申請 Facebook Developer
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>fb{your-app-id}</string>
    </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string> 
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>facebook.com</key>
    <dict>
      <key>NSIncludesSubdomains</key> <true/>        
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
    </dict>
    <key>fbcdn.net</key>
    <dict>
      <key>NSIncludesSubdomains</key> <true/>
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>  <false/>
    </dict>
    <key>akamaihd.net</key>
    <dict>
      <key>NSIncludesSubdomains</key> <true/>
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
    </dict>
  </dict>
</dict>


三、將.framework檔放入
先new Group,名稱為Frameworks
在將FBSDKCoreKit.framework,FBSDKLoginKit.framework,FBSDKShareKit.framework放入Frameworks裡

四、寫程式
1.AppDelegate.swift

import UIKit
import CoreData
import FBSDKCoreKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication,
        openURL url: NSURL,
        sourceApplication: String?,
        annotation: AnyObject) -> Bool {
            return FBSDKApplicationDelegate.sharedInstance().application(
                application,
                openURL: url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    }
.....
}
2.ViewController.swift

import UIKit
import FBSDKCoreKit
import FBSDKShareKit
import FBSDKLoginKit

class ViewController: UIViewController {
    let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    @IBAction func loginAction(sender: AnyObject) {
        
        fbLoginManager.logInWithReadPermissions(["email"],fromViewController: self.parentViewController, handler: { (result, error) -> Void in
            if (error == nil){
                let fbloginresult : FBSDKLoginManagerLoginResult = result
                if(fbloginresult.grantedPermissions.contains("email"))
                {
                    self.getFBUserData()
                    self.fbLoginManager.logOut()
                }
            }
        })
        
    }
    func getFBUserData(){
        if((FBSDKAccessToken.currentAccessToken()) != nil){
            FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).startWithCompletionHandler({ (connection, result, error) -> Void in
                if (error == nil){
                    print(result)
                }
            })
        }
    }
    @IBAction func logoutAction(sender: AnyObject) {
        
        fbLoginManager.logOut()
    }
    
}


打完收功...