简体   繁体   English

Xcode8:为什么 Xcode8 在转换为 Swift3 语法后没有构建/编译

[英]Xcode8 : Why Xcode8 is not building/compiling after converting to Swift3 syntax's

I just ran my project in Xcode8 it asked me to convert to swift3 syntax's so I did it, Obviously there are many errors those errors I am fixing from 2 days.我刚刚在 Xcode8 中运行了我的项目,它要求我转换为 swift3 语法,所以我做到了,显然有很多错误我在 2 天内修复了这些错误。 After I converted all to swift3 step by step(error resolving).在我一步一步将所有转换为 swift3 之后(错误解决)。 But when I build it is not even ran once either in device or simulator.但是当我构建它时,它甚至没有在设备或模拟器中运行一次。

Why it is not moving further ?为什么它没有进一步发展?

It is not even throwing any errors to fix any(checked all again and again)它甚至没有抛出任何错误来修复任何错误(一次又一次地检查)

I am worried.我很担心。 Is there anything I need to check in build settings or in code ?我需要在构建设置或代码中检查什么吗?

Please refer below image请参考下图

在此处输入图片说明

Warnings:警告:

在此处输入图片说明

Xcode8 Compiler Bug : Xcode8 编译器错误:

Sometimes Compiler is not detecting all errors in Xcode8有时编译器没有检测到 Xcode8 中的所有错误

So I started commenting one by one method/class in swift files所以我开始在 swift 文件中一一注释方法/类

There i found one method is troubling compiler which has not updated to swift3 syntax's after that i changed those syntax's then it ran successfully我发现一种方法是令人不安的编译器,在我更改了这些语法之后它没有更新为 swift3 语法,然后它成功运行

Many things we need to check if anyone facing above issue in Xcode8 Swift3 Please refer below syntax's我们需要检查是否有人在 Xcode8 Swift3 中遇到上述问题,请参考以下语法

Thank you for the above comments which helps me to think about the issue感谢您的上述意见,这有助于我思考这个问题

NSFetchRequest Before : NSFetchRequest 之前:

 //let fetchRequest = NSFetchRequest()

NSFetchRequest in Swift3: Swift3 中的 NSFetchRequest:

let fetchRequest = NSFetchRequest<Sample>(entityName: "Sample")

Note: **All delegate methods please re - write注意:**所有委托方法请重写


Declaring a method with parameters - no change but in calling this method声明带有参数的方法 - 没有变化,但调用此方法

func getPageThumbnail(upc:String, pagenum:Int)-> UIImage
 {

 }

Before:前:

if let xImage = GF.getPageThumbnail(self.upcLabel.text!, pagenum: 3) as UIImage?

Now in Swift3:现在在 Swift3 中:

if let xImage = GF.getPageThumbnail(upc:self.upcLabel.text!, pagenum: 3) as UIImage?

Dispatch Queues in Swift3 : Swift3 中的调度队列:

DispatchQueue.global().async {


        DispatchQueue.main.async {

        }

}

Swift3: CGRectMake to CGRect Swift3:CGRectMake 到 CGRect

CGRect(x:0, y:0, width:80, height:80)

CGPointMake to CGPoint CGPointMake 到 CGPoint

CGPoint(x:10,  y:20);

Selectors in Swift3: Swift3 中的选择器:

let myTapGesture = UITapGestureRecognizer(target: self, action: #selector(tapped(_:)) )

func tapped(_ sender: UITapGestureRecognizer) {
}

Subscript in Swift3 Swift3 中的下标

extension String {


//   right(x) and left(x) function to get substring
func right(i: Int) -> String?
{
    return self[self.length-i ... self.length-1 ]
}


func left(i: Int) -> String?
{
    return self[0 ... i-1]
}



subscript (i: Int) -> Character {
    return self[self.characters.index(self.startIndex, offsetBy: i)]
}

subscript (i: Int) -> String {
    return String(self[i] as Character)
}

//added  swift3 replacement
subscript (r: CountableClosedRange<Int>) -> String {
    get {
        let startIndex =  self.index(self.startIndex, offsetBy: r.lowerBound)
        let endIndex = self.index(startIndex, offsetBy: r.upperBound - r.lowerBound)
        return self[startIndex...endIndex]
    }
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM