Eureka: Error compiling latest Eureka

Created on 2 Oct 2017  路  14Comments  路  Source: xmartlabs/Eureka

pod 'Eureka', :git => 'https://github.com/xmartlabs/Eureka.git'

Compiling results in

/.../Pods/Eureka/Source/Rows/Common/FieldRow.swift:233:104: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'
Xcode9-Swift4 swift 4 issue

Most helpful comment

Hi @AAverin the same thing happens to me using Eureka 4.0 and Xcode 9.0.

I tried to change the line 233 in the FieldRow file as mentioned @antonioallen, but then I found that this was not necessary.
I just need to go to Eureka's target an changed the Swift Language Version to Swift 4.0.

In the case that you are using others libraries, you can add in your Podfile all your targets that used Swift 4 and the next time that you run pod install all those pods will be compiled in Swift 4.

Add this code in Podfile:

post_install do |installer|
        # Your list of targets here.
    myTargets = ['Eureka']

    installer.pods_project.targets.each do |target|
        if myTargets.include? target.name
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.0'
            end
        end
    end
end

The solution has been found here.
I hope this helps you!

All 14 comments

@AAverin Please follow contributing guidelines

Before submitting issues ...

  • Make sure you are using Eureka latest release or master branch version.
  • Make sure your Xcode version is the latest stable one.

  • Environment: Eureka master branch, Xcode 9 and iOS 11 version you are using.

Swift Compiler error:
/.../Pods/Eureka/Source/Rows/Common/FieldRow.swift:233:104: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

@mtnbarreto anything else I should add?
My new comment doesn't differ much from the first one on the issue

@AAverin You need to convert your code to Swift 4 for it to work.

@Kishimotovn that would be difficult.
I am using Google Maps SDK, that doesn't seem to support Swift 4 just yet.
And other libraries didn't yet convert to Swift 4.
How can I get latest Eureka fixes with Swift 3.2?

A target written in Swift 4 can depend on a target that鈥檚 written in Swift 3, and vice versa

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Compatibility.html

Ok, so I played around a bit more, and now the state is like in #1258

@AAverin well NSAttributedStringKey doesnt have that member in Swift 3 I dont think, so that's why the error

What seem to have worked for me now.

  1. point Eureka to master pod 'Eureka', :git => 'https://github.com/xmartlabs/Eureka.git', :branch => 'master'
  2. Got to Pods in Xcode, find Eureka and force it be built with Swift 4.0

there was an issue. Please try using Eureka 4.0.1
Sorry for any inconvenience caused.

Hello I just downloaded the 4.0.1 version and Still this issue is present.

Hi @StriderHND, for the time being, I've unlocked the pod file and replace line 233 in FieldRow to the following:
textField.attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSForegroundColorAttributeName: color])

Adding NSForegroundColorAttributeName instead of NSAttributedStringKey.foregroundColor seemed to fixed the issue. I hope this helps!

Hi @AAverin the same thing happens to me using Eureka 4.0 and Xcode 9.0.

I tried to change the line 233 in the FieldRow file as mentioned @antonioallen, but then I found that this was not necessary.
I just need to go to Eureka's target an changed the Swift Language Version to Swift 4.0.

In the case that you are using others libraries, you can add in your Podfile all your targets that used Swift 4 and the next time that you run pod install all those pods will be compiled in Swift 4.

Add this code in Podfile:

post_install do |installer|
        # Your list of targets here.
    myTargets = ['Eureka']

    installer.pods_project.targets.each do |target|
        if myTargets.include? target.name
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.0'
            end
        end
    end
end

The solution has been found here.
I hope this helps you!

Finally I got the solution:

target 'EurekaToDo' do
  use_frameworks!
  pod 'Eureka', '~> 4.0.0'
  pod 'ImageRow', '~> 3.0'
end

post_install do |installer|
    installer.pods_project.targets.each do |target|

        if  target.name == 'Eureka'
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.0'
            end
        end
    end
end

Xcode 9.2
Swift 4

Was this page helpful?
0 / 5 - 0 ratings