Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors #104

Closed
rwalt04 opened this issue Oct 5, 2017 · 5 comments
Closed

Errors #104

rwalt04 opened this issue Oct 5, 2017 · 5 comments

Comments

@rwalt04
Copy link

rwalt04 commented Oct 5, 2017

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
Copy link

lgryp commented Oct 6, 2017

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

@rwalt04
Copy link
Author

rwalt04 commented Oct 6, 2017 via email

@lgryp
Copy link

lgryp commented Oct 7, 2017

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
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants