顯示具有 cocoa開發 標籤的文章。 顯示所有文章
顯示具有 cocoa開發 標籤的文章。 顯示所有文章

2013年2月15日 星期五

建立 iOS app 企業佈署步驟

http://www.maas360.com/maasters/forums/mobile-app-management-mam/show/332/building-ios-apps-for-enterprise-deployment

Building iOS Apps for Enterprise Deployment

4 October 2011 (Last edited: 14 June 2012)

Overview

This document describes the steps needed to build an iOS app for Enterprise deployment. Unlike ad-hoc builds, these builds can be installed on any iOS device owned by the enterprise. Ad-hoc builds are usually created for testing an app on a pre-defined set of test devices. When the app is ready for production deployment, an enterprise (in-house) build is created.

Note: You must have the Team Agent role in the iOS Provisioning Portal to create the artifacts needed for this build.

The process for building an Enterprise app is:

1. Create the Distribution Certificate.

2. Create an Enterprise Provisioning Profile. (Go to developer.apple.com and click Member Center.)

3. Build the app using the Enterprise Provisioning Profile.

Following sections explain these steps in further detail.

Create a Distribution Certificate

Distribution certificates are used to sign Enterprise apps. The steps to receive a Distribution Certificate are:

1. Login to the iOS Provisioning Portal with the Agent role.

2. In the Certificates section, go to Distribution tab.

3. Use the Certificate Assistant (available in the Keychain Access application on Mac OS X) to generate a Certificate Signing Request (CSR).

4. Upload the CSR to the iOS Provisioning Portal and download the distribution certificate.

5. Save the certificate on the disk, and open this using Key Chain Access.

6. Xcode can now use this certificate to sign iOS apps.

7. To export this certificate to a different (build) machine, exported it in .p12 format:

a. In Key Chain Access, go to the My Certificates section

b. Right-click on the downloaded certificate and click "Export..."

c. Save the certificate in .p12 format, and provide a secure password while saving.

Create an Enterprise Provisioning Profile

The steps to create an Enterprise Provisioning Profile are:

1. Log in to the iOS Provisioning Portal with the Team Agent role.

2. In the Provisioning section, go to the Distribution tab.

3. Click on New Profile. On the Create iOS Provisioning Profile page

a. Select the Distribution Method as In House

b. Select an appropriate distribution certificate

c. Select App ID

4. Download the provisioning profile.

5. This provisioning profile can be used to build the app for in-house deployment.

Building an App Using an Enterprise Provisioning Profile

The steps to build an app on a machine are:

1. Install the Distribution certificate (.p12 file)

2. Open Xcode. Go to the Organizer window

3. Import the Enterprise Provisioning Profile

4. Open the app’s project file in Xcode

5. Go to Build Settings, Code Signing section

6. Select the certification contained in the Enterprise Provisioning Profile

7. Build the project using Build For > Build for Archiving. This will create the app archive in .ipa file format

8. The .ipa file is ready for enterprise deployment

push 推播開發

Error Domain=NSCocoaErrorDomain Code=3000 "找不到應用程式的有效“aps-environment”授權字串" UserInfo=0x4b8c40 {NSLocalizedDescription=找不到應用程式的有效“aps-environment}

這問題是由於 provisioning 未更新

在新增 push certificate 之後,請更新 provisioning

注意順序!要先為 App ID 產生推播憑證,再為 App ID 產生的 Provisioning Profile 才有效,若確定以上步驟順序都無誤,卻還是出現問題,則可能,你 [Code Signing] 忘記重新設定 Provisioning Profile:

