Type 'Nsattributedstringkey' (Aka 'Nsstring') Has No Member 'Font'

Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'

Note: Ensure swift language version of your project. Here is how you can see/check your swift language version.

Sample Image


You have two options as solution to your query:

  1. If your project has Swift versio 4.0

    - You should choose/download POD compatible to your project's swift language (Share me POD info and swift version, so I can provide you exact pod version version for your pod library suitable for project).

  2. If your project has swift version below 4.0

    - You need to migrate your project into Swift 4.0 (if you've not migrated it). Here is ref question and answer, how to migrate from swift (below) <4.0 to 4.0.

    • Xcode 9 Swift Language Version (SWIFT_VERSION)


According to tag added by you in your question - Swift3 is your current project language version and pod 'Cosmos', '~> 12.0' is supporting swift 4.

pod 'Cosmos', '~> 12.0'

Here is list of previous release supporting Swift version below 4.0.

https://github.com/evgenyneu/Cosmos/releases

Try previous release of cosmos like:

pod 'Cosmos', '~> 11.0.3'
// or
pod 'Cosmos', '~> 11.0.1'
// or
pod 'Cosmos', '~> 11.0.0

'

Type 'CAGradientLayerType' (aka 'NSString') has no member 'conic'

Thanks to this answer looks like the issue was my swift language version (Target > Build Settings > Swift Language Version). It needs to be version 5 to use this syntax. Otherwise, I guess we would need to treat that property as a string, and set it to kCAGradientLayerConic.

Error setting 'foregroundColor' in macOS

Swift 3 doesn't use the new Swift 4 NSAttributeStringKey values.

Use NSForegroundColorAttributeName for the foreground color:

let placeHolderTitleString: NSAttributedString =
NSAttributedString(string: "Enter text here", attributes:
[NSForegroundColorAttributeName : NSColor.gray])

Type 'UIPageViewController.OptionsKey' (aka 'NSString') has no member 'interPageSpacing'

The syntax was different in Swift 4. Your current project might be in Swift 4.0. Change its swift version to 4.2 and above. Or use the below code

init(transitionStyle style: UIPageViewControllerTransitionStyle, 
navigationOrientation: UIPageViewControllerNavigationOrientation,
options: [String : Any]? = nil)

Swift 4.0

let vc = UIPageViewController(transitionStyle: .scroll,
navigationOrientation: .vertical,
options: [UIPageViewControllerOptionInterPageSpacingKey : 10])

Swift 4.2 and above

let vc = UIPageViewController(transitionStyle: .scroll, 
navigationOrientation: .vertical,
options: [UIPageViewController.OptionsKey.interPageSpacing : 10])

NSFontAttributeName vs NSAttributedStringKey.font

The projects are probably in different versions of Swift.

In Swift 4, NSFontAttributeName has been replaced with NSAttributedStringKey.font.

In Swift 5, NSFontAttributeName has been replaced with NSAttributedString.Key.font.

NSAttributedString has no member replacingOccurrences error

First:
A StringProtocol defined by apple documentation:

A type that can represent a string as a collection of characters.

Im assuming that the variable str25 is an NSAttributedString This is the cause of your error. Ensure that the variable you pass into replacingOccurrences(of:with:) is of Type String

Another route you could take is to convert your String into an NSMutableAttributedString, this object has a var mutableString: NSMutableString { get } property that

returns The mutable string object

Then you can use this in your replacingOccurrences(of:with:) method



Related Topics



Leave a reply



Submit