Skip to content

Cannot use R.swift in a cocoapod lib #293

@MartinMoizard

Description

@MartinMoizard

I am building a framework that uses R.swift internally. When the library is used, all the image created by R.swift are nil (because it cannot find the good Bundle).

After reading http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/, I learnt that the appropriate way to reference the bundle of my framework is to use NSBundle(for: <#ClassFromMyFramework#>).

I tried modifying the R.generated.swift file like this:

//
// This is a generated file, do not edit!
// Generated by R.swift, see https://github.com/mac-cain13/R.swift
//

import Foundation
import Rswift
import UIKit

private class RswiftDummy {}

/// This `R` struct is generated and contains references to static resources.
public struct R: Rswift.Validatable {
  fileprivate static let applicationLocale = hostingBundle.preferredLocalizations.first.flatMap(Locale.init) ?? Locale.current
  fileprivate static let hostingBundle = Bundle(for: RswiftDummy.self) ?? Bundle.main
[...]
}

What do you think? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions