ios開發(fā)筆記

————記錄開發(fā)過程中遇到的一些問題和解決辦法:

1.關(guān)于路徑問題:

遇到的一個最扯淡的問題是,在一個庫a中調(diào)用了庫b的文件,庫a中加了該文件路徑,所以是正常的,然后在主項目中去調(diào)用了庫a的文件,一直提示找不到庫a的文件報錯,糾結(jié)了好久無法解決,最終在主項目中也加入了庫b的文件路徑,于是解決了。(因為庫a的文件調(diào)用了庫b的文件)

!!!血一樣的教訓(xùn),一定要在主工程中的head欄里加上所有需要使用的路徑,所有!?。。。?!

因為主工程中調(diào)用了luabinding,luabinding調(diào)用了正常的c++類。這個時候一定要把所有引用的地方都加到主工程的head欄里,痛苦?。。?!

今天我因為這個傻問題白白花了4個小時?。。。。。。。。。。。。。。。。。。。。?!


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

由于是全局宏,以上可能導(dǎo)致其他圖片出現(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://m.itdecent.cn/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版本,默認(rèn)選擇是最新的,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文件夾沒有導(dǎo)入導(dǎo)致的,導(dǎo)入后需要在library seach path中加入luajit.a和lua.a的路徑。

后來發(fā)現(xiàn)在luabinding工程中導(dǎo)入了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

導(dǎo)致混編失敗了。


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.對于馬甲包的收獲:

馬甲包對于公司賬號包來說,審核要求低了很多,在按照正常操作提包的時候,千萬注意混淆這件事。

第一:蘋果混淆不能用大量的無意義的奇怪字符串,但是拼音居然可以,,,需要習(xí)慣使用駝峰命名。

第二:感覺蘋果對于oc代碼的審核嚴(yán)格度比c++代碼的審核嚴(yán)格度大很多。

第三:千萬避免使用 英文+數(shù)字 這樣的名字來命名,非常危險,極容易被判斷為代碼混淆!

第四:如果使用公司賬號提包,請嚴(yán)格執(zhí)行修改命名到每一行!蘋果對于公司賬號的審核非常嚴(yán)格,并且處罰力度很大!


18.cocos3.7.2新工程遇到的問題

第一:需要把full screen 選項點上,不然提包會報錯

第二:需要把info.plist中的icon flie:Icon_57.png 這一欄刪掉



?。?!.提包遇到警告:

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)該是代碼混淆被機審拒了。在修改了代碼并在提交時的附件中回復(fù)了審核人員,第二次就通過了。


//待續(xù)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 2014年的蘋果全球開發(fā)者大會(WWDC),當(dāng)Craig Federighi向全世界宣布“We have new ...
    yeshenlong520閱讀 2,407評論 0 9
  • 不積跬步無以至千里。再愚蠢的Bug,也是進步的墊腳石。 Mac 軟件安裝提示“文件損壞,打不開” i386, x8...
    DylanPP閱讀 1,995評論 0 0
  • iOS XIB使用Safe Area后在iOS9和10上面出現(xiàn)的問題和解決方案 1.多添加一個距離SuperVie...
    下雨之後閱讀 973評論 0 1
  • 此貼會經(jīng)常更新添加新內(nèi)容,敬請關(guān)注! 首先給出iOS開發(fā)常用開源代碼和第三方庫:http://www.cocoac...
    阿諾德姜嫄水鄉(xiāng)閱讀 1,218評論 0 1
  • 說起夢想,感覺好像是一個很難實現(xiàn)的東西,又好像是很多很多的希望一般,而我的夢想,細想竟然有那么多了!今天就來說說我...
    冰鎮(zhèn)火藥閱讀 282評論 0 2

友情鏈接更多精彩內(nèi)容