————記錄開發(fā)過程中遇到的一些問題和解決辦法:
1.關(guān)于路徑問題:
遇到的一個最扯淡的問題是悲伶,在一個庫a中調(diào)用了庫b的文件咸包,庫a中加了該文件路徑凛驮,所以是正常的常侣,然后在主項目中去調(diào)用了庫a的文件蜡饵,一直提示找不到庫a的文件報錯,糾結(jié)了好久無法解決胳施,最終在主項目中也加入了庫b的文件路徑溯祸,于是解決了。(因為庫a的文件調(diào)用了庫b的文件)
!!!血一樣的教訓舞肆,一定要在主工程中的head欄里加上所有需要使用的路徑焦辅,所有!4豢琛?甑恰!Aぁ前方!
因為主工程中調(diào)用了luabinding,luabinding調(diào)用了正常的c++類廉油。這個時候一定要把所有引用的地方都加到主工程的head欄里镣丑,痛苦!S榱健]航场!
今天我因為這個傻問題白白花了4個小時JぁHたⅰR∶怼!RB啤N捞弧!5ハ弧Oδ!;С印B氡!<拧W!>ò椤8帷!9啊P粘唷!
2.關(guān)于cocos2d-x引擎無法使用png圖片的解決辦法:
Cocos2d-x加載圖片資源出現(xiàn)libpng?error:?CgBI:?unhandled?critical?chunk
設(shè)置Remove?Text?Metadata?From?PNG?Files?=?NO.就可以正常顯示了
3.加載tiled文件時出現(xiàn)白線條
通常是由于抗鋸齒造成的仲吏,打開這個宏?CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL=1
由于是全局宏模捂,以上可能導致其他圖片出現(xiàn)鋸齒,第二種方法如下:
調(diào)用瓦片地圖對應(yīng)CCTexture2D的setAliasTexParameters接口蜘矢。若調(diào)用之后還有黑線,則還調(diào)用?CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
例如:
C++代碼:
CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
CCTexture2D* texture2D = CCTextureCache::sharedTextureCache()->textureForKey("TiledResource.png");
texture2D->setAliasTexParameters();
lua代碼:
cc.Director:getInstance():setProjection( cc.DIRECTOR_PROJECTION2_D )
local map = cc.TMXTiledMap:create( string.format( "map/%s.tmx", mapName ) )
local tmxLayer = map:getLayer( "layerName" )
? ? ? ?tmxLayer:getTexture():setAliasTexParameters()
4.關(guān)于拖入文件:
拖入文件時一定要選擇正確的target综看,否則會發(fā)現(xiàn)文件已經(jīng)拖入到工程里了品腹,但是一直無法找到的問題。
5.應(yīng)用間跳轉(zhuǎn)見:http://www.reibang.com/p/e95266db29b2
6.遇到無法下載圖片的問題:
原因是iOS9中引入了一個新的特性:ATS (App Transport Security)
新特性要求App內(nèi)訪問的網(wǎng)絡(luò)必須使用HTTPS協(xié)議
關(guān)閉很簡單,打開項目中的info.plist文件,在其中添加一個字典類型的項目App Transport Security Settings,然后在其中添加一個key:Allow Arbitrary Loads,其值為YES,如下圖所示:
7.10進制轉(zhuǎn)16進制時:echo 'ibase=10;obase=16;xxxxxxxx'|bc
8.新建工程時红碑,需要修改info中的支持ios版本舞吭,默認選擇是最新的,release版本編譯會有問題
9.cocos新建工程修改:
#define BT_SHUFFLE(x,y,z,w) ((w)<<6| (z)<<4| (y)<<2| (x))
修改為
#define BT_SHUFFLE(x,y,z,w) ((w)<<6| (z)<<4| (y)<<2| (x)) &0xff
10.修改IOS Deployment target最低為8.0
11._luaopen_cjon報錯:
這個問題糾結(jié)了好久析珊,后來發(fā)現(xiàn)是cocos2dx中extenal文件夾中的lua文件夾沒有導入導致的,導入后需要在library seach path中加入luajit.a和lua.a的路徑羡鸥。
后來發(fā)現(xiàn)在luabinding工程中導入了lua文件夾的路徑,從c++工程轉(zhuǎn)到lua工程需要注意忠寻。
12.'system' is unavailable: not available on iOS
cocos2dx的bug惧浴,修改方法為:
添加頭文件 ? ? #include <ftw.h>
添加方法:
intunlink_cb(constchar*fpath,conststruct stat *sb,inttypeflag, struct FTW *ftwbuf)
{
intrv = remove(fpath);
if(rv)
???perror(fpath);
returnrv;
}
替換
lua_pushinteger(L, system(luaL_optstring(L,1,NULL)));
為
lua_pushinteger(L, nftw(luaL_optstring(L,1,NULL), unlink_cb,64, FTW_DEPTH | FTW_PHYS));
13.又遇到了一個.c文件的報錯:
wsocket.c:23:10: Implicit declaration of function 'LOBYTE' is invalid in C99
原因是沒有加入#ifdef _xxx_
和#endif
導致混編失敗了。
14.Building for iOS, but the linked library 'libluajit.a' was built for macOS.
Xcode?->?File?->?Workspace Settings?->?Build System?->?Legacy Build System
15.iOS查找API
1奕剃、 cd 到你的工程目錄
2衷旅、使用全局搜索命令(注意最后要加一個點)
grep -r xxxx .
16. ? ?3.17版本輸入框不能輸入中文
修改cocos2d-x\cocos\platform\ios\CCEAGLView-ios.mm的3個地方就可以了 (以下修改可直接搜索函數(shù)名)
- (NSString *)textInRange:(UITextRange *)range
{
? ? CCLOG("textInRange");
? ? if(nil!=markedText_)
? ? {
? ? ? ? return markedText_;
? ? }
? ? return@"";
}
- (UITextRange *)markedTextRange
{
? ? CCLOG("markedTextRange");
? ? if(nil!=markedText_)
? ? {
? ? ? ? return [[[UITextRange alloc] init] autorelease];
? ? }
? ? return nil; // Nil if no marked text.
}
- (void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event
{
? ? for (UIGestureRecognizer *ges in [self gestureRecognizers])
? ? {
? ? ? ? [self removeGestureRecognizer:ges];
? ? }
? ? if (isKeyboardShown_)
? ? {
? ? ? ? [self handleTouchesAfterKeyboardShow];
? ? }
17.對于馬甲包的收獲:
馬甲包對于公司賬號包來說捐腿,審核要求低了很多,在按照正常操作提包的時候柿顶,千萬注意混淆這件事茄袖。
第一:蘋果混淆不能用大量的無意義的奇怪字符串,但是拼音居然可以嘁锯,宪祥,,需要習慣使用駝峰命名家乘。
第二:感覺蘋果對于oc代碼的審核嚴格度比c++代碼的審核嚴格度大很多蝗羊。
第三:千萬避免使用 英文+數(shù)字 這樣的名字來命名,非常危險烤低,極容易被判斷為代碼混淆肘交!
第四:如果使用公司賬號提包,請嚴格執(zhí)行修改命名到每一行扑馁!蘋果對于公司賬號的審核非常嚴格涯呻,并且處罰力度很大!
18.cocos3.7.2新工程遇到的問題
第一:需要把full screen 選項點上腻要,不然提包會報錯
第二:需要把info.plist中的icon flie:Icon_57.png 這一欄刪掉
8垂蕖!雄家!.提包遇到警告:
ITMS-90683:?Missing?Purpose?String?in?Info.plist?-?Your?app's?code?references?one?or?more?APIs?that?access?sensitive?user?data.?The?app's?Info.plist?file?should?contain?a?NSPhotoLibraryUsageDescription?key?with?a?user-facing?purpose?string?explaining?clearly?and?completely?why?your?app?needs?the?data.?Starting?Spring?2019,?all?apps?submitted?to?the?App?Store?that?access?user?data?are?required?to?include?a?purpose?string.?If?you're?using?external?libraries?or?SDKs,?they?may?reference?APIs?that?require?a?purpose?string.?While?your?app?might?not?use?these?APIs,?a?purpose?string?is?still?required.?You?can?contact?the?developer?of?the?library?or?SDK?and?request?they?release?a?version?of?their?code?that?doesn't?contain?the?APIs.?Learn?more?(https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).
加入了相應(yīng)權(quán)限效诅,但是沒有加權(quán)限說明,對應(yīng)說明加上即可趟济。
ITMS-90078:?Missing?Push?Notification?Entitlement?-?Your?app?appears?to?register?with?the?Apple?Push?Notification?service,?but?the?app?signature's?entitlements?do?not?include?the?"aps-environment"?entitlement.?If?your?app?uses?the?Apple?Push?Notification?service,?make?sure?your?App?ID?is?enabled?for?Push?Notification?in?the?Provisioning?Portal,?and?resubmit?after?signing?your?app?with?a?Distribution?provisioning?profile?that?includes?the?"aps-environment"?entitlement.?Xcode?does?not?automatically?copy?the?aps-environment?entitlement?from?provisioning?profiles?at?build?time.?This?behavior?is?intentional.?To?use?this?entitlement,?either?enable?Push?Notifications?in?the?project?editor's?Capabilities?pane,?or?manually?add?the?entitlement?to?your?entitlements?file.?For?more?information,?see
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/HandlingRemoteNotifications.html#//apple_ref/doc/uid/TP40008194-CH6-SW1.
比較神奇的警告乱投,我生成的證書文件中絕對沒有推送權(quán)限,代碼中也刪干凈了相應(yīng)的顷编。但是還是報了這個警告戚炫,了解到這個警告可以忽略,還有一個辦法:在proprecessor macios中加上DISABLE_PUSH_NOTIFICATIONS=1(參考:https://blog.csdn.net/xudailong_blog/article/details/100833211)
新包提上去后一次收到了兩封郵件媳纬,一封提示如上警告双肤,一封通過。
ITMS-90683:?Missing?Purpose?String?in?Info.plist?-?Your?app's?code?references?one?or?more?APIs?that?access?sensitive?user?data.?The?app's?Info.plist?file?should?contain?a?NSLocationWhenInUseUsageDescription?key?with?a?user-facing?purpose?string?explaining?clearly?and?completely?why?your?app?needs?the?data.?Starting?Spring?2019,?all?apps?submitted?to?the?App?Store?that?access?user?data?are?required?to?include?a?purpose?string.?If?you're?using?external?libraries?or?SDKs,?they?may?reference?APIs?that?require?a?purpose?string.?While?your?app?might?not?use?these?APIs,?a?purpose?string?is?still?required.?You?can?contact?the?developer?of?the?library?or?SDK?and?request?they?release?a?version?of?their?code?that?doesn't?contain?the?APIs.?Learn?more?(https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).
仔細檢查代碼后刪除了Location相應(yīng)系統(tǒng)庫文件和代碼钮惠。
ITMS-90809:?Deprecated?API?Usage?-?Apple?will?stop?accepting?submissions?of?new?apps?that?use?UIWebView?APIs?starting?from?April?2020.?See
https://developer.apple.com/documentation/uikit/uiwebview?for?more?information.
這個是最新版的ios把UIWebView列為過期api了茅糜,不允許調(diào)用,可以改為使用wkWebView素挽。
對于某些三方sdk可能會有使用這個的情況蔑赘,可以用 (grep -r uiwebview .) 代碼在終端中全局搜索
2.?3 Performance: Accurate Metadata
Guideline 2.3.1 - Performance
We discovered that your app contains hidden features. Attempting to hide features, functionality or content in your app is considered egregious behavior and can lead to removal from the Apple Developer Program.
2.3.1被拒,查了下資料應(yīng)該是代碼混淆被機審拒了。在修改了代碼并在提交時的附件中回復了審核人員米死,第二次就通過了锌历。
//待續(xù)