2017-01-25 27 views
3

我一直致力於開發框架,並決定創建自定義枚舉來擴展錯誤協議,以便在遇到特定於域的錯誤時向主機應用程序報告。無法從框架內訪問公共枚舉

public enum MyCustomError: Error { 
    case customCase(message: String) 
} 

從主機應用程序,我有一個響應回調是與相關值

public enum MyCustomResponse { 
    case success 
    case error(Error) 
} 

形式的主機應用程序,我嘗試訪問在另一個枚舉通過執行下列錯誤

let responseHandler: (MyCustomResponse) -> Void = { response in 

    switch response { 
     case .error(let error): 
      if case let MyCustomModule.MyCustomError.customCase(theErrorMessage) = error { 
       print(theErrorMessage) 
      } 
    } 
} 

我得到的是一條來自編譯器告訴我的消息MyCustomModule has no member named MyCustomError。如果鬆動了MyCustomModule.那麼編譯器會抱怨Use of unresolved identifier 'MyCustomError'。我正在導入MyCustomModule,並且MyCustomError的訪問級別爲public,關於如何解決這個問題的任何想法都將非常感激。

感謝

注:我通過的CocoaPods版本1.1.1發展我的框架和使用的Xcode 8.2.1,快捷版本3.0.2,支持IOS版本8.0及以上。

生成的接口

import Foundation 

public enum MyCustomError : Error { 
    case customCase(message: String) 
} 
+0

你可以顯示什麼對象包含'public enum MyCustomError:Error'聲明? –

+0

'MyCustomError'是上面指定的,我將其稱爲'MyCustomError.customCase(「MyCustomObject屬性A不能爲空」)。 @AshleyMills –

+0

我的意思是,包含在另一個對象中的聲明,還是它在頂層? –

回答

0

後很長一段時間嘗試,我能想到的每一件小事,甚至在新回購沙箱問題(檢查github.com/anuragajwani/framework_pod_enums_test)無重現它的能力我結束重新克隆有問題的存儲庫,並重新應用所有更改,它沒有問題。 Pitty我無法找到潛在的問題,但通過比較每個配置設置與沙盒項目以及我完全匹配的所有配置,我放棄了。我有預感,它必須與編譯器,它給了它是多麼的片狀,這將不會是驚喜。

-1

我有完全相同的問題。在我的情況下,我只需將"Build Active Architecture Only" to "No"設置爲Build Settings,問題就消失了。

+0

這並沒有真正回答這個問題。如果您有不同的問題,可以通過單擊[提問](https://stackoverflow.com/questions/ask)來提問。您也可以[添加賞金(https://stackoverflow.com/help/privileges/set-bounties),以吸引更多的關注到這個問題,一旦你有足夠的[口碑](https://stackoverflow.com/help/什麼聲譽)。 - [來自評論](/ review/low-quality-posts/18678374) – aerokite