iOS--常见错误收集(持续更新)

作者: 黑白灰的绿i | 来源:发表于2016-11-10 16:31 被阅读0次

    平时遇到的错误我都会收集起来与大家分享,慢慢积攒中。。。

    一.

    问题:

    You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.

    原因:

    有第三方库不兼容

    解决:
    19181037_IMDA.jpg.png

    二.

    问题:

    App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.

    原因:

    新特性要求App内访问网络请求,要采用 HTTPS 协议。
    但是现在使用的是 HTTP 协议,使用私有加密方式保证数据安全。

    解决:
    210142462856430.png

    三.

    问题:
    78F10FCE-9E38-4906-AD59-3E22DDEB9CA9.png
    原因:

    需要验证应用程序证书是值得信赖的

    解决:

    设置->通用->描述文件->开发商应用->信任xxxxx

    四.

    问题.

    打包上传时出错
    ERROR ITMS-90535: "Unexpected CFBundleExecutable Key. The bundle at 'Payload/OnlineGuardPatrol.app/TencentOpenApi_IOS_Bundle.bundle' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue."

    原因:

    第三方的framework中不包含executable

    解决:

    找到第三方库的info.plist文件,删除箭头指向的一整行

    738721-20150930191130324-974302674.png

    五.

    问题.

    打包上传时出错
    ERROR ITMS-90207: "Invalid Bundle. The bundle at 'OnlineGuardPatrol.app' does not contain a bundle executable."

    原因.

    结合第四条,由于错误的删除了自己的info.plist文件中的对应行

    解决:

    重新添加对应行的键和值

    六.

    问题.

    打包上传时的错误

    1704A9A2-7DDD-47E9-B501-65C609F4AFB6.png

    原因.

    同时在xcode8和xcode7中编码,并且用xcode7打包上传

    解决.

    如下图


    168752AC-4EAB-42B5-AF6D-6D80FD9B09A7.png

    七.

    问题.

    运行报错:


    D282EA23-F458-4846-8EC3-A952949BBDA5.png

    原因.

    第三方库不包含bitcode

    解决.

    在Xcode 7中,我们新建一个iOS程序时,bitcode选项默认是设置为YES的。我们可以在”Build Settings”->”Enable Bitcode”选项中看到这个设置
    将Enable Bitcode默认的YES 选项改成NO 就行了

    八.

    问题.

    编译报错:

    duplicate symbol OBJC_METACLASS$_GTMBase64,duplicatesymbol

    原因.

    引用库重复定义

    解决.

    删掉 set building->other linker flag-> -all_load,就可以了

    九.

    错误.

    duplicate symbols for architecture armv7

    原因.

    1.有名字重复的文件
    2.在#import头文件的时候,不小心把.h写成了.m

    解决.

    找到,改过来就行了

    十.

    错误.

    This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes

    原因.

    在其他线程中更新UI引起

    解决.

    dispatch_async(dispatch_get_main_queue(), ^{});中更新UI

    十一.

    错误.

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 255

    原因.

    不太晓得,我是在xcode8上写了点代码,又在xcode7上编译,就报错了

    解决.

    clean项目,完全退出Xcode,再打开就好了

    十二.

    错误.

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'

    原因.

    这个错误前半句基本没用,种类多样,通过后半句我找到相应的地方,是因为我向数组中添加相同的数据导致

    解决.

    看着办就行

    十三.

    错误.

    The dependency **** is not used in any concrete target.

    原因.

    由于没有指定target,所以pods不知道把这些第三方用在哪里

    解决.

    按照这种格式书写:

    platform :ios, '8.0'
    #use_frameworks!个别需要用到它,比如reactiveCocoa
    
    target 'MyApp' do
      pod 'AFNetworking', '~> 2.6'
      pod 'ORStackView', '~> 3.0'
      pod 'SwiftyJSON', '~> 2.3'
    end
    

    十四.

    错误.

    [!] Invalid Podfile file: syntax error, unexpected end-of-input, expecting keyword_end.

    原因.

    Podfile文件结尾没有加end

    解决.

    加end呗。。。。。

    十五.

    错误.

    /usr/bin/git clone https://github.com/github/Mantle.git /var/folders/bq/h6x44ktn7ysgjl0t9gp645f40000gp/T/d20161224-3583-mr03ke --template= --single-branch --depth 1 --branch 2.0.7

    原因.

    系统中含有不止一个xcode

    解决.

    执行 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer (-switch 后面加上你的Xcode.app包内容里的Developer的文件夹路径即可)
    

    十六.

    错误.

    B52C9A7D-2E39-41DE-89E6-984AE3F6E977.png

    原因.

    本地Podfile文件上的第三方版本太低

    解决.

    执行命令pod update

    十七.

    错误.

    [__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x140534950

    原因.

    我在后台取出来数据,解析成字典之后取字典中的数据出现的,由于后台的疏忽,这并不是一个字典而是一个字符串,如图:

    592BF544-9284-4616-A44F-C40967F6664D.png

    红框代表数据是一个字符串,需要再次解析才可以使用

    解决

    再次解析,或者要求后台修改数据格式

    十八.

    错误.

    Invalid type in JSON write (NSConcreteMutableData)

    原因.

    我在上传数据的json体中直接放入了数组,数组中有不符合json规则的数据,如:自定义的类

    解决.

    NSData *data=[NSJSONSerialization dataWithJSONObject:muArray options:NSJSONWritingPrettyPrinted 
                                                                   error:nil];
    NSString *strs=[[NSString alloc] initWithData:data
                                         encoding:NSUTF8StringEncoding];
    

    此时将strs放入,完美。

    十九.

    错误.

    attempt to insert non-property list object

    原因.

    我用NSUserDefaults储存了一个字典,字典中含有"<null>"

    解决.

    将"<null>"改成""

    二十.

    问题.

    真机调试不打印日志

    原因.

    真机的系统是iOS10以上

    解决.

    21_467146_d145755f49bde09.png

    取消图中的选中。虽然在iOS10以上正常了,但是在iOS10以下会打印一些无效的东西,求解决!!!

    二十一.

    错误.

    ARC forbids Objective-C object in struct

    原因.

    ARC工程中用到非ARC库,其中有头文件定义struct中使用Object* o1,类似的对象指针。

    解决.

    在前面加上__unsafe_unretained

    二十二.

    错误.

    ERROR ITMS-90542: "Invalid CFBundleSupportedPlatforms value. The key 'CFBundleSupportedPlatforms' in the Info.plist file in bundle 'Payload/PgapIos.app/GoogleMaps.bundle' contains an invalid value '( "iPhoneSimulator" )'.

    原因.

    编译bundle的时候,是用模拟器来编译的

    解决.

    在编译bundle的时候选择真机

    二十三.

    错误

    ERROR ITMS-90683: "Missing Info.plist key. This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSHealthShareUsageDescription key with a string value explaining to the user how the app uses this data."

    原因.

    缺少健康权限请求信息,我只请求了写的权限,没有读的权限

    解决.

    //  写
     <key>NSHealthUpdateUsageDescription</key>
    <string>some string value stating the reason</string>
    //  读
      <key>NSHealthShareUsageDescription</key>
        <string>some string value stating the reason</string>
    

    二十四.

    错误.

    ld: library not found for -lPods-AFNetworking

    原因.

    不明

    解决.

    设置 Project -> Pods 下所有第三方库的 Build Active Architecture OnlyNO

    二十五.

    错误.

    终端执行pod install的时候

    [!] Unable to add a source with url https://github.com/CocoaPods/Specs.git named master.
    You can try adding it manually in ~/.cocoapods/repos or via pod repo add.

    原因.

    不明

    解决.

    执行
    pod repo add master https://github.com/CocoaPods/Specs.git
    然后根据提示执行pod setup
    如果出现[!] The `master` repo is not a git repo.
    进入/users/你的用户名/.cocoapods/repos,删除master文件夹
    然后继续执行pod setup
    如果安装了多个xcode,出现错误,上面第十五条有解决方案。

    二十六.

    错误.

    as an NSUserDefaults/CFPreferences value for key sadminLOCATION_POINT_DIC

    原因.

    向NSUserDefaults中存数据时,值为空或者不符合规则

    解决.

    。。。。

    二十七.

    错误

    Error Domain=NSCocoaErrorDomain Code=3840

    原因

    解析json数据时出现无法解析的特殊符号

    解决

    找到AFNetworking包中AFURLResponseSerialization.m文件,大概在第250行左右添加如下过滤方法:
    BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]];
    if (data.length > 0 && !isSpace) {
         NSString* sInvalid = [NSString stringWithUTF8String:[data bytes]];  
         // 从服务器收到的类似上一行的数据
         NSData *dataa = [[sInvalid stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\\r\\n"] dataUsingEncoding:NSUTF8StringEncoding];
         responseObject = [NSJSONSerialization JSONObjectWithData:dataa options:self.readingOptions error:&serializationError];
    } else {
         return nil;
    }
    

    二十八.

    错误

    The default interactive shell is now zsh.
    To update your account to use zsh, please run chsh -s /bin/zsh.

    原因

    升级mac导致

    解决

    chsh -s /bin/zsh
    

    二十九.

    错误

    zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory

    原因

    升级mac导致

    解决

    升级pods

    sudo gem update --system
    sudo gem install cocoapods -n/usr/local/bin
    

    三十.

    错误

    [!] CDN: trunk Repo update failed - 17 error(s):
    CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/1/d/4/CocoaAsyncSocket/0.0.1/CocoaAsyncSocket.podspec.json, error: Operation timed out - SSL_connect
    ...

    解决

    source 'https://github.com/CocoaPods/Specs.git'
    
                     ####持续更新

    相关文章

      网友评论

        本文标题:iOS--常见错误收集(持续更新)

        本文链接:https://www.haomeiwen.com/subject/qmsruttx.html