简体   繁体   中英

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. After I converted all to swift3 step by step(error resolving). 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 :

Sometimes Compiler is not detecting all errors in Xcode8

So I started commenting one by one method/class in swift files

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

Many things we need to check if anyone facing above issue in Xcode8 Swift3 Please refer below syntax's

Thank you for the above comments which helps me to think about the issue

NSFetchRequest Before :

 //let fetchRequest = NSFetchRequest()

NSFetchRequest in Swift3:

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:

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

Dispatch Queues in Swift3 :

DispatchQueue.global().async {


        DispatchQueue.main.async {

        }

}

Swift3: CGRectMake to CGRect

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

CGPointMake to CGPoint

CGPoint(x:10,  y:20);

Selectors in Swift3:

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

func tapped(_ sender: UITapGestureRecognizer) {
}

Subscript in 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]
    }
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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