Commit Graph

336 Commits

Author SHA1 Message Date
Kas c778fedc52
Prevent embedding static frameworks (#490)
Resolves https://github.com/tuist/tuist/issues/454

- All `FrameworkNodes` (i.e. prebuilt frameworks) were being embedded regardless of their linkage
- This check was redundant as there was a more general check for `PrecompiledNode` which happens to be the super class of `FrameworkNode` which took into account the framework linkage
- To resolve this issue it was suffice to remove the redundant check

Test Plan:

- Generate `fixtures/ios_app_with_static_frameworks` via running `tuist generate`
- Verify the generated project doesn't embed `PrebuiltStaticFramework`
- Verify the generated project builds successfully
2019-08-30 11:11:19 +01:00
Pedro Piñera Buendía 3d725b72c8
FileHandler.shared (#488)
* Use shared FileHandler

* Fix tests

* Make the init method public

* Fix linting issue
2019-08-24 06:10:45 -04:00
Pedro Piñera Buendía 27bb970732
Add shared instance to the Printer (#483)
* Implement Context and update usages of the printer to use it through Context.shared

* Fix tests

* Add XCTAssertPrinterError and XCTAssertPrinterError

* Rename the XCT methods

* Simplify API

* Get rid of Context and provide a mockEnvironment() helper method

* Fix linting issues
2019-08-23 08:58:46 -04:00
Adam Khazi cbc4780f85
Transitively Link Static Dependency's Dynamic Dependencies Correctly (#484)
Resolves https://github.com/tuist/tuist/issues/455

### Short description 📝

> When a static dependency has a dynamic dependencies, those dynamic dependencies need to be linked at the point the static dependency is linked.

This PR fixes the issue where a static dependency's dynamic libraries were linking incorrectly.

### Solution 📦

As we already traverse the graph for static dependencies, we can add a step to this process to check each static dependency's `targetDependencies` for dynamic libraries and add them as a reference adjacent to where the original static dependency is referenced.

### Implementation 👩‍💻👨‍💻

- [X] Update `linkableDependencies` in `Graph.swift` to reference a static dependency's dynamic libraries
- [X] Update `GraphTests` to check the test case:
-  A (App) -> B (Static) -> C (Dynamic)
-  Expected: A -> C
- [X] Update `GraphTests` to check the test case:
-  A (App) -> B (Dynamic) -> C (Static) -> D (Static) -> E (Dynamic) 
-  Expected: A -> B
-  Expected: B -> (C, D, E)
-  [X] Update `GraphTests` to check the test case:
-  A (App) -> B (Dynamic) -> C (Dynamic) -> D (Static) -> E (Static) -> F (Dynamic)
-  Expected: B -> C

### Test Plan
- Run `tuist generate` inside `fixtures/ios_app_with_static_frameworks`
- Check that the `App` target has `D` inside `Build Phases -> Link Binary With Libraries`
2019-08-21 11:29:23 +01:00
Pedro Piñera 2c274ba15f Version 0.17.0 2019-08-14 17:25:38 +02:00
Kas 1cbb9b402e
Expose the `.bundle` product type (#479)
Part of https://github.com/tuist/tuist/issues/290

- Tuist support iOS resouce bundles
- This can now be leveraged via specifying `.bundle` product types
- Fixture has been updated to show case how this can be used

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_framework_and_resources`
- Verify the project `StaticFramework` has a bundle target called `StaticFrameworkResources` which includes resources
- Verify the `StaticFrameworkResources` bundle is copied as a resouce in the App
- Verify running the app prints out descriptions for images within `StaticFrameworkResources`
2019-08-14 07:03:40 +01:00
Kas 915f59f236
Set the correct lastKnownFileType for localized files (#478)
Resolves https://github.com/tuist/tuist/issues/424

- Localized file extensions are used to determine the `lastKnownFileType`

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_framework_and_resources`
- Verify the `lastKnownFileType` of the strings files are set (inspect `App/MainApp.xcodeproj/project.pbxproj`)
2019-08-14 07:03:15 +01:00
Pedro Piñera Buendía 2b09f5cfa9
Add compatible Xcodes option to the TuistConfig (#476)
* Add model changes to ProjectDescription

* Add models to the TuistGenerator target

* Create Xcode & XcodeController to interact with local Xcode installations

* Implement TuistConfigLinter

* Add acceptance test

* Support initializing CompatibleXcodeVersions with a string literal

* Add documentation

* Update CHANGELOG

* Address comments

* Fix imports

* Rename TuistConfigLinter to EnvironmentLinter

* Some style fixes
2019-08-07 19:44:44 +02:00
Adam Khazi 1aed58f4ec Use Custom File Name for `.xcodeproj` at Model Level (#462)
* using custom file name

* swiftformat

* use file name from model

* changelog

* fix test

* enum suffix, prefix, test, and new fixture

* acceptance test

* swiftformat

* new api

* docs and clean ups

* swiftformat and clean up

* expose less at generator level, tuist config tests for code coverage

* more code coverage?

* clean ups

* clean ups

* pr suggestions

* swift format

* fixes tests from changes in master
2019-08-07 13:48:29 +02:00
Pedro Piñera Buendía 22854327d5
Add support for CocoaPods dependencies (#465)
* Add TargetDependency.cocoapods

* Add Dependency.cocoapods

* Add CocoaPodsNode model and support for caching it to the GraphLoaderCache

* Add tests to CocoaPodsNode

* Support loading a CocoaPods target dependency

* Test TargetNode changes

* Lint that the directories referenced by CocoaPods dependencies contain a Podfile

* Run 'pod install' after the workspace generation

* Add documentation

* Update Pod specs repository automtically

* Update CHANGELOG

* Add acceptance tests

* Remove empty code block and fix acceptance test
2019-08-04 07:22:49 -04:00
Kas a3684c66d6
Add linting for mismatching build configurations in a workspace (#474)
Resolves https://github.com/tuist/tuist/issues/467

- All projects' build configurations are now validated against the top level projects
- In the event any are missing or are mismatching (e.g. have a mismatching variant) the linter will now flag them

Example:

```
$ tuist generate
The following issues have been found:
  - The project 'Framework2' has missing or mismatching configurations. It has [Debug (debug), Release (release)], other projects have  [Beta (release), Debug (debug), Release (release)].
```

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_multi_configs`
- Comment out any of the build configurations defined in `App`, `Framework1` or `Framework2`
- Re-run `tuist generate`
- Verify a lint warning is displayed
2019-08-04 10:01:57 +01:00
Kas 7d2388b0e3
Allow specifying multiple configurations within project manifests (#451)
- Exposing a new `CustomConfiguration` type to allow specifying named configurations with a variant (debug or release) to inner the default settings.
- Adding fixture `fixtures/ios_app_with_multi_configs` with acceptance tests
- Adding additional linting to ensure scheme specified configurations exist
- Updating scheme API to use configuration name strings instead of `BuildConfiguration` enum
- Renamed the `BuildConfiguration` enum to `PresetBuildConfiguration` enum to ensure schemes are backwards compatible
- Updating how default build configurations for scheme targets are selected
  - 'Debug' configuration is used for Run, Test and Analyze actions 
  - 'Release' configuration is used for the Profile & Archive actions.
  - If those aren't found, the first alphabetically ordered configuration with the corresponding variant is used
- Adding manifest linter to help flag manifest issues such as duplicate custom configuration names
- Updating documentation to include information on multiple configurations and some of the gotchas to watch out for

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_multi_configs`
- Verify the generated project contains the build configurations "Debug", "Beta" and "Release"
- Verify the generated project `Framework2` has a target xcconfig override for the Beta configuration that points to `Target.Beta.xcconfig`
- Verify the generated project has a scheme "App-Beta" which uses the "Beta" configuration when performing the run action
- Verify that referencing a configuration within the scheme that isn't defined in the project flags a listing error
2019-07-31 20:44:11 +01:00
Adam Khazi f84fe72181
Support Multiple Header Paths (#459)
Resolves https://github.com/tuist/tuist/issues/354

### Short description 📝

Add support to specify array of paths / glob patterns for headers such as the case below:

```
Headers(public: ["Sources/A/**/*.h", "Sources/B/**/*.h"],
        private: ["Sources/C/**/*.h", "Sources/D/**/*.h"],
        project: "Sources/E/**/*.h")
```

### Solution 📦

Similar to the way multiple source file paths/glob patterns were implemented  (https://github.com/tuist/tuist/pull/266). We can use `FileList` and `ExpressibleByStringLiteral` to  expose public, private and project headers as either a String or Array of Strings. The original `FileList` used for sources was not reused as it contained `compilerFlags` which is specific to source files. A new `FileList` containing only paths/glob patterns was created for use with headers. This way `FileList` can be potentially reused elsewhere.

### Implementation 👩‍💻👨‍💻

- [X] Remove `FileList` type alias from `SourceFilesList` and references to it 
- [X] Create new `FileList` without `compilerFlags`
- [X] Modify `Headers` to use the new `FileList` for public, private and project headers
- [X] Add tests to `GeneratorModelLoaderTests` to verify newly supported cases work
- [X] Create `ios_app_with_headers` fixture to support new array of strings case for headers
- [X] Write test that verifies `ios_app_with_headers` fixture targets build

### Test Plan
- Run `tuist generate` inside the `ios_app_with_headers` fixture
- Verify that the Framework1 target has the correct header files specified in the manifest
2019-07-25 13:56:40 +01:00
Kas c14824360b
Adding ability to re-generate individual projects (#457)
Resolves https://github.com/tuist/tuist/issues/452 

### Short description

To support workflows where only the local project needs to be re-generated without re-generating all its dependencies a new generation option is needed (see https://github.com/tuist/tuist/issues/452 for full rationale)

### Solution

Add a new option to generate the local project only.

usage:

```bash
tuist generate --project-only
```

### Implementation

- [x] Expose new generator method that generates a single project
- [x] Expose new option via command line argument `--project-only`
- [x] Update documentation
- [x] Update changelog 

### Test Plan

- Run `tuist generate` within `fixtures/ios_app_with_custom_workspace`
- Verify the workspace is still generated with all the dependencies as before
- Run `tuist generate` within `fixtures/ios_app_with_custom_workspace/App`
- Verify the project workspace is still generated with all the dependencies as before
- Run `tuist generate --project-only` within `fixtures/ios_app_with_custom_workspace/App`
- Verify only the `App`'s project re-generated (this can be done by either doing a git clean before running the command and then verifying that the only Xcode project is for `App` or by manually modifying any of the projects and verifying they don't update)
2019-07-24 11:39:04 +01:00
Adam Khazi bd1897a947 Do Not Create `Derived/InfoPlists` Folder When No InfoPlist Dictionary Specified (#456)
* fix and test case

* make info plist inclusion explicit

* swiftformat and changelog
2019-07-24 09:58:37 +02:00
Pedro Piñera Buendía d12f659940
Add new manifest file, TuistConfig.swift (#446)
* Add TuistConfig manifest model

* Add TuistConfig to the TuistGenerator

* Use the TuistConfig generationOptions to determine whether the manifest elements should be generated

* Generate a TuistConfig.swift when initialing a project using 'tuist init'

* Add documentation

* Add documentation

* Update CHANGELOG

* Fix tests
2019-07-22 09:05:23 +02:00
Pedro Piñera Buendía 58c6580f73
Pass Info.plist as dictionary (#380)
* Add a new case to Info.plist, dictionary

* Add .dictionary to the model in TuistGenerator

* Add DerivedFile model

* Add documentation

* Create a custom type for the InfoPlist dictionary

* Fix tests

* Update CHANGELOG

* Add logic to write Info.plist content

* Test DerivedFileGenerator

* Generate the file elements and the right configuration path

* Add tests

* Include Minitest::Assertions namespace

*  Fix acceptance tests

* Fix tests

* Add test that asserts that a codable & equatable object can be encoded and decoded, resulting in the same object

* Remove not used decoding logic from the InfoPlist.Value enum.
Moreover, update its tests to use the new XCTAssertCodable helper.

* Simplify the generation logic by setting the target.infoplist attribute pointing to the Info.plist generated in the Derived folder
2019-07-15 18:05:52 +02:00
Adam Khazi 7923e06480 Transitive SDK Dependencies (#441)
* adds transitive sdk deps

* transitive dependencies are unique

* use sets, duplication test, immediate child test

* remove comments

* integration test

* integration test, remove throws

* minor fixes to naming etc

* swiftformat

* unneeded throws

* changelog entry and adds private to struct
2019-07-12 20:27:10 +02:00
Kas fdbe6289b3
Adding support for static products depending on dynamic frameworks (#439)
- Updating lint rules to allow static products to depend on dynamic frameworks
- Updating fixture to include scenario where a static framework depends on a dynamic framework

Test Plan:

- Verify unit tests pass via `swift tests`
- Verify acceptance tests pass via `bundle exec rake tests`

Manually:
- Run `tuist generate` within `fixtures/ios_app_with_static_frameworks`
- Verify the generation is successful
- Open the generated workspace
- Verify D is embedded in App and CTests
- Verify the app compiles runs
2019-07-10 10:58:00 +01:00
Oliver Atkinson 3907b63794 Code Review 2019-07-05 10:13:26 +01:00
Oliver Atkinson 1f4f684b9c swiftformat . 2019-07-04 21:29:08 +01:00
Oliver Atkinson 1f6b89a161 Only link direct dependencies of the target node, check for framework architechtures when linking 2019-07-04 20:46:18 +01:00
Oliver Atkinson 7301e378e1 Update product name for manifest 2019-07-04 13:26:23 +01:00
Oliver Atkinson 2e1695c9fd swiftformat . 2019-07-04 13:26:23 +01:00
Oliver Atkinson 714abb0c2d Unique products on target name rather than product name 2019-07-04 13:26:23 +01:00
Oliver Atkinson 8f2ebf973c swiftformat . 2019-07-04 13:26:23 +01:00
Oliver Atkinson d8ce237bed Support PRODUCT_NAME in manifest 2019-07-04 13:26:23 +01:00
Kas 95f7422d4d
Update manifest target name such that its product has a valid name (#426)
Part of https://github.com/tuist/tuist/issues/425

- Renaming the generated manifest target to include an `_` separator instead `-` which produces an invalid product name.
- This was causing Xcode to automatically re-name it when opening the project

Test Plan:

- Generate `fixtures/ios_app_with_tests` via `tuist generate`
- Run `git add . -f` to stage the generated project
- Open the project in Xcode
- Verify the manifest target `App_manifest` doesn't get renamed by Xcode within the Scheme and project
- Verify the manifest target can still build successfully
2019-07-03 23:09:57 +01:00
Pedro Piñera Buendía f584917534
Set up the Galaxy frontend's stack (#433)
* Setup webpacker for typescript

* Typescript is working

* Add documentation to set up the Galaxy project and start contributing to it

* Add Storybook

* Add Jest

* Remove tuistenv from the .gitignore

* Run rubocop
2019-07-03 13:41:08 +02:00
Pedro Piñera Buendía 5657230a8f
Merge installation scripts (#432)
* Merge installation scripts

* Don't run Rubocop

* Fix path

* Change Xcode version

* Fix path

* Fix command

* Add missing files
2019-07-02 22:16:21 +02:00
Pedro Piñera Buendía 1b828716e9
Add "tuist graph" command (#427)
* Implement class to generate the dotgraph as a string

* Add GraphCommand

* Register command

* Add command to export the graph

* Fix graph syntax error

* Don't generate manifest targets when printing the graph

* Add tests

* Update CHANGELOG

* Add documentation

* Add the graph.dot file to the gitignore

* Address comments

* Don't lint when generating the graph
2019-07-02 16:13:27 +02:00
Pedro Piñera Buendía 4739ea80e0
Generate a dot graph from the project graph (#382)
* Add command to output the graph to the standard output

* Make Graph and nodes conform Encodable

* Print the graph as a json

* Some fixes after rebasing

* Pass file and line arguments

* Keep models and attributes as internal

* Extract the node classes into their own files

* Add DotGraph* elements

* Extract FrameworkNode from GraphNode

* Add tests

* Address comments
2019-06-29 08:48:24 +02:00
Kas 089697fc2b
Ensuring the correct platform SDK dependencies path is set (#419)
Resolves https://github.com/tuist/tuist/issues/417

- Updating SDK dependency paths to be based on the developer directory and the platform SDK root path

Test Plan:

- generate the fixture `fixtures/ios_app_with_sdk` via `tuist generate`
- Verify the linked system frameworks and libraries have the correct path set based on the platform
2019-06-26 08:44:44 +01:00
Oliver Atkinson 641e33c9c4 release/v0.16.0 2019-06-21 08:50:31 +01:00
Kas 76b50a2f9d
Adding support for linking system libraries and frameworks (#406)
Resolves https://github.com/tuist/tuist/issues/174

Continuation of https://github.com/tuist/tuist/pull/272 by @steprescott 

### Short description 

In some cases specifying the status of the frameworks or libraries to link against is needed (e.g. weakly linking frameworks).

### Solution 

- A new `.sdk` dependency type is being introduced

usage:

```swift
Target(name: "App",
        platform: .iOS,
        product: .app,
        bundleId: "io.tuist.App",
        infoPlist: "Info.plist",
        sources: "Sources/**",
        dependencies: [
            .sdk(name: "CloudKit.framework", status: .required),
            .sdk(name: "StoreKit.framework", status: .optional),
            .sdk(name: "libc++.tbd"),
        ])
```

### Test Plan 

- Verify unit tests pass via `swift test`
- Verify acceptance tests pass via `bundle rake exec features`
- Manually generate `fixtures/ios_app_with_sdk` via `tuist generate`
- Verify the appropriate libraries are included in the generated project

### Notes 

Credit goes to @steprescott and [`XcodeGen`](https://github.com/yonaskolb/XcodeGen) - this PR is based on their work!
2019-06-19 13:25:46 +01:00
Marcin Iwanicki 6a9594ed4a
Don't generate settings attribute when compiler flags are not specified (#415)
Resolves https://github.com/tuist/tuist/issues/414

`BuildPhaseGenerator` will not generate empty `settings` attribute for source `PBXBuildFile` elements when compiler flags are not specified.

Test Plan:
 - Close Xcode
 - Generate `fixtures/ios_app_with_frameworks` fixture
 - Open generated .xcodeproj in a non-Xcode editor (i.e vim), ensure empty `settings ={}` attributes have not been generated
2019-06-18 20:50:19 +01:00
Kas 1932448f59
Updating `XcodeProj` dependency version (#412)
- Adding Xcode10 constants to maintain backwards compatibiltiy (Xcode 11 is still in beta!)

Test Plan:

- Verify unit tests pass via `swift test`
- Verify acceptance tests pass via `bundle exec rake features`
2019-06-17 14:02:25 +01:00
Kas 10d556ac36
Ensure generated projects are stable (#410)
Resolves https://github.com/tuist/tuist/issues/409

### Short description 

Calling `tuist generate` on the same project multiple times can yield a different `.xcodeproj` file each time. 

### Solution 

Sort elements ahead of adding them to their corresponding xcodeproj container.

### Implementation 

- Update generator integration tests to shuffle sources / headers 
- Sort files added within `BuildPhaseGenerator`
- Update generator integration tests to shuffle additional files
- Update `ProjectFilesSortener` to be stable
- Update `LinkGenerator` to sort dependencies 

### Test Plan 

- Ensure unit tests pass via `swift test`
- Ensure acceptance tests pass via `bundle exec rake features`

Generate the fixture `fixtures/ios_app_with_tests/` and verify the generated project is identical each time

```
$ cd fixtures/ios_app_with_tests/
$ touch Sources/Source{A..Z}.swift
$ for i in {1..5}; do tuist generate > /dev/null && md5 App.xcodeproj/project.pbxproj; done
```
2019-06-16 20:37:15 +01:00
Marcin Iwanicki b595fdbb4d
Fix "The file couldn’t be saved." error in unit tests caused by rdar://50553219 (#408)
# Short description

The `FileManager` `url(for:in:appropriateFor:create:)` method, when configured to create a temporary directory, fails after 1000 calls with: Error Domain=NSCocoaErrorDomain Code=512 "The file couldn’t be saved."

http://openradar.appspot.com/50553219

# Solution

We need to ensure the temporary directory is removed after `FileHandler.replace` method finished.
2019-06-15 12:41:48 +01:00
Kas 319e959831
Re-enable swiftformat (#405)
- Removing empty test file (seems to upset SwiftFormat)
- Doing a sweep of swiftformat fixes
- Bumping circleci image to Xcode 10.2.1

Test Plan:

- Verify tuist builds via `swift build`
- Verify tests pass via `swift tests`
- Verify swiftformat runs without issues
- Verify swiftformat runs on CI
2019-06-11 15:59:08 +01:00
Kas 65dad120fa
Omitting unzip logs during installation (#404)
Resolves https://github.com/tuist/tuist/issues/387

- We now pass the `-q` (quiet) option to `unzip` to suppress the verbose output

Test Plan:

- build this version locally
- run `swift run tuistenv update`
- Verify the logs don't display the unzipped files
2019-06-10 20:53:10 +01:00
Oliver Atkinson 034c84d09e
Merge pull request #353 from Rag0n/target_action_inputs_outputs
Add input & output paths for target action
2019-06-10 09:50:36 +01:00
Oliver Atkinson fef3bbb7d3 [target_action] add unit test to cover generating a target with input/output lists 2019-06-09 21:25:51 +01:00
Oliver Atkinson 551ae78548 [target_action] correct the formatting for the initialisers 2019-06-09 21:02:48 +01:00
Alexander Guschin b92ed8e0f0 Add input & output paths for target action 2019-06-09 21:02:48 +01:00
Oliver Atkinson 87a9ec7aed [tuist-local] fix 'tuist local' still referencing static lib when using swift 5 2019-06-09 20:14:10 +01:00
Oliver Atkinson b484c446fb [env-version] remove Constants.envVersion and use Constants.version 2019-06-08 22:39:54 +01:00
Oliver Atkinson a54065c7ee [env-version] added version command with envversion 2019-06-08 22:39:27 +01:00
Oliver Atkinson dc428a8e99
Update XcodeBuild.swift 2019-06-08 21:38:59 +01:00
Oliver Atkinson a0a25f710d [codesign-frameworks] Check if codesigning is allowed before signing 2019-06-08 15:28:44 +01:00