mac-cain13 / R.swift

Strong typed, autocompleted resources like images, fonts and segues in Swift projects
MIT License
9.49k stars 763 forks source link

R.swift Fails to Generate Resources for Folders (Xcode 16 default project structure) #913

Closed tlacan closed 2 days ago

tlacan commented 2 days ago

Environment:

•   Xcode Version: 16.0
•   macOS Version: Sequoia 15.0
•   R.swift Version: 7.6.1

Description:

We are experiencing issues with R.swift failing to generate the expected enum values for resources when creating new projects in Xcode 16.0 on macOS Sequoia 15.0. This problem affects multiple users, including myself and others who are being trained in a similar setup.

In new projects made with Xcode 16.0 where we add images, fonts, or strings, the R.generated.swift file does not include the resource-specific enum values. Instead, it remains in a basic template state as shown below:

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

import Foundation
import RswiftResources

private class BundleFinder {}
let R = _R(bundle: Bundle(for: BundleFinder.self))

struct _R {
  let bundle: Foundation.Bundle
  func validate() throws {

  }

  struct project {
    let developmentRegion = "en"
  }
}

(Checked from derived data result)

Behavior: • New Projects: The issue occurs when creating new projects in Xcode 16.0. • Existing Projects: Interestingly, the issue does not occur when opening and using projects that were created in earlier versions of Xcode.R.swift works as expected and generates all resources enums without issues.

Attempted Workarounds: • Verified that the resources (images, fonts, and strings) are properly added to the project. • Cleaned and rebuilt the project. • Removed the Derived Data folder, but no relevant changes are reflected in R.generated.swift.

Additional Notes: • We are unable to test this configuration on Xcode 15.4, as it is not compatible with macOS Sequoia 15.0.

Expected Behavior: R.swift should generate the necessary enum values for resources such as images, fonts, and strings in new projects created in Xcode 16.0, just as it does for projects created in earlier versions.

Steps to Reproduce:

1.  Create a new project in Xcode 16.0 on macOS Sequoia 15.0.
2.  Add resources (images, fonts, strings) to the project.
3.  Run the R.swift build phase.
4.  Check the R.generated.swift file in the Derived Data directory.

Request:

Is this a known issue with Xcode 16.0 or Sequoia 15.0 compatibility? Are there any suggested workarounds or updates to R.swift that might resolve this?

tlacan commented 2 days ago

Additional Notes: I have checked the projects build settings, they are the same between Xcode 16 projects and Xcode 15 projects could not find an option which was causing the issue.

tlacan commented 2 days ago

We were expecting the last release to include PR #886.

In the latest Xcode projects, .xcstrings files have become the new standard, while .strings files are now considered legacy. It would be great to have support for this updated format in R.swift.

tomlokhorst commented 2 days ago

This is a known issue. R.swift currently doesn’t support resources inside Xcode 16 Folders that are synchronized to the file system.   Older projects use Groups (grey icon) instead of Folders (blue icon). Groups do work. As a workaround: You can right click in Xcode and click “Convert to Group”. This turns a folder into an old-style group. Which works with R.swift. We are working on adding support for Xcode 16 Folders in a future version of R.swift. On 26 Sep 2024, at 20:30, tlacan @.***> wrote: Environment: • Xcode Version: 16.0 • macOS Version: Sequoia 15.0 • R.swift Version: 7.6.1

Description: We are experiencing issues with R.swift failing to generate the expected enum values for resources when creating new projects in Xcode 16.0 on macOS Sequoia 15.0. This problem affects multiple users, including myself and others who are being trained in a similar setup. In new projects made with Xcode 16.0 where we add images, fonts, or strings, the R.generated.swift file does not include the resource-specific enum values. Instead, it remains in a basic template state as shown below: // // This is a generated file, do not edit! // Generated by R.swift, see https://github.com/mac-cain13/R.swift //

import Foundation import RswiftResources

private class BundleFinder {} let R = _R(bundle: Bundle(for: BundleFinder.self))

struct _R { let bundle: Foundation.Bundle func validate() throws {

}

struct project { let developmentRegion = "en" } }

(Checked from derived data result) Behavior: • New Projects: The issue occurs when creating new projects in Xcode 16.0. • Existing Projects: Interestingly, the issue does not occur when opening and using projects that were created in earlier versions of Xcode.R.swift works as expected and generates all resources enums without issues. Attempted Workarounds: • Verified that the resources (images, fonts, and strings) are properly added to the project. • Cleaned and rebuilt the project. • Removed the Derived Data folder, but no relevant changes are reflected in R.generated.swift. Additional Notes: • We are unable to test this configuration on Xcode 15.4, as it is not compatible with macOS Sequoia 15.0. Expected Behavior: R.swift should generate the necessary enum values for resources such as images, fonts, and strings in new projects created in Xcode 16.0, just as it does for projects created in earlier versions. Steps to Reproduce:

  1. Create a new project in Xcode 16.0 on macOS Sequoia 15.0.
  2. Add resources (images, fonts, strings) to the project.
  3. Run the R.swift build phase.
  4. Check the R.generated.swift file in the Derived Data directory.

Request: Is this a known issue with Xcode 16.0 or Sequoia 15.0 compatibility? Are there any suggested workarounds or updates to R.swift that might resolve this?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

tlacan commented 2 days ago

@tomlokhorst

Thank you for the prompt reply and clarification. I hadn’t noticed this change, but after converting the folders to groups, everything works as expected.

I’m looking forward to the future version of R.swift that supports both folders and .xcstrings files.

tomlokhorst commented 2 days ago

I've created an issue explaining the situation and the workaround: https://github.com/mac-cain13/R.swift/issues/914.

Closing this one, in favour of the other one.

julesfakhouri1 commented 1 day ago

Hello,

I have followed the previous discussion regarding the error we are encountering. However, I still have the following error: Value of type '_R' has no member 'string' on line : I converted the folder to group

Text(R.string.localizable.textSampleSimple)

xcode_02

xcode

Thank you !