Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for resource folder references #318

Merged
merged 8 commits into from Apr 8, 2019

Conversation

kwridan
Copy link
Collaborator

@kwridan kwridan commented Apr 6, 2019

Resolves #202

Short description πŸ“

Resources to include in an application can be in the form of files as well as folder references.

resource-references

Solution πŸ“¦

Add support for folder references within target resources. For consistency, we can use FileElement which has already been used in Project and Workspace to define additional files.

e.g.

import ProjectDescription

let project = Project(
    name: "MainApp",
    targets: [
        Target(
            name: "App",
            platform: .iOS,
            product: .app,
            bundleId: "io.tuist.App",
            infoPlist: "Config/App-Info.plist",
            sources: "Sources/**",
            resources: [
                "Resources/*.png",
                .folderReference(path: "Examples")
            ])
      ]
)

Implementation πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

  • Include fixture
  • Update manifest
  • Update models & Generator
  • Update documentation
  • Update change log

Test Plan βš’

  • Verify unit tests pass via swift test

  • Verify acceptance tests pass via bundle exec rake features

  • Run tuist generate within fixtures/ios_app_with_framework_and_resources

  • Inspect the generated workspace

  • Verify MainApp has a folder reference to Examples which is also included in the Copy Bundle Resources phase

- Resources are now `FileElement`s to support folder references
- Resource folder references are added to the project and copied to the final product (bundle resources)
@kwridan kwridan requested review from dangthaison91 and a team April 6, 2019 20:11
@tuistbot
Copy link
Contributor

tuistbot commented Apr 6, 2019

1 Warning
⚠️ Have you introduced any user-facing changes? If so, please take some time to update the documentation. Keeping the documentation up to date makes it easier for users to learn how to use Tuist.

Generated by 🚫 Danger

@codecov
Copy link

codecov bot commented Apr 6, 2019

Codecov Report

Merging #318 into master will increase coverage by 0.21%.
The diff coverage is 97.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #318      +/-   ##
==========================================
+ Coverage   89.48%   89.69%   +0.21%     
==========================================
  Files         280      280              
  Lines       10707    10793      +86     
==========================================
+ Hits         9581     9681     +100     
+ Misses       1126     1112      -14
Impacted Files Coverage Ξ”
Sources/ProjectDescription/Target.swift 100% <ΓΈ> (ΓΈ) ⬆️
...neratorTests/Models/TestData/Target+TestData.swift 100% <ΓΈ> (ΓΈ) ⬆️
...nerator/TestData/ProjectDescription+TestData.swift 100% <ΓΈ> (ΓΈ) ⬆️
...urces/TuistCoreTesting/Utils/MockFileHandler.swift 82.85% <100%> (+6.85%) ⬆️
...atorTests/Generator/ProjectFileElementsTests.swift 99.68% <100%> (ΓΈ) ⬆️
Sources/TuistGenerator/Linter/TargetLinter.swift 96.25% <100%> (ΓΈ) ⬆️
Tests/ProjectDescriptionTests/TargetTests.swift 100% <100%> (ΓΈ) ⬆️
...TuistGeneratorTests/Linter/TargetLinterTests.swift 100% <100%> (ΓΈ) ⬆️
...tKitTests/Generator/GeneratorModelLoaderTest.swift 98.32% <100%> (-0.04%) ⬇️
...ratorTests/Generator/WorkspaceGeneratorTests.swift 93.51% <100%> (-0.18%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 8d7f15f...e869906. Read the comment docs.

@@ -65,3 +65,19 @@ extension FileElement: ExpressibleByStringLiteral {
self = .glob(pattern: value)
}
}

extension Array: ExpressibleByUnicodeScalarLiteral where Element == FileElement {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘

var fileHandler: MockFileHandler!
override func setUp() {
do {
fileHandler = try MockFileHandler()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be safe to go with try! MockFileHandler() here but all good πŸ‘

@@ -72,6 +72,8 @@ Scenario: The project is an iOS application that has resources (ios_app_with_fra
Then tuist generates the project
Then I should be able to build the scheme App
Then the product 'App.app' with destination 'Debug-iphoneos' contains resource 'tuist.png'
Then the product 'App.app' with destination 'Debug-iphoneos' contains resource 'Examples/item.json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘

Copy link
Contributor

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @kwridan. The PR looks to me and CI is happy about it πŸ˜›

@kwridan kwridan merged commit 28a879b into tuist:master Apr 8, 2019
@kwridan kwridan deleted the feature/202-2-resouce-file-elements branch April 8, 2019 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support adding file/folder as reference
3 participants