iOS项目更新之升级Xcode7 & iOS9 & swift2.0

1 sizeWithAttributes 传参

错误的写法
let twoWordWidth = “差额:”.sizeWithAttributes(NSDictionary(object: Macro_Font_14, forKey: NSFontAttributeName) as [NSObject : AnyObject]).width

正确的写法

let twoWordWidth = “差额:”.sizeWithAttributes([NSFontAttributeName : Macro_Font_14]).width

2 ?还是!的问题

3 参数含#的问题
一个个根据提示修复

4 Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

提示信息太少,用命令行编译
xcodebuild -workspace -scheme

发现
Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
* BUILD FAILED *

The following build commands failed:
CompileSwift normal arm64 /Users/haidihan/项目/gitlab/EasyAccount_Iphone/EasyAccount/Base/CommonView/share/WXShareImpl.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

暂时注释掉此文件的代码

再次编译

ld: ‘/Users/haidihan/项目/gitlab/EasyAccount_Iphone/EasyAccount/Vendor/ARC/ShareSDK/MOBFoundation.framework/MOBFoundation’ does not contain 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. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Build Settings 搜索 bitcode 将Enable Bitcode更改为NO即可

编译成功

5 网络访问https的问题

如果接口还未实现https
其实只要在App的Info.plist里面加入如下信息就可以

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

6 网络是否可达Reachability的问题
SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0)) //此行总是报错

public class Reachability {
 class func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in() zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) zeroAddress.sin_family = sa_family_t(AF_INET) let defaultRouteReachability = withUnsafePointer(&zeroAddress) { SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0)) } var flags = SCNetworkReachabilityFlags.ConnectionAutomatic if !SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) { return false } let isReachable = (flags.rawValue & UInt32(kSCNetworkFlagsReachable)) != 0 let needsConnection = (flags.rawValue & UInt32(kSCNetworkFlagsConnectionRequired)) != 0 return (isReachable && !needsConnection) } }

参考:
1 iOS项目更新之升级Xcode7 & iOS9
http://www.tuicool.com/articles/FFbqmyr

2 xcode7报错:does not contain bitcode
http://blog.csdn.net/colin_smile/article/details/47973979

3 Xcode 7 beta发布,Swift 2.0带来哪些新变化?
http://www.csdn.net/article/2015-06-09/2824909-xcode-7-beta-and-swift/2

4 Check for internet conncetion in Swift 2 (iOS 9)
http://stackoverflow.com/questions/30743408/check-for-internet-conncetion-in-swift-2-ios-9

5 牛人分享IOS9适配,绝对解决你的所有问题

https://github.com/ChenYilong/iOS9AdaptationTips

你可能感兴趣的:(swift,崩溃,Xcode7,IOS9,项目升级)