(來自 http://cutesung2.blogspot.tw/2012/04/3-push-notifications-aps-environment.html

Device Token:

這是在 mobileProvisioning 配置成功後,在 app 上執行時才會產生的資訊

编写push notification之获取device token

PushMeBaby

https://github.com/stefanhafeneger/PushMeBaby

這是個方便的測試 push 程式(在MAC上)

不過所用的 certificate 名稱有限定

目前(2013年1月4日 下午3:05)為 apns.cer

需要複製檔案進去改名

名稱在 ApplicationDelegate.m 的

self.certificate = [[NSBundle mainBundle] pathForResource:@"apns" ofType:@"cer”

其他參考

http://blog.csdn.net/totogogo/article/details/7376214

http://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/

NSString 找文字方法

其實重點是要搞懂 NSRange 是什麼

NSRange commonLocation =[b rangeOfString:@":"];

if (commonLocation.location != NSNotFound) {

//會員帳號

loginID = [b substringFromIndex:commonLocation.location];

isLogined=YES;

}

certificate, provisioning, 又是你們兩個搗蛋鬼..

CSR:產生 certificate 的檔案

產生 CSR 時,電腦已經先行產生了公用 key 和私密 key 在電腦了

CSR 中包含了公用 key, 可以送給 apple 產生 certificate, 因為private key 只有產生的電腦有

所以可以保證該 certificate 只有該電腦可以使用和簽署

app id 就是類似專案

provision file

Xcode 會有很大的 cache 空間

包括 refresh certificate, 甚至是 team

code sign error 但是確定 provisioning 和 certificate 正確時

可以使用 don’t code sign 清除 Xcode 對 provision 的記憶

只要是要切換帳號

先把 key

iOS 鍵盤處理事件

對需要切換輸入法的國家來說

處理鍵盤事件還蠻煩的..(Apple 怎麼不把這個一起搞定...)

以擁有兩個 TextField textA, TexField B textB 的 viewController 而言

在 ViewDidLoad 中註冊 UIKeyboardWillShowNotification、UIKeyboardWillHideNotification 通知後

[notification addObserver:self selector:@selector(keyboardWillShow:)

                                                 name: UIKeyboardWillShowNotification object:nil];

        [notification addObserver:self selector:@selector(keyboardWillHide:)

                                                 name: UIKeyboardWillHideNotification object:nil];

進入 text A 時,會觸發 textBigenEdit 事件

然後會觸發 UIKeyboardWillShowNotification(鍵盤顯示)

如果這時候切換鍵盤,會再次觸發 UIKeyboardWillShowNotification(鍵盤顯示)

每切換一次輸入法就會觸發一次 UIKeyboardWillShowNotification(鍵盤顯示)

在不離開 textA 的情況下直接進入 textB 的話

無論是使用程式移動或使用者移動,都不會觸發 UIKeyboardWillShowNotification(鍵盤顯示)

而無論在何種情況

關閉鍵盤就會觸發 UIKeyboardWillHideNotification(鍵盤隱藏)

所以,一個完整的解決辦法是

使用者進入、切換輸入法時,抓取鍵盤高度,進行調整

第一次進入時,抓取高度,調整元件到鍵盤上方

切換輸入法時,抓取高度,調整元件到鍵盤上方

如果元件的高度不大,可以考慮直接調整到鍵盤上方一定高度,避免切換鍵盤時移動

可是當輸入元件不只一個時,只有拉 view 的位置,很可能會因為元件間的位置不足而造成使用者混亂(UX 問題)

這邊有一個小問題

如何切換到下一個輸入欄位

使用鍵盤移動時,可以將元件放到輸入鍵盤正上方

要考慮的

元件彼此間的高度是否足夠?直接移動 view 的話,是否會造成視覺干擾?(輸入欄位 A 時,畫面上出現了欄位 A 和欄位 B,欄位 B 甚至可能讓人以為是目前正在輸入的欄位

因此在多欄位的情況,個人偏好的方法是將對應的欄位直接放到鍵盤正上方

需要的方法會是

開啟鍵盤時,移動元件或基底 view,使元件顯示到正上方

切換元件或切換輸入法時,檢查位置,移動到正上方

關閉鍵盤(離開元件時使用 resignFirstResponder)回復元件或基底 view 到原值

作法

註冊鍵盤監聽事件、beginEdit 事件

目前元件屬性

和一個接受移動或離開參數的移動方法

-(void)keyboardWillShow{

        //移動 view

}

-(void)keyboardWillHide{

        //回復 view

}

-(void)textWillEdit{

        //檢查鍵盤是否顯示,未顯示則不作動作

        //以顯示則移動 view

}

-(void)mokeView:(BOOL)toShow{

        

        //檢查鍵盤大小和元件位置,可以考慮檢查位置是否符合而是否執行移動

        //移動 view

        

}

2013年2月14日 星期四

iOS 憑證、金鑰管理與備份

了解了 private key, public key, .CSR, .cer 檔案彼此的關係後

接下來就是怎麼管理的問題

先回顧一下

建立 CSR 時,會產生對應的 private key, public key

上傳 .CSR 產生 .cer 時,產生的 .cer 只有在存在對應的 private key 的電腦中才能用

首先,先記得一件事情

已經由 .cer 檔案有效簽署的 iOS app 在撤銷對應的 .cer 時,是不會受到影響的

而推播所用的 ssl certificate 是獨立的(或者說,使用的是負責推播的伺服器上存在的 private/public key 以及對應的 .CSR)

因此,如果遺失了 private/public key 時,其實大可以重新產生、重新申請

對現有服務、App 並不會造成影響

唯一的影響只是開發人員要上傳新檔案時,必須使用新的 .cer

另一種比較常見的狀況

是需要輸出 certificate 給其他人員簽署 app (例如 phoneGap…)

這種情況,下載對應的 certificate (*.mobilevision)後,安裝到 Mac,然後打開 keychain access,找到對應的 certificate,選擇輸出(.p12),這時候會需要密碼(忘記的話,再輸出一次就好了..)

然後將 *.mobilevision 和 .p12 檔案給對方就好

.p12 檔案的結構和原理還不太熟

(以下部分「全部」尚未實作過,僅就手上資料描述)

如果要轉移/備份現有的 certificate, 首先要記得一起轉移對應的 keys

備份 keys 的方法,是匯出成 .cer

Mac 的 keychain 有提供匯出 keys 的功能(轉出的檔案是 .cer 檔案)

理論上應該可以把對應的 keys 轉移出去

如果遺失了 iOS app store 的 .cer 檔案,重新下載就好

如果遺失了 .CSR 檔案

可以開啟 keychain access, 點選對應的 private key 選擇從現有金鑰要求憑證(如下圖,不確定中文)

PastedGraphic-2013-02-14-19-24.png

如果遺失了 keys.. 找一下有沒有備份(time machine..)

沒有的話,應該是沒救了

重新產生就好

可以考慮用 certificates 需要更新的理由來虎爛 dever..

dever 聽到 certificates 這種非開發問題大概都會隨你處置… :p

2013年2月5日 星期二

p12, mobileprovision 以及更換開發帳號的方法

使用 keychain 刪除憑證時

偶爾會一起刪除掉金鑰,造成 proviosning 無效需要重新處理(掯....

後來發現正確作法是打開 keychain,

進入鑰匙

然後選擇鑰匙下面的憑證一一刪除..

喵的一堆鑰匙就這樣失去效用..

然後 keychain 的 cache 很嚴重

做完更新後,要確認效果最好是關閉(cmd + Q)後重新開啟

為何要刪除憑證?

因為 Xcode 經常會錯亂..尤其在 certificate 使用相同名字(同一家公司的不同帳號)時

更新 certificate 後

development 的 provisioning 檔案可以重新產生

distribution provisioning profile 則只能砍掉重新建立

Code Sign 同名錯誤

Code Sign error: Certificate identity 'iPhone Distribution: xxxxxx’ appears more than once in the keychain. The codesign tool requires there only be one.

先到 keychain 裡面,挑選 key, 把不要用的 certificate 刪除(注意...)

然後選擇 don’t code sign 洗記憶,clean

再換回正常的 provisioning profile 就OK了

理論上是這樣啦..不過 keychain 和 Xcode 的 organiser 的記憶時間有點沒規則

可能需要多做幾次

什麼是 p12 檔案

.p12 檔案是憑證+金鑰匯出的結果檔案

在其他電腦上輸入密碼開啟並匯入後,該台電腦上就可以使用該憑證

以及以該憑證建立的 provisioning 檔案

這也是之前用來讓多組開發人員可以進行實機測試的主要方法:將金鑰輸出成 p12 後匯入其他電腦

可參考 http://itouchs.blogspot.tw/2011/08/idevice-app.html 的說明

4. 將 private key 轉成 .p12 檔, 寄給需要利用 Certificate 一同開發 App 的人.

若要使用此方法,建議為 dev 和 dis certificate 建立不同的 CSR (也就是會產生兩組不同的金鑰)

方便管理(開發組使用 dev p12 匯入開發證書即可)

開發推播時,常會使用同一台電腦

不過在正式環境,通常會使用不同電腦

因此有推播功能時,要申請 推播用的 SSL 檔案,可建立伺服器自己的 CSR 檔案,上傳到 apple 推播取得對應的 SSL 檔案後,轉送到推播伺服器

當然使用同一台電腦,取得SSL憑證後匯出成 p12 也不是不行

什麼是 mobielprovision

從網站下載的 mobielprovision

包含了 appID, certificate (dev/dis) 以及可應用機器(特定幾台或無限制)等設定的檔案

可用於簽署 app ID 相符的 app (所以 wildcard 可用於所有 app)

mobielprovision 檔案

多帳號下開發的建議配置

可能的話,使用 member center 使用一個帳號負責開發作業(各帳號邀請同一帳號A,帳號A擁有不同開發帳號下的 dev certificate cer_A,同時也可以申請使用了 cer_A 的 provisioning profile 作為開發測試用

或者只是使用 wildcard 其實也可以

需要佈署 distribution 時,下載對應帳號的 distribution certificate 以及 provisioning profile

佈署、上傳完畢後,就可以到 keychain 中刪除對應的 certificate 避免錯亂

iOS Team Provisioning Profile: Wildcard 應該是使用對應的輔助帳號,在 Xcode 下的 organiser refresh 時自動更新?

iOS 憑證申請總整理(二) member center

這邊說明 member center 功能

member center 提供讓 apple dev 帳號可多人開發的方法

由於一個帳號在 dev/dis 環境下只能有一個 certificate

在多人開發環境下會有很大問題

member center 的入口隨處可見..但是我以前從沒想要去點

PastedGraphic13-2013-02-5-13-53.png

進去後,可以選擇 people 管理人員

左邊的 All People、 iOS Developers 內容我看起來差不多…可能是邀請的成員不夠複雜

基本上分三 + 一級

Admin, Member, No Access 和不在名單

iOS Developers 中可以勾選大量成員移除 Access 權限

而 All people 和 iOS Developer 頁面都可以選擇成員的 detail 調整權限(Admin, Member or No Access)

PastedGraphic23-2013-02-5-13-53.png

成員怎麼來?邀請來的

開啟 Invitations 頁面,可以看到兩種邀請法(單一、大量),以及最近的邀請結果

PastedGraphic22-2013-02-5-13-53.png

邀請發出後,受邀的人員會收到邀請信

信中有連結,點下連結後會有確認網址

確認後就可以登入受邀的 Developer Program了

受邀的帳號若有多個 Developer Program 存取權限的話

使用受邀的帳號登入時,可能會有點混亂

因為需要不時確認目前所在的 Program

不過總算比之前要一直登出簡單了一點

PastedGraphic16-2013-02-5-13-53.png

上面這個畫面不時會出現,而且有點沒規律…

請各位程式設計師多多包容 Apple 對我們的不友善..

反正 Xcode 都用過來了…這點小小不便算什麼呢....

登入後,就可以申請新的 Certificate(記得 CSR 要給個好名字..)

在 Provisioning Portal 會看到以下畫面

上面是 Your Certificate,所以只會看到自己的

下面是成員的,左邊的 Signing Requests 是待驗證(by role: Admin)

右邊是 Active Certificates

PastedGraphic18-2013-02-5-13-53.png

另一個有變化的地方是 Provisioning 申請畫面可以挑 certifictes 了

PastedGraphic19-2013-02-5-13-53.png

iOS 憑證申請總整理(一)

注意:

CSR 檔案很重要,請妥善保存

如果有比較高級的安全性需求,建議每一個帳號作兩份 CSR,分別對應 dev/dis 環境的憑證申請

注意,CSR 檔案真的非常重要..

如果你覺得不重要,那你應該是已經搞懂了 private/public 和相關資料流程的人

不然就是完全不知道 CSR 檔案重要的原因..

CSR 檔的重要性在於可與對應的專用/公用密鑰對應

如果這三者有其中一份不見了..請考慮重新作一組..

目前為止,我不知道怎麼從鑰匙重新產生對應的 CSR 檔案

如果你知道,請告訴我

先從申請憑證講起(下圖)

申請憑證時,會產生對應的專用、公用 key 到鑰匙中

並以輸入的一般名稱儲存,名稱這個東西很重要,尤其當你是 soho 或有需要申請多組憑證時

名稱可以事後變更,不過何必多一道工呢

選擇儲存到硬碟是因為之後要上傳到 apple developer

PastedGraphic-2013-02-5-12-03.png

之後到 developer 或 distribution 要求 certificate

系統會要求提供 CSR

上傳成功後,稍等一下就會產生對應的 certificate

PastedGraphic7-2013-02-5-12-03.png

下載下來後(記得順便下載 WWDR)

會在 keychain 中發現對應的 certificate (憑證)

這邊會發現下載回來的 certificate 會有對應的 key,

所以 key 不能亂砍..

PastedGraphic8-2013-02-5-12-03.png

同時,在 Xcode 的 organiser 中也會看到對應的 ID

之後想移除 Teams 的帳號,到 keychain 移除對應的 certificate 就可以了,然後,千萬別動 key

由於 Xcode 的這方面機制很容易錯亂(我沒有說爛..果粉別噴我)

切換帳號或使用不同帳號的 provison 簽署(即使 dev..),我常出現問題

所以很習慣刪除 certificate 再切換帳號

頭像有綠色勾勾表示可以使用/沒有問題

PastedGraphic9-2013-02-5-12-03.png

DEVICE ID 沒啥可說的

可以在 Xcode organizer 中直接 add to portal 加入這邊,profile 顯示的是有使用該機器的 dev profile 數目

PS: 每個帳號一年只能新增 100 “次”新裝置,也就是說移除舊裝置不會影響到 100 這個數目

PastedGraphic1-2013-02-5-12-03.png

APP ID 申請畫面,這邊的 description 和 bundle identifier 之後都不能更改

記得要有識別性

PastedGraphic2-2013-02-5-12-03.png

下圖是 app id 列表

Wildcard 應該會自己產生,如果沒有的話,可以自己建立一個 bundle identifier 為 *, decryption 自訂的 app id

如果沒有這個,xcode organiser refresh 時會出現 wildcard 錯誤

PastedGraphic4-2013-02-5-12-03.png

App ID configure 內容

推播、iCloud 等設定都在這邊

PastedGraphic5-2013-02-5-12-03.png

啟用四項設定其中任一時

之前的 provision file 必須要重新產生,不然無法套用設定

另外,推播需要有 SSL 檔案用於加密訊息,與 certificate、provisioning 獨立(意思就是更新 certificate、provisioning 時不用重新產生)

Data protection 不太了解,請參看 http://blog.csdn.net/lifengzhong/article/details/7739477

PastedGraphic6-2013-02-5-12-03.png

建立 Provisioning 時,需要輸入 Profile name(之後可修改)

挑選 certificate (dev 環境的話)

certificate 理論上在 dev/dis 都只能有一組

不過因為可以在 member center 中邀請開發者,開發者可申請 certificate

因此可能會有多組 developer certificate

但是 distribution certificate 一定只能有一組,請妥善保管當初申請時的金鑰(使用 p12 輸出)

遺失的話,就只能重新建立 CSR 重新建立(不會對已簽署的 app 造成影響)

development provision profile 可以選擇 certificate, app ID 和 devices

app ID 是選擇對應的 ID,而且只會出現app id 的 description name, 沒有識別性的話就只能猜了..

Devices 是此 provisioning profile 可以安裝的裝置

裝置安裝了此 provioning 後,就可以執行 bundle id 為對應 app id 的 app 了

換個說法,建立名稱為xyz 的 provisioning profile,使用 app ID tw.com.abc, 選擇機器 2,3,4 後

一個 bundle identifier 為 tw.com.abc 的 app 就可以用xyz 簽署,並使用機器 2, 3,4 執行

此外的 app, 如 tw.com.gef 不可使用此 provisioning profile 簽署

此外的裝置,如裝置 1, 5, 6, 則無法用於執行使用 xyz 簽署的 app

PastedGraphic10-2013-02-5-12-03.png

distribution,這邊可以選擇兩種

app store: 上傳到 apple store 用,只可選 ID,不用選機器

ad hoc: 臨時,基本上是給 testflight 之類服務執行大範圍測試使用

除了 app ID 外,必須指定可用裝置

(這也是為何 testflight 需要先申請、安裝他們的憑證、上傳 udid 並新增到 devices 中之後才可使用)

PastedGraphic11-2013-02-5-12-03.png

distribution 頁面都是說明

pass type ID 頁面沒用過,所以就不說明了

2013年1月29日 星期二

iOS 推播流程整理

先去 developer 開啟 app-id 的推播

更新 provisioning,不然會有 找不到應用程式ID或授權的錯誤

程式內

開啟後執行

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert];

}

使用者開啟時就會出現註冊推播警告視窗,下面這各是申請更多權限

[[UIApplication sharedApplication]

registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert |

UIRemoteNotificationTypeBadge |

UIRemoteNotificationTypeSound)];

若使用者不同意,執行(並於每次開機後執行?)

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err{

若使用者同意後,執行(並於每次開機後執行)

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

以下是接收 push 訊息

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

{

2013年1月18日 星期五

cocoa 取得 webview cookie

在 iOS app 中

可以使用 NSHTTPCookie 取得 同一 app 中 webview 的 cookie 值

NSHTTPCookie *cookie;

NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];

for (cookie in [cookieJar cookies]) {

NSLog(@"%@", cookie);

}

其他方法

NSMutableString *cDesc = [[[NSMutableString alloc] init] autorelease];

[cDesc appendString:@"[NSHTTPCookie]\n"];

[cDesc appendFormat:@" name = %@\n", [[cookie name] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

[cDesc appendFormat:@" value = %@\n", [[cookie value] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

[cDesc appendFormat:@" domain = %@\n", [cookie domain]];

[cDesc appendFormat:@" path = %@\n", [cookie path]];

[cDesc appendFormat:@" expiresDate = %@\n", [cookie expiresDate]];

[cDesc appendFormat:@" sessionOnly = %d\n", [cookie isSessionOnly]];

[cDesc appendFormat:@" secure = %d\n", [cookie isSecure]];

[cDesc appendFormat:@" comment = %@\n", [cookie comment]];

[cDesc appendFormat:@" commentURL = %@\n", [cookie commentURL]];

[cDesc appendFormat:@" version = %@\n", [cookie version]];

實作時,value 可能會有 %00

可以用 [nsstring componentsSeparatedByString:@“%00”] 方法分割陣列

然後用 stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 還原數值

2013年1月16日 星期三

使用 EdgeInsets 建立按鈕側邊底圖

使用了 EdgeInsets 建立這樣的一個按鈕

PastedGraphic-2013-01-16-19-34.png

基本作法是先上圖

[btn_store setImage:[UIImage imageNamed:@"arrow.png"] forState:UIControlStateNormal];

然後設定圖片的 Insets, 把圖擠到右邊

[btn_store setImageEdgeInsets:UIEdgeInsetsMake(0,130,0,0)];

不過這時候會發現 title 被擠到左邊

所以就把title labe 拉回來一點

(這一點我覺得不太對勁,應該要有比以下更好的作法

btn_store.titleEdgeInsets=UIEdgeInsetsMake(0, -40, 0, 40);

2013年1月15日 星期二

iOS 0xE8008016 錯誤

這是一個很爛的錯誤說明

The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.

這問題發生在我新增了一台 iPad 測試,修正 storyboard for ipad 設定後

看到這個錯誤後,我理所當然的以為是某個設定被動到了(雖然我很確定我沒動過 Entitlements 檔案

網路上主要的解決作法是建議新增/建立 entitlement 檔案,加入 get-task-allow = YES

不過這作法對我不適用

後來檢查了一下,發現有一種說法是裝置沒有加入 provisioning (可是我記得我有add to portal?

去 portal 檢查了一下之後,才發現原來 device 只被加入到舊的 provisoning 中(不知道判斷邏輯是啥..

重新加入目前使用的 provisioning 後就解決了

同場加映:另一個奇葩解法 (CodeSignError:ProvisioningProfile 487F3EAC-05FB-4A2A-9EA0-31F1F35760EB can't be found

http://blog.csdn.net/zzfsuiye/article/details/7310266

iOS App 在 iPad 1, new iPad 上閃退

今天碰到一個詭異的問題

目前開發的 app 並沒有 iPad 專屬介面

所以在前端設定成使用 iphone 介面

在 ipad 2 上測試時沒有問題

但是在 new iPad 和 iPad 1 測試時,一直閃退

今天拿到實機後,測試時發現裝置會嘗試讀取 iPad 的 storyborad 檔案..

但是這檔案根本沒有在用..

檢查了一下,發現 MainStoryboard_iPad 出現在一個欄位中

修改後就沒有問題了

PastedGraphic1-2013-01-15-08-54.png

同場加映:

另外一個可能的原因是 storyboard 的 auto layout 選項沒有取消

2013年1月5日 星期六

ViewController dealloced

前幾天寫程式時

因為多了一個功能,決定把本來用程式碼製作 VC 的部份重組出來作為單一 VC 檔案

不過重新引用時一直出現問題..

出現的錯誤訊息是 VC performselector: deallocd

後來發現是因為本來是使用

UIView* vv= childVC.view

[parent addsubview:view]

改成

[parent addsubview:childvc.view]就ok了

這應該是所有權的問題所導致

2012年12月28日 星期五

iOS 6 鬼打牆的 UINavigationController source 問題

錯誤訊息

Push segues can only be used when the source controller is managed by an instance of UINavigationController

下面左邊為主要 vc

裡面第二、第三個按鈕對應到圖中的兩個vc,使用 addsubview 方式貼上處理

一開始為了快速建立,有拉seque 關連,不過後來就使用 IBAction 方式而非 Seuqeready 方式處理

在 iOS 5 中,這樣的方式沒問題

但是在 iOS 6中,切換到這兩個 VC,按下完成按鈕執行 NSData datawithcontentofurl 動作時

會「直接」跳離 app

滴巴戈時,只有出現

Push segues can only be used when the source controller is managed by an instance of UINavigationController

處理了很久一直沒有頭緒

後來打開 storyboard,看到這兩個關連

決定死馬一下

沒想到竟然好了..

特此誌之

PastedGraphic-2012-12-28-12-04.png

2012年12月26日 星期三

iOS in-house 企業佈署相關知識

app 做好後進行封裝

封裝時要使用 enterprise distribution 相關設定

並把產生的 ipa 檔案和 plist 檔案放到相關人員可存取的位置

然後提供如下連結,告知 iDevice 進行安裝

使用此網址通知安裝

itms-services://?action=download-manifest&url=http://example.com/app.plist

itms-services 為 url-scheme, 告知 iOS 啟動安裝服務

action 為動作參數

url 為 plist 位置

伺服器要進行 MIME 設定

.IPA - application/octet-stream

.PLIST - text/plain.

iOS in-house 企業佈署 ipa 儲存修改了

2012年12月26日

使用 Xcode 4.5.2 build for archiving 之後

在 Organizer 中選擇 Distribution 要建立 in-house ipa 版本時

會發現傳統的 share 選項不見了

改成勾選 save for enterprise 建立

2012年8月12日 星期日

專案開發 成本、流程與地雷


之前看過一篇文章討論 app 開發成本的
http://www.inside.com.tw/2010/10/17/how-much-to-develop-a-great-app
裡面的說法大致是,一個 app的開發成本不是只有app最後版本的成本
還要包括開發過程中的開發成本
例如,app最後呈現出來的版面/ui並不是一次就好的
過程中可能有上百種嘗試
上百種嘗試並不誇張
版面配置三種主要修改,對應這些配置,各種UI/按鈕/圖片的修改隨便算一下就會超過上百次
theme plus的開發過程中,光是logo就出現了30種嘗試,而那只是一個沒有任何ui的圖案
主題、地圖、地標的顯示也都至少有過 3 種不同的嘗試作法

ui/版面配置調整後,背後的程式碼當然也要調整
這部份的調整主要是在版面配置改變時發生
不過當顯示內容改變(例如表格背景從紅色換成粉紅),這部份也要有修改
而這部份的修改並不會只是程式端
程式改好後,還要讓美術看過才能過關,除非是單純的色塊或文字大小的修改
如果是漸層這種無法直接抓色碼的修改,沒有美術把關,很能做到
除非美術能給 方向、起始色碼等..,當然另一種選擇是給圖片,大家都愉快
不過圖片會碰到另一個色偏問題(這問題不只是圖片會發生就是了..)

iOS device和mac的螢幕很注重色彩正確性
但是這一點在win上基本悲劇,除非是超高級螢幕+專業調色
這意思是,美術在他的 win 電腦上設計出來的東西
放到ios上後,感覺可能就跑了(攤手
然後又要繼續調整..(悲劇阿…

回到開頭的文章
最近接了一個小案子,真的不大..
基本功能很簡單,但是業主沒有其他具體想法
結果就是做了兩三板
功能越來越多,但是價格一開始也說死了
算是學個經驗吧..

以後碰到這種只有功能沒有版面的案子
先照成本開三倍下去
如果有版面和功能,開個兩倍
萬一他沒有要改功能或版面的話,在把錢拿來找美術或加入動畫功能
不然的話,對於這種非專業的業主,照成本開基本悲劇..


2012年3月27日 星期二

取得使用者目前鍵盤/輸入法


目前用不上,還是備忘一下
http://stackoverflow.com/questions/1414876/detecting-current-iphone-input-language

https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/ChoosingLocalizations.html


NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];

不確定這作法抓到的是什麼就是了..


此外也可以監視使用者切換事件
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(inputModeDidChange:)
name:@"UIKeyboardCurrentInputModeDidChangeNotification"
object:nil];

- (void)inputModeDidChange:(NSNotification*)notification
{
id obj = [notification object];
if ([obj respondsToSelector:@selector(inputModeLastUsedPreference)]) {
id mode = [obj performSelector:@selector(inputModeLastUsedPreference)];
NSLog(@"mode: %@", mode);
}
}