NMAC427 / SwiftOCR

Fast and simple OCR library written in Swift
Apache License 2.0
4.61k stars 481 forks source link

Errors #104

Closed rwalt04 closed 6 years ago

rwalt04 commented 6 years ago

I get these errors when trying run the build.

Cannot invoke 'draw' with an argument list of type '(in: CGRect, withAttributes: [NSAttributedStringKey : Any])’

NSString(string: code).draw(in: CGRect(origin: CGPoint(x: 0 + randomFloat(5), y: -15.5 + randomFloat(5)), size: randomImg.size), withAttributes: randomFontAttributes())

Type 'NSString' has no member 'font' return [.font: randomFont(), .kern: CGFloat(8) as NSObject, .foregroundColor: OCRColor(red: 27/255 + randomFloat(0.2), green: 16/255 + randomFloat(0.2), blue: 16/255 + randomFloat(0.2), alpha: 80/100 + randomFloat(0.2)), .paragraphStyle: paragraphStyle] }

lgryp commented 6 years ago

I'm having the same issue. Is it related to Swift 4 or IOS 11?

rwalt04 commented 6 years ago

Both I can’t figure away around

On Friday, October 6, 2017, lgryp notifications@github.com wrote:

I'm having the same issue. Is it related to Swift 4 or IOS 11?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/garnele007/SwiftOCR/issues/104#issuecomment-334832621, or mute the thread https://github.com/notifications/unsubscribe-auth/AV36ON0qfsMSZxv-sxVfNnogz78TxiA9ks5spm9rgaJpZM4Pvu2A .

lgryp commented 6 years ago

I solved the issue by selecting Swift 4.0 syntax in the xcode build settings of my project. Before, it was on Swift 3.2.

ColdLogical commented 6 years ago

For anyone who had a tough time finding this:

  1. Click your project file
  2. Click your target
  3. Click Build Settings
  4. Search Swift Language Version
  5. Change to Swift 4.0
frakman1 commented 6 years ago

I don't have the option to switch Swift versions. My XCode 8.3.3 only supports up to Swift 3.

image

My error is slightly different: in SwiftOCRTraining.swift:

image

SwiftOCRTraining.swift:92:42: Use of undeclared type 'NSAttributedStringKey'

I tried changing it to NSFontAttributeName but I get the same error.