简体   繁体   English

由于“内部”保护级别为swift 4,因此无法访问扩展初始化程序

[英]Extension initializer is inaccessible due to 'internal' protection level swift 4

I have a convenience initializer in an extension inside my framework. 我在框架内的扩展中有一个便捷的初始化程序。 And I want to use it in another extension in my project. 我想在项目的另一个扩展中使用它。 It granted public access to everything I could but the compiler keeps saying "initializer is inaccessible due to 'internal' protection level"... 它授予了我可以访问的所有内容的公共访问权限,但是编译器不断说“由于'内部'保护级别而无法访问初始化程序”。

Here is my extension in framework: 这是我在框架中的扩展:

public extension UIColor {
    public convenience init(hex: Int) {
        self.init(red:(hex >> 16) & 0xff, green:(hex >> 8) & 0xff, blue:hex & 0xff)
    }
}

and here is my extension in my project: 这是我的项目扩展名:

import myFramework

extension UIColor {
    class var backgroundGrey: UIColor {
        return UIColor(hex: 0xe3e8eb)
    }
}

The error is when I call UIColor(hex). 错误是当我调用UIColor(hex)时。

Do you know what's wrong here ? 你知道这是怎么回事吗?

Edit: I added the framework import 编辑:我添加了框架导入

Generally the answer here is to clean the project. 通常,这里的答案是清理项目。 If that doesn't work, delete DerivedData. 如果这样不起作用,请删除DerivedData。 If that doesn't work, then start simplifying the project to just do this one thing (import the framework and access the extension), because you have something else in the project interfering. 如果那不起作用,请开始简化项目以仅做一件事(导入框架并访问扩展),因为项目中还有其他干扰。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于“内部”保护级别,无法访问初始化程序-Swift 4 iOS - initializer is inaccessible due to 'internal' protection level - Swift 4 iOS 由于“内部”保护级别 swift 3 而无法访问 - inaccessible due to 'internal' protection level swift 3 由于“内部”保护级别,无法访问 phoneFieldChanged' - phoneFieldChanged' is inaccessible due to 'internal' protection level 如何使用diffrence模块编写测试? 由于“内部”保护级别,初始化程序无法访问 - How to write Test with diffrence module ? i got initializer is inaccessible due to 'internal' protection level 由于“私有”级别的保护,无法访问“ restoreProgress”-Swift - 'restoreProgress' is inaccessible due to 'private' level protection - swift Swift-由于具有'fileprivate'保护级别,无法访问'textFields' - Swift - 'textFields' is inaccessible due to 'fileprivate' protection level 由于“内部”保护级别,初始化程序不可访问 - Initializer is inaccessable due to 'internal' protection level 框架中的单例错误:由于“私有”保护级别,无法访问初始化程序 - singleton in framework with error: initializer is inaccessible due to 'private' protection level iOS-由于“内部”保护级别,无法访问“ val”(来自我的pod) - iOS - 'val' is inaccessible due to 'internal' protection level(from my pod) “‘isSuccess’由于‘内部’保护级别而无法访问”,AlamoFire 不像以前那样工作 - “'isSuccess' is inaccessible due to 'internal' protection level”, AlamoFire not working like before
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM