ios 工程 报错

iOS开发之Found a swap file by the name ".podfile.swp" owned by: Netban dated:...file name: ~N...

 

Found a swap file by the name ".podfile.swp"
owned by: Netban dated: Fri Mar 24 13:57:27 2017
file name: ~Netban/Desktop/podfile
modified: YES
user name: Netban host name: NetBanMacBook-Pro.local
process ID: 15310
While opening file "podfile"
dated: Sat Apr 1 11:30:23 2017
NEWER than swap file!

(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.

(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r podfile"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".podfile.swp"
to avoid this message.

Swap file ".podfile.swp" already exists!

问题:就是说当前问价夹下存在了一个.podfile.swp文件,这样会导入无法写入

解决办法:
cd 进入工程目录
ls -a //查看当前目录下的文件
rm -rf ..podfile.swp // 强制删除
再vimpodfile就好了




参考链接:https://www.jianshu.com/p/dec1bed7a0b6

 

 

=====

ios  the request was denied by service delegate for reason unspecified 

报错的情况如下:

xcode8(The request was denied by service delegate (SBMainWorkspace) for reason: Unspecified. )Xcode 8 模拟器无法调试

 

从xcode7 创建的工程用xcode8 的环境打不开也报这个,其实是转换工程的时候  里面environment variables下多了一个空白配置,删除就可以了。

 

通用的解决方案如下:

1.点击模拟器前面的工程 -> New Scheme ->Target选择第一个Name默认点击OK重新添加一个工程到模拟器上。

2.点击模拟器前面的工程 ->Manage Schemes (如果你完成第一步就会有两个工程,将以前的删除掉)删除方法是选中不要的工程,点击左下方的“-”号就可以了。

3.选中你新添加的工程run就可以了。



 
 
 
 
 
 

推荐大家个朋友开的淘宝小店店, 

https://shop545764523.taobao.com/

 

====

 

Attempt to present <TestViewController2: 0x7fd7f8d10f30> on <ViewController: 0x7fd7f8c054c0> whose view is not in the window hierarchy!

当 storyboard里面的 按钮 即连接了 类文件里面的点击方法  又  连接了   storyboard里 另一个  控制器的  modal 

就会出现类似Attempt to present <TestViewController2: 0x7fd7f8d10f30> on <ViewController: 0x7fd7f8c054c0> whose view is not in the window hierarchy!的错误  ,意思是说系统尝试present一个没有在window的层级结构内 存在view的控制器

需要去掉一个方法,不要对一个按钮通过不同形式重复add不同的方法。这样会冲突。

 

====

iOS开发之Xcode9报错 Compiling IB documents for earlier than iOS7 is no longer supported. 

 

升级到Xcode9时,最低的编译版本为iOS8,但是在使用一些SDK的时候就会报出Compiling IB documents for earlier than iOS7 is no longer supported. 

这句错误,这个时候我们点击错误跳转到Xib或Storyboard中随后按照截图操作,把build for 的版本更改为iOS8或以上错误即可解决。

一般有多个,需要改完一个之后再次编译,把报类似错误的都改过来,这时候重新编译  可能左边的错误提示还会在(xcode的缓存所致),但是已经可以编译成功。说明错误已经解决。

====

报错一,编译或者打包的时候 找不到图片的错误

  

 

进入app路径,copy一份图片进去就好了

 

 

 

报错二 

 

打包OTA包出错:ipatool failed with an exception CmdSpec NonZeroExcitException bitcode-build-tool

 

一、 library not found for -lXXX

  • 描述: Xcode 10 以后报错library not found for -lstdc++.6.0.9
  • 原因: 这个错误原因是因为iOS12.0中去掉了lstdc++.6.0.9.tbd动态库

解决方案:从Xcode9中找到动态库lstdc++.6.0.9.tbd文件copy到Xcode10下就可以完美解决问题。或者用古老的办法将iOS12的DeviceSupport文件copy到Xcode9.4下也可以完美解决Xcode9运行iOS12的问题。

实际操作

  1. 从Xcode9中找到动态库lstdc++.6.0.9.tbd;
  2. 需要将文件复制到下述四个路径下,才能保证模拟器和真机均好用

二、iPhone is busy: Preparing debugger support for iPhone

  • 描述: 手机第一次链接到Xcode时出现
  • 原因: 需要识别手机

解决方案:等10-15分钟。安心等待是最好的方法

三、Expected a type

  • 描述: 写一个自定义的类,这个类继承了NSObject,其中UIView 报错 Expected a type
  • 原因: 只导入了#import <Foundation/Foundation.h>

解决方案:导入#import <UIKit/UIKit.h>


四、#<CmdSpec::NonZeroExcitException: Command exited with pid 22735 exit 1:

  • 描述: 打测试包时报错

解决 打包的时候不要选择  rebuild from bitcode

 

 

五、IPA processing failed

 

当时本人用环信的sdk包包,打包的时候提示这个。

 

突然想到,打包需要用剔除x86 框架的那个 sdk。换过来就好了。
因为项目中使用的SDK支持i386,x86_86这个架构,而最新的打包环境强制不支持模拟器架构打包。因此会给报出错误。

 


参考链接:

 

https://www.jianshu.com/p/d071c0209b40

 

 https://www.jianshu.com/p/80707b3fe899

 

https://www.jianshu.com/p/0145916f2139

 

 

====

Main.storyboard: WKWebView before iOS 11.0 (NSCoding support was broken in previous versions)

 

在工程里用  故事板写了 wkwebview  如果运行在 ios11以下 就会报这个错误,如果要支持iOS 11 以下的用户,请重写View部分,使用代码调用WKWebView,而不用使用故事版来加载wkwebview。

 

这个错误是苹果的兼容性的问题,与ios开发者无关。

 

 

=====

no accounts with itunes connect access

有时候打包上传的时候 会遇见  no accounts with itunes connect access 的报错

 

原因主要如下:

 

1. 你没有被开发者管理员加入 itunes connect 权限。要去找开发团队的leader  将你的appleid(区别于 app的  bundleid)加进去,不但要被 account  加入,还要被iTunes里面的 用户加入。

 

见图片

 

 

 

 

 

 

 并且下面给出个   离开队伍的  按钮。  注意  如果你离开这个team, 那么你就不会再有这个team相关的权限。

 

加完这个就可以 用自己的appid 登录xcode  真机调试  并打包了,但是还不能往商店传app。要想传app,还需要被 iTunes connect  添加。如下图

 

 

 

 

 需要管理员点击 用户和职能   将你的  appleid 加入进去  。

 

否则就会报错  : no accounts with itunes connect access

 

 出现下图,说明你已经有了上传app的权限

 

 

 

 

 以上两步当管理员把你添加后,苹果系统会给你发激活确认邮件,你同意之后就会成功加入team。

 

 

 

 

 

2.如果 还报错,通常解决方式如下:

 

      1.你的证书、描述文件在开发者中心有没有过期,在Xcode有没有配置好

 

        2.如果你此时要做的是提交App上架审核的操作,请你打开Xcode,按 command+逗号 检查你账号的身份,member,admin,还是agent,只有agent才有权限提交上架

 

      3.检查你的dns是否异常导致登录不上apple的官网

 

        4.按照以下顺序重启,当重启后无法解决便进行下一项重启:xcode  、  电脑。

 

 

 

 

 

推荐大家个朋友开的淘宝小店店, 欢迎光临

 

https://shop545764523.taobao.com/

 

 

 

 

 

=====

xcode 报错 malloc: *** error for object 0x6c3c5a4: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug------d

 

大家有时候会遇到这个错误

 

 malloc: *** error for object 0x******: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

 

先看下字面意思

 

对象0x****** 发生了错误:对一个已经被释放了的对象进行了不正确的校验。  你可能对已经被系统释放过的对象进行了修改。请设置一个 malloc_error_break 类型的断点来调试 这个错误

 

 

 

下面总结发生这个错误的常见情况:

 

1.使用了已释放的内存

 

2.数组越界

 

3.发生了资源抢占

 

具体待续。。。

 

 

 

 

 

 

 

推荐大家个朋友开的淘宝小店店, 欢迎光临

 

https://shop545764523.taobao.com/

 

 

 

======

xcode9 报错 “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift 

用xcode编译后会出现这个错误的情况:

 

1.使用cocopod导入第三方swift包后,swift的包是比较老的swift开发的。

 

2.用xcode9 打开老的swift(比如swift2.0)的工程的时候

 

解决方案如下:

 

在xcode中对应的targets下面的build settings 里面 设置swift的语言版本,就ok。建议设置成最新的swift语言版本。

 

如图

 

 

 

 

 

====

controller.tabBarItem.title = @"11111"不显示

场景: 

在xcode8.3下  今天在弄工程的时候,发现把之前工程中的tabbar控制器拿过来后,在控制器里面用 controller.tabBarItem.title = @"11111"不显示 

 

之前用着一直没问题

 

代码如下

 

===============================================

 

#pragma mark -

 

 - (void)viewDidLoad {

 

    [super viewDidLoad];

 

    

 

    [self addChildVc];

 

    

 

}

 

 

 

-(void)addChildVc

 

{

 

    OneViewController * infoVc = [[OneViewController alloc] init];

 

    [self addChildVc:infoVc withTitle:@"1" withImage:@"shuju_1" withSelectedImage:@"info"];

 

 }

 

 

 

 

 

-(void)addChildVc:(UIViewController *)controller withTitle:(NSString *)title withImage:(NSString *)image withSelectedImage:(NSString *)selectedImage

 

{

 

    // 设置子控制器的文字

 

//    controller.title = title; // 同时设置tabbar和navigationBar的文字

 

//    本工程不需要设置导航的标题,所以不用上一句

 

    controller.tabBarItem.title = title; // 设置tabbar的文字

 

//    controller.navigationItem.title = title; // 设置navigationBar的文字

 

    

 

    

 

#pragma mark 设置子控制器的 tabBarItem.image

 

    controller.tabBarItem.image = [UIImage imageNamed:image];

 

    

 

    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

 

    

 

 

 

#pragma mark 先给外面传进来的小控制器 包装 一个导航控制器

 

    ZNavigationController *nav = [[ZNavigationController alloc] initWithRootViewController:controller];

 

#pragma mark 添加为子控制器

 

    [self addChildViewController:nav];

 

    

 

}

 

===============================================

 

 

 

 

 

 

 

尝试了

 

controller.title = title;  和  

 

controller.navigationItem.title = title; 

 

 都可以在tab或者navi上显示相应的标题,唯独用    controller.tabBarItem.title = title; 显示不出来

 

挺奇怪

 

后来把

 

    [self addChildVc:infoVc withTitle:@"1" withImage:@"shuju_1" withSelectedImage:@"info"];

 

 里面的图片shuju_1和info真正加到工程里才可以了

 

xcode 等有的时候也有bug,比较怪。具体原因归结为xcode的。  有具体知道原因的欢迎评论

 

 

 

======

xcode9报错 Safe Area Layout Guide before iOS9.0 

运行工程的时候会遇到  Safe Area Layout Guide before iOS9.0

 

这是因为xcode9  storyboard的设置里面多了 个 Safe Area Layout Guide,而这个特性只针对ios9 以后的版本,所以如果工程兼容ios9以前的话,加上这个选项就会报错,需要把这个选项去掉,如图

 

 

 

 

 

===========

iOS Xcode 10: Multiple commands produce 

Xcode自动升级到10.0

 

1.编译的时候报错:
Multiple commands produce

 

解决办法:
File -> Workspace Setting -> build system: legacy build system

 

参考:
https://www.jianshu.com/p/8a8444acdca5

 

2.library not found for -lstdc++.6.0.9

 

这个需要将xcode9 中的相应库 拷贝到xcode10对应的目录下,注意真机路径 和 模拟器路径要一一对应,不要弄混淆了。

 

 

 

 

 

--------------------- 
参考:https://blog.csdn.net/xjh093/article/details/83060506 

 

 

=====

UICachedDeviceRGBColor CGImage]: unrecognized selector sent to instance 0xxxxxxxxxxx'

 

 

UICachedDeviceRGBColor CGImage]: unrecognized selector sent to instance 0xxxxxxxxxxx'

 

 

 

报错原因是

 

本来应该写空间的背景色:

 

textField.backgroundColor = [UIColor redColor];

 

但是如果你 没注意,直接写了 

textField.background = kColorRed;

 

就会报这个错误。

 

因为 

 

.background这个属性 的类型是  uiimage,而你却隔了它一个 rgb的颜色 所以有如此的提示。

 

 

 

 

=========

iOS项目运行出现:[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object

 说白了就是 字典初始化 的时候 放入空的值了 

下面这个比较具体

 

错误原因:

 

NSDictionary *dic = @{@"key":value}这个初始化方法,发现keys count和objcects的个数不匹配了, 一般是因为 NSArrayNSDictionary插入数据为空而造成的。

 

 

 

解决方法:

 

NSDictionary创建有两种方法,NSDictionary *dic =@{@"xxx":@"xxx"};或者NSDictionary *dic =[NSDictionary dictionaryWithObjectsAndKeys:@"xxx",@"xxx",nil];但是用第一种创建的dic里面的元素一定不能为空,否则就会崩溃。

 

在使用@{@”key”:value} 这种方式初始化的时候,一定要对value做是否为nil的判断,为nil就不要加入Dictionary。

 

NSDictionary dictionaryWithObjectsAndKeys:value1,@"v1",value2,@"v2", nil];使用这个初始化方法进行初始化,这样如果value为nil就不会加入字典,使用 objectForKey:取出来的对象就会为nil对象,不会引发崩溃。

