————记录开发过程中遇到的一些问题和解决办法:
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被拒,查了下资料应该是代码混淆被机审拒了。在修改了代码并在提交时的附件中回复了审核人员,第二次就通过了。
//待续