【问题标题】:Unable to access ViewController which is present inside Pod无法访问 Pod 中存在的 ViewController
【发布时间】:2018-02-11 06:15:59
【问题描述】:

我创建了一个UIViewController(TestViewController.swift),我在Test.xcodeproj 中创建了它,并希望在另一个abc.xcodeproj 中访问这个TestViewController.swift 及其方法。

例子-

import Test

class abcViewController: TestViewController {
}

我在项目的 Pod 文件中添加了 abc.xcodeproj 和 Test.xcodeproj。

但我无法继承abcViewController 中的TestViewController。我想使用 LEGO 模式创建我的项目。

请提出正确的方法。

【问题讨论】:

    标签: ios swift3 uiviewcontroller cocoapods


    【解决方案1】:

    TestViewController 很有可能被标记为internal,因为这是默认值。这可以防止它被其他模块看到,在使用 CocoaPods 时会出现这种情况。

    要纠正这个问题,TestViewController 需要标记为public 或open。

    以下Apple documentation 涵盖访问级别,以防您不熟悉此内容并希望了解公开和公开之间的区别。

    【讨论】:

    • 我在添加公开课时犯了一个错误。它使用开放工作。谢谢
    猜你喜欢
    • 2020-07-06
    • 1970-01-01
    • 2022-01-11
    • 2022-01-15
    • 2021-06-24
    • 2021-06-16
    • 2023-04-07
    • 2021-09-17
    • 1970-01-01
    相关资源
    最近更新 更多