Material: Help ~ 馃槀馃檹 ~ Swift 4 Support

Created on 6 Jun 2017  路  8Comments  路  Source: CosmicMind/Material

pod 'Material'
xcode 9(Version 9.0 beta (9M136h))

Module compiled with Swift 3.1 cannot be imported in Swift 4.0: /Users/xxx/Library/Developer/Xcode/DerivedData/XXQrcode-ecjlrkexvbbkdodejchzeabjtuce/Build/Products/Debug-iphonesimulator/Material/Material.framework/Modules/Material.swiftmodule/x86_64.swiftmodule
enhancement feature request

Most helpful comment

So, according to the Swift Migration Guide https://swift.org/migration-guide/ as long as you compile the cocoapods in Swift 3.2 (not 3.1) you should be able to use them in Swift 4. When I do that though, I still get two compilation errors in the Material library.

One was in Font.swift where font was optional (force-unwrapping here was the quick-fix)

var error: Unmanaged<CFError>?
        if !CTFontManagerRegisterGraphicsFont(font!, &error) {

The other one was in TextStorage.swift where the initializer needed to be marked as required

    /// Initializer.
    public required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

Making these two small changes made the library compile.

I am still confused however because the rest of the pods compiled fine so I am not sure the difference.

All 8 comments

I am currently working on Material 3. I will have Swift 4.0 in there. It will take a few days to get it going, so until then I will keep this up :)

Thank you very much!

So, according to the Swift Migration Guide https://swift.org/migration-guide/ as long as you compile the cocoapods in Swift 3.2 (not 3.1) you should be able to use them in Swift 4. When I do that though, I still get two compilation errors in the Material library.

One was in Font.swift where font was optional (force-unwrapping here was the quick-fix)

var error: Unmanaged<CFError>?
        if !CTFontManagerRegisterGraphicsFont(font!, &error) {

The other one was in TextStorage.swift where the initializer needed to be marked as required

    /// Initializer.
    public required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

Making these two small changes made the library compile.

I am still confused however because the rest of the pods compiled fine so I am not sure the difference.

@Rdxer Follow the steps you should be sweet

image

Just curious around when Material 3 is scheduled to release?

@ssrballin Good question. I am not setting a date, but I am already working on it, making small releases in the 2.* branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ijameelkhan picture ijameelkhan  路  23Comments

mohpor picture mohpor  路  43Comments

karstengresch picture karstengresch  路  15Comments

timoschwarzer picture timoschwarzer  路  19Comments

timoschwarzer picture timoschwarzer  路  16Comments