ios工程打包ipa時提示archive failed (CC_MD5導致的)

打包失敗有很多的原因,而我這個項目沒有任何的錯誤提示,無從下手。還好有備份,備份是可以打包的。

用最笨的方法,一個一個的把新文件覆蓋到舊項目中,終於把問題鎖定在一個md5函數裏,

+(NSString *)md5:(NSString *)str {
    const char *cStr = [str UTF8String];//轉換成utf-8
    unsigned char result[16];//開闢一個16字節(128位:md5加密出來就是128位/bit)的空間(一個字節=8字位=8個二進制數)
    CC_MD5( cStr, strlen(cStr), result);
    /*
     extern unsigned char *CC_MD5(const void *data, CC_LONG len, unsigned char *md)官方封裝好的加密方法
     把cStr字符串轉換成了32位的16進制數列(這個過程不可逆轉) 存儲到了result這個空間中
     */
    return [NSString stringWithFormat:
            @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
            result[0], result[1], result[2], result[3],
            result[4], result[5], result[6], result[7],
            result[8], result[9], result[10], result[11],
            result[12], result[13], result[14], result[15]
            ];
    /*
     x表示十六進制,%02X  意思是不足兩位將用0補齊,如果多餘兩位則不影響
     NSLog("%02X", 0x888);  //888
     NSLog("%02X", 0x4); //04
     */
}

//沒有導包的時候,提示如下:
Implicit declaration of function 'CC_MD5' is invalid in C99

 //導入這個就行了,成功生成ipa
#import <CommonCrypto/CommonDigest.h> 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章