原文:https://blog.csdn.net/yuhao309/article/details/80609823 

 

 

 

 

======

-[UITableView copyWithZone:]: unrecognized selector sent to instance 0x7XXXXXX00

-[UITableView copyWithZone:]: unrecognized selector sent to instance 0x7XXXXXX00

 

-[Class copyWithZone:]: unrecognized selector sent to instance 0x7XXXXXX00

 

出现这个错误的原因是,全局的属性的修饰词写错了,

 

比如一个view 本来应该用weak和strong 修饰,结果你写成了copy  那么就会出现这个错误

 

错误:

 

@property (nonatomic,copy) UITableView *tableView;     //tableView;

 

正确:

 

@property (nonatomic,strong) UITableView *tableView;     //tableView;

 

 

 

 

 

下面来自外国兄台的回答给大家个参考

 

Your -setObj1: method is declared as copy, so it calls -copy on your Class1 object. -copy just calls -copyWithZone:nil. So you either need to implement the NSCopying protocol (which means implementing -copyWithZone:), or change your property from copy to retain.

 

 

 

To make your class respond to copyWithZone:, you have to implement the NSCopying protocol in your class. And you must override the copyWithZone: method.

 

 

 

要实现自定义对象copy,需遵守NSCopying、NSMutableCopying协议,实现copyWithZone、mutableCopyWithZone 方法

 

 

 

更多关于copy请看

 

https://blog.csdn.net/qq_25639809/article/details/80048843

 

 

 

 

 

 

 

=====

CUICatalog: Invalid asset name supplied:

 

控制台打印这个

 

[framework] CUICatalog: Invalid asset name supplied: '(null)'

 

 

 

原因是 :

 

[UIImage imageNamed:@""]这个方法传入的照片名字为空,是无效资源名称

 

不改正对全局无影响

 

 

 

参考:

 

https://www.jianshu.com/p/7923d1aa3ba7

 

https://blog.csdn.net/qq_19979539/article/details/52493194

 

 

 

 

=====

 

ios 打包相关的那些报错

 

 

这张图片是因为打包bitcode的时候出现了失败,重新打包即可

 

 

 

 

 

这个是因为电脑容量不足导致的无法启动模拟器,这个经常发生在128g的电脑并且同时开启多个模拟器的情况下

 

 

 

 

 

 

打完包后,苹果会给你发邮件告诉你你的app下次提交的时候希望改正一些问题。 这种问题是过度性的问题,所以不会要求你立即改正,但是当过渡期结束后就会给你发强制修改的邮件了,如果不改的话上线就拒绝你。 我这个是因为苹果认为我再后台一直用手机的位置所以让我加一个info的配置。

 

 

 

 

 

 

