module
Xcode がバンドル内のパラメータを判別できない場合があります。
タイプ「バンドル」にはメンバー「モジュール」がありません
私の調査によると、SPMはモジュールのこのプロパティの拡張機能を(時々)自動的に次のファイルに生成します。resource_bundle_accessor
のように:
import class Foundation.Bundle
private class BundleFinder {}
extension Foundation.Bundle {
/// Returns the resource bundle associated with the current Swift module.
static var module: Bundle = {
let bundleName = "ABUIKit_ABStyleKit"
let candidates = [
// Bundle should be present here when the package is linked into an App.
Bundle.main.resourceURL,
// Bundle should be present here when the package is linked into a framework.
Bundle(for: BundleFinder.self).resourceURL,
// For command-line tools.
Bundle.main.bundleURL,
]
for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
fatalError("unable to find bundle named ABUIKit_ABStyleKit")
}()
}
しかし、時々そうならないことがあります。なぜでしょうか、そしてどうすれば自動的に動作させることができるでしょうかまた(手動で実装する必要はありません。)
どちらの状況も、Xcode 12 ベータ.3
アップデート
時々、次のように表示されます:
「モジュール」は「内部」保護レベルによりアクセスできません
そして、ファイルはまったく表示されません。
ベストアンサー1
SPMはresource_bundle_accessor
対応するターゲットに次のような引数が含まれている場合のみresources
:
.target(
name: "ChenzookKit",
dependencies: ["Apollo"],
resources: [.process("Resources")] // <- `copy` or `process` doesn't really matter
),
また、有効なリソース パスである必要があることに注意してください。
そして❗️
プロジェクトしなければならない含むResources
内部ターゲットのディレクトリ!
そして❗️❗️
のResources
しなければならない何かを含み、してはいけないこと空のディレクトリである
そして❗️❗️❗️
作成するには、コードをビルド ( cmd+ )することを忘れないでください。b.module