Xcode报错解决办法汇总

1. An App ID with Identifier 'com.XXX.XXX’ is not available. Please enter a different string.
宗旨:移除钥匙串中的开发证书,重新导入

  1. 完全关闭Xcode;
  2. 找到钥匙串,将钥匙串(Keychain)中的对应证书移除;
  3. 再次打开Xcode,通过 Preferences - View Details - download 新的证书;
  4. 选择正确的appID,运行项目。

2. The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
解决方法1:

  1. 在Info.plist中添加NSAppTransportSecurity类型Dictionary。
  2. 在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
  3. 注意,单元测试下面也有一个Info.plist,修改那个文件是没有作用的!
    解决方法2:
    让有的域名支持https的话也可以这么配置:
      
/*
        
        NSAllowsArbitraryLoads
        
*/
        NSExceptionDomains
        
            
            qq.com
            
                
                NSIncludesSubdomains
                
                NSTemporaryExceptionAllowsInsecureHTTPLoads
                
                NSTemporaryExceptionMinimumTLSVersion
                TLSv1.1
            
            sina.com.cn
            
                NSIncludesSubdomains
                
                
                NSTemporaryExceptionAllowsInsecureHTTPLoads
                
                
                NSTemporaryExceptionMinimumTLSVersion
                TLSv1.1
            
        
      ```

**3. “Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”
**
解决:命令行分别输入下面语句,删除所有的Profiles
cd ~/Library/MobileDevice/Provisioning\ Profiles/
rm *.mobileprovision

**4. Please verify that your device’s clock is properly set, and that your signing certificate is not expired**
1) 关闭项目,找到项目文件XXXX.xcodeproj,在文件上点击右键,选择“显示包内容”(Show Package Contents)。会新打开一个Finder。
2) 在新打开的Finder中找到project.pbxproj,并且打开,找到所有包含报错的UUID‘XXX’的行(包含UUID后面的一串数字的行,可能不包含"UUID"),整行删除。
3) 保存,重新启动项目,再编译,就OK了。

**5. @2x与@3x图片无法提交SVN**
原因:add a "@" character at the end of all "@2x" files while checking in and your problem with subversion will be solved.
in other words, "svn add [email protected]@" (where blahblah is the true name of the Retina high rez image files) at the terminal and then explicitly commit that. In other words, don't add these files from Xcode, use the command line in the Terminal.
Subversion can have troubles with files with "@" in the filename.
命令行解决步骤:
svn add image_file_name\@3x.png@
svn commit -m “add your comment here"

**6. CodeSign error: no provisioning profile at path '/Users/zhht-2015/Library/MobileDevice/Provisioning Profiles/79693141-f98b-4ac4-8bb4-476c9475f265.mobileprovision'**
1) 关闭Xcode,找到项目中的**.xcodeproj文件,点击右键,show package contents(打开包内容)。
2) 打开后找到project.pbxproj文件,用文本编辑器打开。其实就是右键,点击open就好了。
3) 打开这个文件后,按command+F,在这个文件中查找“PROVISIONING_PROFILE",找到这个“
PROVISIONING_PROFILE = "79693141-f98b-4ac4-8bb4-476c9475f265";
并删除。
4) 然后保存文件,重新打开项目。xcode会提示你重新下载安装provisioning profile文件。下载后安装上就可以。

下面的是我重启Xcode后自动默认的,之前的设置都被重置了,也正是这个问题导致我做APNS推送时注册deviceToken成功和失败的函数都不回调,要么就是注册成功了发送消息成功了但是接收不到。我按照默认设置重新运行后推送测试可以了。

![1396780-b8f1bd80002b3e6b.png](http://upload-images.jianshu.io/upload_images/1396780-7a5e3ce2ceacdf66.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

好消息是:Xcode 8 代码签名可以自动管理或使用自定义设置 ,当Xcode 8代你处理代码签名的时候,你可以具体地看到执行了什么检查,还有Xcode8做了什么来修复它识别出来的问题。

**7. [NSBundle mainBundle] pathForResource: ofType: 为nil**
资源没有真正添加到bundle中,需要在项目设置中,build phases —> copy bundle resources 点击 + 重新添加即可。

**8.  The 'Apple Push Notification' feature is only available to users enrolled in Apple Developer Program. Please visit  https://developer.apple.com/programs/ to enroll.**
解决步骤:
情况一:如果是使用 Xcode7 以后的无证书真机编译调试,只需将项目中推送开关(Capabilities - Push Notifications)关掉即可,如果找不到推送开关,参考情况二解决。
情况二:
1. 在projectName.xcodeproj文件上右键“显示包内容”,用文本编辑器打开“project.pbxproj"文件
2. 查找:
com.apple.Push = {
enabled = 1;
};
修改为:
com.apple.Push = {
enabled = 0;
};
3. 在 build settings 里搜索 Code signing Entitlements,把后面的路径清空
4. 重新编译

你可能感兴趣的:(Xcode报错解决办法汇总)