I receive a Compile Swift errors from sources:
A declaration cannot be both 'final' and 'dynamic'
I'm using Swift 3. I've been reading the Revision History
about 2016-09-13
and I found the Declarations
https://docs.swift.org/swift-book/RevisionHistory/RevisionHistory.html
https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#ID362
I'm new in Swift and I don't know what I did bad but I'm Google some solution.
The environment is below:
$ pod env
Stack
CocoaPods : 1.5.3
Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
RubyGems : 2.5.2.3
Host : Mac OS X 10.13.6 (17G65)
Xcode : 8.3 (8E162)
Git : git version 2.18.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ f1a1dd649b3c8e2655e760063549da3b953bb735
Installation Source
Executable Path: /usr/local/bin/pod
Plugins
cocoapods-clean : 0.0.1
cocoapods-deintegrate : 1.0.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.0
cocoapods-try : 1.1.0
Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '9.3'
# Uncomment this line if you're using Swift
use_frameworks!
target 'my-Project' do
pod 'Alamofire', '~> 4.0'
pod 'MBProgressHUD'
pod 'PromiseKit', '~> 4.0'
pod 'MBAutoGrowingTextView', '~> 0.1.0'
pod 'PusherSwift', '~> 3.0'
pod 'PopupDialog', '~> 0.4'
pod 'SwiftMessages', '3.5.1'
pod 'Bugsnag'
pod 'AutoCompleteTextField'
pod 'Fabric'
pod 'Crashlytics'
target 'my-ProjectTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
The screenshot of compile error is below:
I don't know what is the problem with this code:
import UIKit
class BaseAddPeopleButton: UIButton {
override var isHighlighted: Bool {
didSet {
backgroundColor = isHighlighted ? .defaultGreyBackgroundColor : .white
}
}
}
or this code:
import UIKit
class TableTableViewCell: UITableViewCell {
@IBOutlet weak private var tableView: UIView!
@IBOutlet weak private var tableNumberLabel: UILabel!
public var table : TableForDisplay? {
didSet {
reloadUI()
}
}
private func reloadUI() {
guard let table = table else { return }
tableNumberLabel.text = String((table.number))
tableView.layer.cornerRadius = 2
tableView.backgroundColor = table.sale != nil ? getOpenedTableColor() : .defaultGreenColor
backgroundColor = table.isActive ? .defaultGreyNavigationBarColor : .white
}
private func getOpenedTableColor() -> UIColor {
return table!.sale?.stateId == 5 ? .defaultBlueColor : .defaultRedColor
}
}
References: