1 Launch Keychain Access from your local Mac and from the login keychain, filter by the Certificates category. You will see an expandable option called “Apple Development Push Services”
2 Right click on “Apple Development Push Services” > Export “Apple Development Push Services ID123″. Save this as apns-dev-cert.p12 file somewhere you can access it. There is no need to enter a password.
3 The next command generates the cert in Mac’s Terminal for PEM format (Privacy Enhanced Mail Security Certificate):
openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts
posted @
2012-05-29 11:07 lincode 閱讀(733) |
評論 (0) |
編輯 收藏
這個(gè) bug 在 xcode 4.3 以下會(huì)出現(xiàn),4.3 以后已經(jīng)修正了。
解決方法為:找到 target 的圖標(biāo),更改其 Other Linker Flags 為: -all_load 或 -force_load
-force_load,后跟隨一個(gè)文件位置,可以更精確地加載所需文件。
蘋果的解釋為 :
http://developer.apple.com/library/mac/#qa/qa1490/_index.html簡單點(diǎn)說就是,Objective-C 的動(dòng)態(tài)特性使得需要,為鏈接器添加一個(gè)標(biāo)簽(設(shè)置 Other Linker Flags 為 -ObjC)來解決通過 Category 向類添加方法的問題。
但這個(gè)標(biāo)簽 -ObjC 在 64 位 和 iOS 中有問題,需要使用 -all_load 或 -force_load。
總結(jié)如下:
如果,第三庫中沒有 category,Other Linker Flags 無需設(shè)置
如果,第三方庫中有 category,需要設(shè)置為 -ObjC
如果,某些 Xcode 版本中,出現(xiàn)問題,修改設(shè)置為 -all_load
posted @
2012-04-23 14:56 lincode 閱讀(1814) |
評論 (0) |
編輯 收藏
獲得 Crash Report:1 itunesConnect 的后臺(tái)會(huì)提供一個(gè) Crash report 表;
2 把一臺(tái)打開了開發(fā)模式的機(jī)器接入 Mac,Xcode 的 Organizer 中能查看這臺(tái)設(shè)備的 Crash Report;
3 若使用了 Umeng.com, Bugsense.com 之類的工具。
閱讀 Crash Report:這之前需要一個(gè)名為 AppName.app.dSYM 的文件。Xcode 中,Archive 一個(gè)項(xiàng)目之后,可以在 Organizer 的 Archives 分頁中,找到所有項(xiàng)目的 Archvie 文件。
右鍵點(diǎn)擊一個(gè), Show Package Content,就能看到一個(gè)類似 AppName-3-19-12.app.PM.xcarchive 的文件,show in finder 這個(gè)文件,就能找到 .dSYM 文件。
在 Ternimal 中執(zhí)行,若是 來自于 iphone 3G 的機(jī)器,就需要使用 armv6 代替 armv7.
atos -o AppName.app.dSYM/Contents/Resources/DWARF/AppName -arch armv7 0x0000b82
這樣就能看到,地址對應(yīng)的類,函數(shù),代碼行數(shù)。這個(gè)命令只能解析出客戶代碼的位置。若是錯(cuò)誤堆棧中的系統(tǒng)調(diào)用,是無法翻譯出來的。
posted @
2012-03-18 13:56 lincode 閱讀(1001) |
評論 (0) |
編輯 收藏
Apple 提供了一個(gè)地址方向解析的服務(wù) MKReverseGeocoder,上傳一個(gè)經(jīng)緯度,返回一個(gè)詳細(xì)的地理位置信息。但這個(gè)服務(wù)在中國不太穩(wěn)定,時(shí)常不可用。
Google map 也提供了一個(gè)類似的服務(wù),是訪問一個(gè) google map 的 api,這里試圖封裝了 google map 的服務(wù)。使使用 apple 和 google 的服務(wù)的接口基本一致,替換起來很容易。Google map 的這個(gè)服務(wù)在中國的狀態(tài)比 apple 稍微好一些,但也有不穩(wěn)定的時(shí)候。我猜想,apple 也許是使用 google 的服務(wù)封裝了自己的 MKReverseGeocoder。若是如此,這里的嘗試也就沒有什么意義了。
DOUHttpRequest 是對 ASIHTTPRequest 的一個(gè)簡單封裝。這些代碼可以 繼承自 MKReverseGeocoder。這樣,使用方法就和 MKReverseGeocoder 一樣了。
static NSString* kGeoServerUrl = @"http://maps.google.com/maps/api/geocode/json?latlng=%f,%f&sensor=true&language=en";
static NSString* kLatitudeUserInfoKey = @"latitudeUserInfoKey";
static NSString* kLongitudeUserInfoKey = @"longitudeUserInfoKey";
//
// It's tje solution for replacing MKReverseGeocoder that has problem in China.
//
- (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude {
NSString *url = [NSString stringWithFormat:kGeoServerUrl, latitude, longitude];
DOUHttpRequest *req = [DOUHttpRequest requestWithURL:[NSURL URLWithString:url] target:self];
NSNumber *lat = [NSNumber numberWithDouble:latitude];
NSNumber *lon = [NSNumber numberWithDouble:longitude];
req.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:lat, kLatitudeUserInfoKey, lon, kLongitudeUserInfoKey, nil];
DOUService *service = [DOUService sharedInstance];
[service addRequest:req];
}
- (NSDictionary *)addressDictionary:(NSObject *)obj {
NSArray* ary = nil;
if (IS_INSTANCE_OF(obj, NSDictionary)) {
NSObject* data = [(NSDictionary*)obj objectForKey:@"results"];
if (IS_INSTANCE_OF(data, NSArray)) {
ary = (NSArray*)data;
NSDictionary *dic = [ary objectAtIndex:0];
NSArray *addressComps = [dic objectForKey:@"address_components"];
//NSString *streetNumber = @"";
NSString *route = @"";
NSString *locality = @"";
NSString *country = @"";
for (NSDictionary *comp in addressComps) {
NSArray *types = [comp objectForKey:@"types"];
NSString *type = [types objectAtIndex:0];
// if ([type isEqualToString:@"street_number"]) {
// streetNumber = [comp objectForKey:@"long_name"];
// }
if ([type isEqualToString:@"route"]) {
route = [comp objectForKey:@"long_name"];
}
if ([type isEqualToString:@"locality"]) {
locality = [comp objectForKey:@"long_name"];
}
if ([type isEqualToString:@"country"]) {
country = [comp objectForKey:@"long_name"];
}
}
NSDictionary *addressDic = [NSDictionary dictionaryWithObjectsAndKeys:route, kABPersonAddressStreetKey,
locality, kABPersonAddressCityKey,
country, kABPersonAddressCountryKey, nil];
return addressDic;
}
}
return nil;
}
- (void)requestFinished:(DOUHttpRequest *)req {
NSError *error = [req error];
if (!error) {
DebugLog(@"str:%@", [req responseString]);
NSObject *obj = [[req responseString] JSONValue];
NSDictionary *addressDic = [self addressDictionary:obj];
CLLocationCoordinate2D coordinate;
coordinate.latitude = [[req.userInfo objectForKey:kLatitudeUserInfoKey] doubleValue];
coordinate.longitude = [[req.userInfo objectForKey:kLongitudeUserInfoKey] doubleValue];
MKPlacemark *placemark = [[[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:addressDic] autorelease];
[self reverseGeocoder:nil didFindPlacemark:placemark];
}
}
- (void)requestFailed:(DOUHttpRequest *)req {
[self reverseGeocoder:nil didFailWithError:[req error]];
}
#pragma mark - MKReverseGeocoderDelegate
static NSString * const AppleLanguagesKey = @"AppleLanguages";
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
NSArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:AppleLanguagesKey];
NSString *currentLanguage = [array objectAtIndex:0];
// set current language as english
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"zh-Hans", nil]
forKey:AppleLanguagesKey];
NSString *local = [placemark.locality lowercaseString];
[AppContext sharedInstance].currentCityUid = local;
// reset current language
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:currentLanguage, nil]
forKey:AppleLanguagesKey];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
TraceLog(@"reverseGeocoder :%@", [error localizedDescription]);
}
posted @
2012-01-12 21:27 lincode 閱讀(1369) |
評論 (0) |
編輯 收藏