【XCode7+iOS9】http网路连接请求、MKPinAnnotationView自定义图片和BitCode相关错误

简介:

更新了iOS9和XCode7,之后,Swift变成了2.0,有了新的语法习惯,iOS也加强了安全方面的限制。我们原本的项目就会出现不少问题。先来看我之前的项目中出现的3个错误吧和相关的解决办法吧。

1. HTTP网络请求错误。

因为iOS9默认使用HTTPS的链接方式,所以如果你的程序以前使用的是HTTP方式进行网络链接,那么更新了之后,你的程序可能不会有bug,但是当运行的时候,遇到访问HTTP的接口时,就会出现这样的错误提示:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
所以,解决的办法是在info.plist中添加进去新的项目:NSAppTransportSecurityNSAllowsArbitraryLoads


注意,NSAppTransportSecurity的类型是Dictionary,NSAllowsArbitraryLoads的类型是Boolean,另外NSAllowsArbitraryLoads一定要放置在NSAppTransportSecurity的二级目录之下。


2. 自定义地图Annotation的图标

在iOS9之前,我们基本上是偏向于使用MKPinAnnotationView的,因为MKPinAnnotationView如果设置了自定义的图片,就会显示之;如果不设置自定义的图片,就会默认显示大头针的样式。但是注意,到了iOS9,就不能使用MKPinAnnotationView这个类型了,因为它将不再支持自定义的图片,如果想要显示自定义的图片的话,必须使用MKAnnotationView这个类。

但是这里有个很尴尬的地方。比如你的工程里面,有部分地图上的点显示默认的大头针,有部分显示自定义的图片,需要在你的

mapView viewForAnnotation代理中返回两个不同类型的Annotation,例如下面我的工程中的代码(因为这个工程时间比较久,所以用的还是OC,swift的话基本类似):

static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";
[mapView dequeueReusableAnnotationViewWithIdentifier:BridgeAnnotationIdentifier];
if (level==0 || level == 1) {
            MKPinAnnotationView* PinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];
            PinView.pinColor = MKPinAnnotationColorRed;
            PinView.opaque=NO;
            PinView.canShowCallout = YES;
            return PinView;
}else if(level==2){
            MKAnnotationView* customView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];
            customView.canShowCallout = YES;
            customView.opaque=NO;
	......
            return customPinView;
        }


3. 最后来看一个新的错误关于BitCode

(null): URGENT: all bitcode will be dropped because '/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/foldername/appname/GoogleMobileAds.framework/GoogleMobileAds(GADSlot+AdEvents.o)' was built without bitcode. 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.

这个错误一般会出现在引入的第三方的框架中出现,是关于bitcode的。

Note: For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS apps, bitcode is required.

所以解决的办法也很简单,步骤如下(从Statckoverflow上传过来的):



注意一下,这个只有在Xcode7下面才有。

暂时就只遇到这3个问题,有新的问题,我会接着更新blog。

目录
相关文章
|
10天前
|
Java
java原生发送http请求
java原生发送http请求
|
17天前
|
网络协议 Linux iOS开发
推荐:实现RTSP/RTMP/HLS/HTTP协议的轻量级流媒体框架,支持大并发连接请求
推荐:实现RTSP/RTMP/HLS/HTTP协议的轻量级流媒体框架,支持大并发连接请求
38 1
|
1月前
|
编解码 测试技术 索引
性能工具之 Jmeter 使用 HTTP 请求编写 HLS 脚本
在我们简要介绍了 HLS 协议的基础知识,接下来我们详细介绍一种使用 Jmeter 编写压测 HLS 协议脚本的方法。
70 1
性能工具之 Jmeter 使用 HTTP 请求编写 HLS 脚本
|
1月前
|
JSON 数据格式
第三方系统或者工具通过 HTTP 请求发送给 ABAP 系统的数据,应该如何解析试读版
第三方系统或者工具通过 HTTP 请求发送给 ABAP 系统的数据,应该如何解析试读版
26 0
|
1月前
|
Java Spring
用spring发送http请求
用spring发送http请求
|
3天前
|
安全 网络安全 开发工具
对象存储oss使用问题之flutter使用http库进行post请求文件上传返回400如何解决
《对象存储OSS操作报错合集》精选了用户在使用阿里云对象存储服务(OSS)过程中出现的各种常见及疑难报错情况,包括但不限于权限问题、上传下载异常、Bucket配置错误、网络连接问题、跨域资源共享(CORS)设定错误、数据一致性问题以及API调用失败等场景。为用户降低故障排查时间,确保OSS服务的稳定运行与高效利用。
16 1
|
29天前
|
JSON 前端开发 数据格式
糊涂工具类真是场景下请求http接口的案例
糊涂工具类真是场景下请求http接口的案例
21 0
|
29天前
|
数据采集 缓存 前端开发
http和https请求服务器的时候在请求头部分都带什么到服务器呢?
HTTP和HTTPS请求头基本结构相似,HTTPS多了一层SSL/TLS加密。常见请求头如Accept(指定内容类型)、Authorization(身份验证)、Cookie(会话跟踪)、User-Agent(标识用户代理)等。HTTPS特有的头包括Upgrade-Insecure-Requests(升级到HTTPS)、Strict-Transport-Security(强制使用HTTPS)、Sec-Fetch-*(安全策略)和X-Content-Type-Options、X-Frame-Options等(增强安全性)。实际应用中,请求头会根据需求和安全策略变化。
20 0
|
30天前
|
网络协议 网络安全 API
Qt 网络编程之美:探索 URL、HTTP、服务发现与请求响应
Qt 网络编程之美:探索 URL、HTTP、服务发现与请求响应
43 1
|
1月前
|
域名解析 Kubernetes Linux
Kubernetes 外部 HTTP 请求到达 Pod 容器的全过程
Kubernetes 外部 HTTP 请求到达 Pod 容器的全过程
36 4