The application could not be verified.
删除之前在设备上安装的app就好了,估计问题应该是上一次的证书跟现在的证书不一致导致。
解决:上传application loader
ld: file not found: /Users/chenweidong/Library/Developer/Xcode/DerivedData/.......
改Build Setting中改一下项目名字就好了
原因:项目名不同造成的Build Setting----》Product Name---
全局音频正在播放时,如果退出了当前的界面后会崩溃,检查是否是delegate未设置为nil。
No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “CU4JMP378W” were found CodeSign error: code signing is required for product type 'Unit Test Bundle' in SDK 'iOS 8.3’
解决方法:分别点击上图中三个图标(targets、project),修改Build Settings中的Code Signing(其中Code Signing Identity修改为自己的证书,Provisioning Profile修改成ForAnyIdPublish)
openssl rsa.h file not found
官方文档说需要 对“Header Search Paths”增加头文件路径:(SRCROOT)/项目名称/公共类/工具&第三方/支付宝SDK,问题就解决了
再反过来看官方的demo,原来他们把openssl这个文件放到了项目根目录下,所以“Header Search Paths”只需要设置$(SRCROOT)/项目名称
libxml/tree.h file not found解决方法
导入libxml2.dylib包
设置Header search Paths 的 /usr/include/libxml2
第三方升级后,遇到以下问题 首先考虑.a文件是否需要更新
升级Xcode7后,模拟器无法连接网络
在info.plist中添加以下字段
当第三方执行成功但是不走AppDelegate的回调方法时,检查以下三个方法是否写全
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{}
双击UISearchBar会因为导航栏移动而消失
[self setExtendedLayoutIncludesOpaqueBars:YES];
当对观察者进行移除时,如果当前未添加观察者会导致崩溃,将移除代码放在try、catch中执行可以解决
@try {
[observer removeObserver:self forKeyPath:@"status"];
}
@catch (NSException *exception) {
NSLog(@"移除KVO--%@",exception);
}
解决视图层级查看界面无法加载
// 解决视图查看器不可见,错误警告:
// Assertion failure in -[UITextView _firstBaselineOffsetFromTop]
// 可尝试在.h文件中输入以下代码
@implementation UITextView (Category)
- (void)_firstBaselineOffsetFromTop{
}
- (void)_baselineOffsetFromBottom{
}
@end
当设置了键盘弹出通知,如果弹出的是第三方键盘,这样通知会调三次
/**
键盘即将弹出
*/
- (void)keyboardWillShow:(NSNotification *)notification
{
NSDictionary *info = [notification userInfo];
CGRect begin = [[info objectForKey:@"UIKeyboardFrameBeginUserInfoKey"] CGRectValue];
CGRect end = [[info objectForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
/*! 第三方键盘回调三次问题,监听仅执行最后一次 */
if(begin.size.height > 0 && (begin.origin.y - end.origin.y > 0))
{
// 逻辑实现
}
}
在命令行中执行pod之后报出[!] You need at least git version 1.8.5 to use CocoaPods。
1.git没安装,因为xcode下载完没有打开过,xcode自带git环境吧,双击点开自己的xcode即可,让它安装.
Cannot find interface declaration for "A'', superclass of ''B"
如果出现该错误,先确认是不是出现了交叉引用。
WKWebView加载网页后,对选择项进行长按会弹出框
长按弹框// 禁止长按弹出框
NSString*css = @"body{-webkit-user-select:none;-webkit-user-drag:none;}";
//css 选中样式取消
NSMutableString*javascript = [NSMutableString string];
[javascript appendString:@"var style = document.createElement('style');"];
[javascript appendString:@"style.type = 'text/css';"];
[javascript appendFormat:@"var cssContent = document.createTextNode('%@');", css];
[javascript appendString:@"style.appendChild(cssContent);"];
[javascript appendString:@"document.body.appendChild(style);"];
[javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
[javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
//javascript 注入
WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:javascript
injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
forMainFrameOnly:YES];
WKUserContentController*userContentController = [[WKUserContentController alloc] init];
[userContentController addUserScript:noneSelectScript];
WKWebViewConfiguration*configuration = [[WKWebViewConfiguration alloc] init];
configuration.userContentController = userContentController;
//控件加载
[_webView.configuration.userContentController addUserScript:noneSelectScript];
CocoaPods 问题汇总
一、出现Unable to find a pod with name, author, summary, or description matching 'FrameName' 解决方法
错误例图-
执行pod setup其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令:终端输入:pod setup
会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。
如果pod search操作还是搜索失败,例如终端输入:pod search AFNetworking -
删除~/Library/Caches/CocoaPods目录下的search_index.json文件
pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
终端输入:rm ~/Library/Caches/CocoaPods/search_index.json,删除成功后,再执行pod search。 -
执行pod search
终端输入:pod search afnetworking(不区分大小写)
输出:Creating search index for spec repo ‘master’.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。
Xcode导入头文件自动补齐
使用了一段时间CocoaPods来管理Objective-c的类库,方便了不少。但是有一个小问题,当我在xcode输入import关键字的时候,没有自动联想补齐代码的功能,需要手工敲全了文件名,难以适应。
简单说就是这么几步:
- 选择Target -> Build Settings 菜单,找到\”User Header Search Paths\”设置项
- 新增一个值"${SRCROOT}",并且选择\”Recursive\”,这样xcode就会在项目目录中递归搜索文件
路径错误
Xcode发生以下错误提示时:
Build setting TARGET_BUILD_DIR undefined
Build setting BUILT_PRODUCTS_DIR undefined
解决方法
- 在
Build settings
中搜索configuration Build Products Path
- debug输入
$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
release输入$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
方法弃用警告屏蔽
若在程序中弹出以下图例警告
图例
可在Targets->Build Settings->Apple LLVM 9.0 - Warnings - All languages -> Unguarded availability 中 设置为 Yes
图例
NSUrlSession NSUrlConnection https连接时证书无效的解决办法
错误描述:
The certificate for this server is invalid. You might be connecting to a server that is pretending to be “wxpay.wxutil.com” which could put your confidential information at risk.
func sendPayRequest() {
// 1.创建会话对象
let session: URLSession = URLSession.init(configuration: .default, delegate: self, delegateQueue: nil)
//2.根据会话对象创建task
let urlstr = "https://wxpay.wxutil.com/pub_v2/app/app_pay.php?plat=ios"
let urls: NSURL = NSURL(string: urlstr)!
//3.创建可变的请求对象
let request: NSMutableURLRequest = NSMutableURLRequest(url: urls as URL)
//4.修改请求方法为POST
request.httpMethod = "POST"
//5.设置请求体-------可以不设置,有默认的
// request.httpBody = "".data(using: String.Encoding.utf8)
//request.HTTPBody ="username=520it&pwd=520it&type=JSON".data(using: String.Encoding.utf8)
//6.根据会话对象创建一个Task(发送请求)
/*
第一个参数:请求对象
第二个参数:completionHandler回调(请求完成【成功|失败】的回调)
data:响应体信息(期望的数据)
response:响应头信息,主要是对服务器端的描述
error:错误信息,如果请求失败,则error有值
*/
let dataTask: URLSessionDataTask = session.dataTask(with: request as URLRequest) { (data, response, error) in
if(error == nil){
//(此处返回的数据是JSON格式的,因此使用NSJSONSerialization进行反序列化处理)
do {
let dict = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.allowFragments)
print(dict)
} catch {
}
}
}
//.执行任务
dataTask.resume()
}
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
var disposition = URLSession.AuthChallengeDisposition.performDefaultHandling
var credential: URLCredential!
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust &&
challenge.protectionSpace.host.hasSuffix("wxpay.wxutil.com"){
credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
if credential != nil {
disposition = URLSession.AuthChallengeDisposition.useCredential
} else {
disposition = URLSession.AuthChallengeDisposition.performDefaultHandling;
}
} else {
disposition = URLSession.AuthChallengeDisposition.performDefaultHandling;
}
if completionHandler != nil {
completionHandler(disposition, credential)
}
}
网友评论