ios开发笔记

————记录开发过程中遇到的一些问题和解决办法:

1.关于路径问题:

遇到的一个最扯淡的问题是,在一个库a中调用了库b的文件,库a中加了该文件路径,所以是正常的,然后在主项目中去调用了库a的文件,一直提示找不到库a的文件报错,纠结了好久无法解决,最终在主项目中也加入了库b的文件路径,于是解决了。(因为库a的文件调用了库b的文件)

!!!血一样的教训,一定要在主工程中的head栏里加上所有需要使用的路径,所有!!!!!!

因为主工程中调用了luabinding,luabinding调用了正常的c++类。这个时候一定要把所有引用的地方都加到主工程的head栏里,痛苦!!!!

今天我因为这个傻问题白白花了4个小时!!!!!!!!!!!!!!!!!!!!!!


2.关于cocos2d-x引擎无法使用png图片的解决办法:

Cocos2d-x加载图片资源出现libpng error: CgBI: unhandled critical chunk

设置Remove Text Metadata From PNG Files = NO.就可以正常显示了


3.加载tiled文件时出现白线条

通常是由于抗锯齿造成的,打开这个宏 CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL=1

由于是全局宏,以上可能导致其他图片出现锯齿,第二种方法如下:

调用瓦片地图对应CCTexture2D的setAliasTexParameters接口。若调用之后还有黑线,则还调用 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.关于拖入文件:

拖入文件时一定要选择正确的target,否则会发现文件已经拖入到工程里了,但是一直无法找到的问题。


5.应用间跳转见:https://www.jianshu.com/p/e95266db29b2


6.遇到无法下载图片的问题:

原因是iOS9中引入了一个新的特性:ATS (App Transport Security)

新特性要求App内访问的网络必须使用HTTPS协议

关闭很简单,打开项目中的info.plist文件,在其中添加一个字典类型的项目App Transport Security Settings,然后在其中添加一个key:Allow Arbitrary Loads,其值为YES,如下图所示:


7.10进制转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报错:

这个问题纠结了好久,后来发现是cocos2dx中extenal文件夹中的lua文件夹没有导入导致的,导入后需要在library seach path中加入luajit.a和lua.a的路径。

后来发现在luabinding工程中导入了lua文件夹的路径,从c++工程转到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个地方就可以了 (以下修改可直接搜索函数名)


- (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++代码的审核严格度大很多。

第三:千万避免使用 英文+数字 这样的名字来命名,非常危险,极容易被判断为代码混淆!

第四:如果使用公司账号提包,请严格执行修改命名到每一行!苹果对于公司账号的审核非常严格,并且处罚力度很大!


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).

加入了相应权限,但是没有加权限说明,对应说明加上即可。


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.

比较神奇的警告,我生成的证书文件中绝对没有推送权限,代码中也删干净了相应的。但是还是报了这个警告,了解到这个警告可以忽略,还有一个办法:在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相应系统库文件和代码。


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了,不允许调用,可以改为使用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被拒,查了下资料应该是代码混淆被机审拒了。在修改了代码并在提交时的附件中回复了审核人员,第二次就通过了。


//待续

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,176评论 5 469
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,190评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,232评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,953评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,879评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,177评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,626评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,295评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,436评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,365评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,414评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,096评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,685评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,771评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,987评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,438评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,032评论 2 341

推荐阅读更多精彩内容

  • 2014年的苹果全球开发者大会(WWDC),当Craig Federighi向全世界宣布“We have new ...
    yeshenlong520阅读 2,242评论 0 9
  • 不积跬步无以至千里。再愚蠢的Bug,也是进步的垫脚石。 Mac 软件安装提示“文件损坏,打不开” i386, x8...
    DylanPP阅读 1,880评论 0 0
  • iOS XIB使用Safe Area后在iOS9和10上面出现的问题和解决方案 1.多添加一个距离SuperVie...
    下雨之後阅读 854评论 0 1
  • 此贴会经常更新添加新内容,敬请关注! 首先给出iOS开发常用开源代码和第三方库:http://www.cocoac...
    阿诺德姜嫄水乡阅读 1,118评论 0 1
  • 说起梦想,感觉好像是一个很难实现的东西,又好像是很多很多的希望一般,而我的梦想,细想竟然有那么多了!今天就来说说我...
    冰镇火药阅读 184评论 0 2