这个是由app的配置文件缺少相关尺寸的icon 造成的。加上就好了。 我的是建立工程的时候误选择了 universal 所以让传ipad icon。 直接更改为 iphone 就搞定了

 

 

 

 

这个是因为 请求超时 网络不好造成的

 

 

 

 

 

 

这个也是与苹果的服务器和 网络不好有关,重启xcode不能解决的话就换网络

 

 

 

 

 

 

这个也是因为网络,可能也和本地空间不足有关

 

 

 

 

=======

最近在项目中遇到了

Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]

这个崩溃报错,并且真机调试 卡在了 mj_reloadData 那里,是苹果那些人跟 mj教授过不去么,是可忍孰不可忍,投诉,投诉,投诉!

 

在系统11上运行没问题, 系统10.3.3-iphone6-xcode9 报错.
解决办法
1 注释掉下面代码, 使用代理实现

tableView.sectionFooterHeight = 0.1;
tableView.sectionHeaderHeight = 0.1;
tableView.estimatedSectionHeaderHeight = 0.1;
tableView.estimatedSectionFooterHeight = 0.1;
2 或者把0.1 改成大于1的任意数都可以, 1.1 , 1.5
3 或者把0.1 改成0

 

 

有时候还会报错  section footer height must not be negative - provided height for section 0 is -0.000100

你明明在代理方法里面 设置了 正的值,但是它就偏偏给你说 你设置的是负值。

当iOS9或iOS8系统下使用func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat,如果return 值小于1会产生崩溃,iOS11和12则不会。

反正  这俩crash都是height在搞鬼,最初我们为了适应ios8、ios9. 给footer设置高度为0 系统不认,只好设置个0.00X 来。 但是随着新的版本的出现,这个0.00x要被废弃了。 而且我觉得 那个  tableView.estimatedSectionXXXHeight 也很鸡肋,基本用不到哦。

 

==============================

App上线-Unexpected CFBundleExecutable Key

 

解决方案:

按照提示,找到环信中的那个info.plist 删除里面的 executable 所在的 那一行就 ok

 

参考链接 https://www.cnblogs.com/StevenHuSir/p/UploadApp_CFBundleExecutableKey.html

 

 

'CALayer position contains NaN: [nan nan]'异常

 

异常一

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'

原因

计算高度,宽度,CGRectMake设置等中存在错误,看看是不是除0等操作了

 

异常二

CALayer position contains NaN: [187.5 nan]. Layer: <CALayer:0x281d9c0a0; position = CGPoint (100 100); bounds = CGRect (0 0; 200 200); delegate = <UIImageView: 0x101a8cc50; frame = (0 0; 200 200); gestureRecognizers = <NSArray: 0x2816f39c0>; layer = <CALayer: 0x281d9c0a0>>; opaque = YES; allowsGroupOpacity = YES; >

这种下面会有一串的 block_invoke错误,这时候不要在意这些细节,抓住主要矛盾,主要排查看看是否有四则运算没有考虑全作用域 即可


参考链接:https://www.jianshu.com/p/b1b8d8eab874

 

 

=======

ios 报错 Invalid row height provided by table delegate. Value must be at least 0.0, or UITableViewAutomaticDi......

Invalid row height provided by table delegate. Value must be at least 0.0, or UITableViewAutomaticDi

说明,row height 设置出问题了,不小心计算成了负值。 去 设置 rowHeight的代理方法里面找就行。

====

 

posted on 2015-08-22 11:26  &#127774;Bob  阅读(419)  评论(0编辑  收藏  举报

导航