Commit Graph

273 Commits

Author SHA1 Message Date
Kas ac502072bc
Migrate info plist generator to a project mapper (#1469)
- The info plist generator is now a project mapper
- This helps keeps project modifications and side effects consistent to some of the others introduced
- Updated `Constants` to create a nested hierarchy for `DerivedDirectory` to allow grouping all related constants
- Updated side effect descriptions such that they are all `CustomStringContvertible` to allow using them in verbose logs

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_watchapp2`
- Verify the Info.plist files continue to be generated to the `Derived/InfoPlists` directory
2020-06-22 06:43:22 +01:00
Marek Fořt 3d369d1717
Runpaths (#1463)
* Use @rpath for dynamic frameworks in tests.

* Remove case-insensitive handler.

* Add @rpath tests.

* Run swiftformat.

* Move isDynamicAndLinkable to PrecompiledNode.

* Fix build issues.

* Edit changelog.
2020-06-19 08:00:41 +02:00
Marek Fořt d7f167ffa4
Signing install (#1186)
* Install provisioning profile.

* Import signing cert.

* Add SigningInstallerTests.

* Add SecurityControllerTests.

* Add keepFiles option.

* Fix SigningInstaller tests.

* Encrypt files only when necessary.

* Install signing on generate.

* Install signing only when signing dir exists.

* Run swiftformat.

* Make finding signing dir optional.

* Fix typo in keepFiles.

* Name variable in zip.

* Install certs and profiles in SigningMapper.

* Install certs into new keychain.

* Setup signing settings.

* Add signing linting.

* Do not create git changes on generate from reencryption.

* Run SigningInteractor.

* Create keychain at Derived.

* Restrict mutability of TuistCore models.

* Add errors to certificateparser.

* Better error handling.

* Build tests.

* Add Certificate test data.

* Add SigningInteractor tests.

* SigningMatcher tests.

* Add signing mapper tests.

* Fix finding certificate and privateKey.

* Add signing integration tests.

* Minor changes.

* Run swiftformat.

* Fix SecurityControllerTests.

* Edit changelog.

* Fix Xcode 11.3.1 compiler error.

* Fix generate when root dir not found.

* Refactor SigningMapper to be a ProjectMapper.

* Generate keychain into project derived directory.

* Change certificate naming convention.

* Code review changes, fix wildcard support.

* Fix tests.

* Added signing fixture.

* Change handling of duplicate keychain.

* Remove provision profiles from .gitignore.

* Add signing documentation.

* Fix signing section.
2020-06-15 20:59:51 +02:00
Maksym Prokopchuk 4665424696
Add source to sdk target dependency (#1001)
* Provide path for XCTest.framework

Add unit tests for XCTest framework

* Fix swifit lint errors

* Update fixture to test XCTest sdk

* Add new .sdk dependency

* Update the documentation

Co-authored-by: Maksym Prokopchuk <rowwingman@gmail.com>
Co-authored-by: Kassem Wridan <kwridan@bloomberg.net>
Co-authored-by: Pedro Piñera <pedro@ppinera.es>
2020-06-13 12:51:20 +02:00
Marek Fořt 036fa7559b
Generate tuist generated file into workspace to solve ambiguity. (#1427)
* Generate tuist generated file into workspace to solve ambiguity.

* Edit changelog.

* Move generating tuist-generated file to TuistKit.

* Fix BuildGraphInspector tests.

* Add test for no tuist workspace present.

* Add loadProjectWorkspace method to add tuist-generated to project workspace.

* Run swiftformat.
2020-06-11 20:32:32 +02:00
Maciej Piotrowski 40b81c89d3
Update SchemeLinter.swift to lint BuildAction (#1054)
* Update SchemeLinter.swift

Adds missing linting of scheme's `BuildAction`

* Remove redundant check

Co-authored-by: Pedro Piñera <pedro@ppinera.es>
2020-06-03 18:10:46 +02:00
Pedro Piñera Buendía 5dc8b7ab92
Move the auto-generation of schemes to a mapper (#1357)
* Add empty AutogeneratedSchemesGraphMapper

* Don't generate the schemes at generation time

* Implement AutogeneratedSchemesGraphMapper

* Update CHANGELOG

* Remove unnecessary method

* Turn the graph mapper into a project mapper

* Address some comments

Co-authored-by: Pedro Piñera <pedro@ppinera.es>
2020-06-03 17:41:36 +02:00
Maciej Piotrowski c07df2be86
Adds `language` and `region` to `TestAction` types (#1055)
* Adds `language` and `region` to `TestAction` types

* Update CHANGELOG.md

* Fix issues after rebasing from master and update documentation

Co-authored-by: Maciej Piotrowski <maciej.piotrowski@allegro.pl>
Co-authored-by: Pedro Piñera <pedro@ppinera.es>
2020-06-03 16:52:57 +02:00
Pedro Piñera Buendía dac7cb4659
Add the option to enable/disable the main thread checker from the generated schemes (#1382)
* Update the models in ProjectDescription to add support for enabling the main thread checker

* Set disableMainThreadChecker depending on the given diagnostic options

* Fix tests

* Add unit tests

* Update documentation

* Update CHANGELOG

Co-authored-by: Pedro Piñera <pedro@ppinera.es>
2020-05-27 19:18:51 +02:00
Kas ad24943ece
Remove CFBundleExecutable from iOS resource bundle target plists (#1361)
* Remove CFBundleExecutable from iOS resource bundle target plists

- When generating the plist file for an iOS resource bundle target the key `CFBundleExecutable` should be omitted
- Having it included causes a validation error when uploading application to the app store

```
Error 1: ITMS-90535 - Unexpected CFBundleExecutable Key
```

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_framework_and_resources/StaticFramework`
- Verify the generate info plist in `Derived` directory does not contain the `CFBundleExecutable` key

* Update changelog
2020-05-25 16:20:08 +02:00
Pedro Piñera Buendía 9dba155fba
Value graph (#1336)
* wip

* Document models

* Update CHANGELOG

* Fix style issues

* Upgrade swiftformat

* Style fixes

* Ensure attributes in ValueGraphDependency cases are consistently defined
2020-05-14 13:43:41 +02:00
Pedro Piñera Buendía ec30305bd8
Don't show logs when resolving packages (#1337)
* Don't show logs when resolving packages

* Upgrade Swiftformat

* Style fixes

* Add missing dependency
2020-05-14 11:12:03 +02:00
Pedro Piñera Buendía 25f3b13404
Inherit defaultSettings from the project when the target's defaultSettings is nil (#1338)
* Inherit the project settings behavior when the target doesn't specify defaultSettings

* Update CHANGELOG

* Style fixes
2020-05-14 09:28:16 +02:00
Alexander Guschin dd05ecb828
Add support for localized sources `.intentdefinition` (#1269)
Resolves https://github.com/tuist/tuist/issues/1225

### Short description 

Add support for localized sources(eg `.intentdefinition`)

### Solution 

Add localized sources variant group as build files to the sources build phase instead of the individual files. This solution is consistent with how localized resources are handled within the resources build phase.
2020-05-10 08:20:55 +01:00
Pedro Piñera Buendía 142ed6ebfe
Read the Swift version from the system (#1317)
* Read the Swift version from the system

* Update CHANGELOG

* Output a warning when SWIFT_VERSION is set automatically

* Remove warning
2020-05-06 13:38:38 +02:00
Pedro Piñera Buendía a2c175c988
Update the default Info.plist values to not include storyboards (#1289) 2020-04-29 18:40:56 +02:00
Natan Rolnik b52424a76b
Settings dictionary improvements (#1229)
* Add SettingsDictionary typealias for [String: SettingValue]

* Add SettingsDictionary functions to avoid using typed strings

* Add new SettingsDictionary functions to Changelog

* Improve changelog with links to PRs and usernames

(of contributors with 3+ PRs)

* Link also to PRs in Changelog

* Add documentation for SettingsDictionary

* Minor update to a SettingsDictionary transformer

* Update Changelog PR number

* Apply PR comments - part 1

* Apply more PR comments - part 2:

- Make SettingValue conform to ExpressibleByBooleanLiteral
- Add tests
- Change code signing methods

* Fix linting in SettingsTests

* Update Docs and Changelog

* Remove some of the SettingsDictionary functions

* Add SettingsDictionary functions table to website docs
2020-04-20 18:29:39 +03:00
Marek Fořt 8337c02bc9
Move from SPM libs to TSC (#1230)
* Convert from SPM libs to TSC.

* Edit changelog.

* Fix flaky duplicate configuration name test.

* Fix lint project duplicate config names.
2020-04-17 08:24:24 +02:00
Pedro Piñera Buendía 238d25aca0
Extend GraphMapping protocol to support returning SideEffectDescriptors (#1201)
* Add support for returning side effect descriptors from mappers

* Implement GraphMapperProvider to provide the mapper to be used depending on the config

* Add GraphMapperProviderTests

* Update CHANGELOG

* Test if the descriptors are concatenated in the right order

* Fix CHANGELOG. Some updates showed up in the wrong section
2020-04-09 14:07:20 +02:00
Søren Gregersen f28fa9647a
Linting: Only warn when copying the target Info.plist (#1203)
* Reproduce bug in tests

* Only raise a warning if the target info plist is also copied as resource

* Changelog
2020-04-09 10:50:05 +02:00
Jakub Olejník ca5e719721
Add possibility to skip generating default schemes (#1130)
### Short description 📝

In our projects at @AckeeCZ we usually use customized schemes that add pre-build actions which generate inputs for other build phases. Without those inputs, project is not compilable, thus default generated schemes do not make a real sense and only confuse newcomers.

### Solution 📦

Idea is to add possibility to skip generation of those schemes by specifying a new configuration option `disableAutogeneratedSchemes`. This will ensure only custom schemes are generated.

### Implementation 👩‍💻👨‍💻

- [x] add new property `disableAutogeneratedSchemes ` to `Config`
- [x] check this property in `SchemesGenerator` 
- [x] update existing tests
- [x] update docs
2020-03-30 12:55:13 +01:00
paul.s 79395e0430
Remove symbols from test input/output file lists (#1118)
When a project has a scheme that runs multiple test targets that rely on
the `Embed Precompiled Frameworks` script then the new build system
fails because there are multiple commands that produce the same target
file.

This commit prevents adding symbol files to the input/output file lists
for test targets to prevent this error from occuring.

Fixes tuist/tuist#919
2020-03-30 08:47:01 +01:00
Pedro Piñera Buendía 183304963b
Merge pull request #1146 from tuist/graph-without-cache
Decouple Graph from the cache
2020-03-26 07:54:34 +01:00
Pedro Piñera d45c836e0a Fix some Xcode 11.4 warnings 2020-03-26 05:59:30 +01:00
Pedro Piñera 6c60ee233d Make attributes in Graph normal arrays 2020-03-26 05:27:34 +01:00
Pedro Piñera 9dff608c40 Use WeakArrays 2020-03-25 19:47:26 +01:00
Pedro Piñera ad49cc95fc Make projects a WeakArray 2020-03-25 11:26:18 +01:00
Pedro Piñera 4f030ab2b0 Make packages a weak array 2020-03-25 09:34:32 +01:00
Pedro Piñera 9cae66bb67 Make precompiled a weak array 2020-03-25 09:16:13 +01:00
Pedro Piñera 437879c428 Make cocoapods a weak array 2020-03-25 09:11:10 +01:00
Pedro Piñera 6dccd9700e Fix tests 2020-03-24 20:01:23 +01:00
Pedro Piñera 8c7a6d12ad Move more attributes 2020-03-24 20:01:23 +01:00
Pedro Piñera 36e9c5ff88 Move Packages to the Graph object 2020-03-24 20:01:23 +01:00
Pedro Piñera 8dc7d4df27 Make CocoaPods an attribute of the Graph model 2020-03-24 20:01:22 +01:00
Pedro Piñera 1a9b2a840d Make projects an attribute of Graph 2020-03-24 20:01:22 +01:00
Kassem Wridan fcebb7f241 Remove redundant SDK paths from FRAMEWORK_SEARCH_PATHS
Resolves: https://github.com/tuist/tuist/issues/1144

- Generating a project that has a .sdk dependency will result in in a project that includes a relative path to the SDK directory from the source root (which will be different on different machines).

```diff
buildSettings = {
        ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
        CODE_SIGN_IDENTITY = "iPhone Developer";
        ENABLE_PREVIEWS = YES;
+        FRAMEWORK_SEARCH_PATHS = (
+            "$(inherited)",
+            "$(SRCROOT)/../../../../../../../Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks",
+            "$(SRCROOT)/../../../../../../../Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib",
+        );
        INFOPLIST_FILE = "Support/App-Info.plist";
        LD_RUNPATH_SEARCH_PATHS = (
            "$(inherited)",
            "@executable_path/Frameworks",
        );
        PRODUCT_BUNDLE_IDENTIFIER = io.tuist.App;
        PRODUCT_NAME = App;
        SDKROOT = iphoneos;
        SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
        SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
        SWIFT_COMPILATION_MODE = singlefile;
        SWIFT_OPTIMIZATION_LEVEL = "-Onone";
        SWIFT_VERSION = 5.1;
        TARGETED_DEVICE_FAMILY = "1,2";
    };
    name = Debug;
};
```

- This appears to be a side effect of some tidy ups to `GraphDependencyReference` which accidentally removed the filtering `LinkGenerator` used to perform to only add paths to precompiled frameworks and libraries
- To help make the usage clearer the `path` variable has been renamed to `precompiledPath`
- Tests have been updated to catch this in the future

Test Plan:

- Run tuist generate within `fixtures/ios_app_with_sdk`
- Open the generated project
- Inspect the `FRAMEWORK_SEARCH_PATH` build setting
- Verify it doesn't contain entires for the relative SDK paths
2020-03-24 08:19:23 +00:00
Pedro Piñera c12ea86ff7 Remove Graphing 2020-03-21 19:11:49 +01:00
Pedro Piñera 13ed503d0f Extend GraphDependencyReference to include metadata in the cases 2020-03-19 14:44:09 +01:00
Kas 70676b0e89
Concurrent project generation (#1096)
- Each project within a workspace is currently generated independently and non of the project share any mutable state
- The graph is static during the generation process
- As such one option to gain some overall performance improvement is to generate project concurrently as well serialise them to disk concurrently.
- An additional stress test was added to ensure there were no concurrency issues during workspace generation
- The test logger needed some small thread safetey improvement
- Fix concurrency issues in Atomic
- Leverage execution contexts to control threading behavior of components
- Update `XcodeController` to minimize synchronization calls (via `Atomic`)

Test Plan:

- Verify all automated tests pass
- Stress test tuist via running this script in the `fixtures` directory

```sh
#!/bin/bash -e

# skip fixtures that are testing failure cases
declare -a skipped_fixtures=(
    "invalid_workspace_manifest_name" 
    "ios_app_with_incompatible_dependencies" 
    "ios_app_with_incompatible_xcode" 
    "ios_workspace_with_dependency_cycle"
)

# Generate all fixtures in a loop
for i in {1..20}; do
    for f in *
    do
        if [[ ! " ${skipped_fixtures[@]} " =~ " ${f} " ]]; then
            if [[ -d $f ]]; then
                echo ">> Generating: $f"
                swift run tuist generate --path $f
                echo ""
            fi
        fi
    done
done
```
2020-03-17 10:32:44 +00:00
Kas fac70586de
Optimize `BuildPhaseGenerator`'s method of detecting assets and localized files (#1094)
Part of: https://github.com/tuist/tuist/issues/1093

- Leverage simpler string contains check to determine if a path is nested within an `xcassets` or `lproj` container
- The check on the `pathString` can be done directly as `AbsolutePath` ensures no trailing `/` in its `pathString` as such checking for `.xcassets/` or `.lproj/` can act as a suitable faster replacement of the `regex` check that was previously used.

Test Plan:

- Run `tuist generate` within `fixtures/ios_app_with_framework_and_resources`
- Verify the generated projects contains the xcassets and localized string files as before
2020-03-16 13:19:53 +00:00
Sylvain Rebaud 045b0b731a
Add support for passing Organization name to project (#1062)
Resolves https://github.com/tuist/tuist/issues/1063

### Short description 📝

New Files created by Xcode use the Organization name set in the project file for copyright notices. The organization was left blank before this PR.

### Solution 📦

It is now possible to optionally pass the organization name to either the `Project` initializer or more generally in `Config`. The latter will override the former if set.

### Implementation 👩‍💻👨‍💻

- [x] Add new `organizationName` argument to Project
- [x] Add new `organizationName` GenerationOptions case to pass to Config
- [x] Use project `organizationName` during pbxproj generation via attributes
- [x] Add Tests
2020-03-13 19:18:36 +00:00
Kas ef3071df1e
Generator update - leveraging intermediate descriptors (#1007)
### Short description

When using `TuistGenerator` as a library, the generator component performs several actions:

- Loading of the graph
- Linting the graph
- XcodeProj generation
- Writing generation artifacts to disk
- Post generation actions
 
While convenient it doesn't offer flexibility to perform any custom linting or post processing on the generated XcodeProj representations or to selectively leverage some of those actions without the others.

### Solution

Based on a few early prototyping rounds on [tuist-labs](https://github.com/tuist/tuist-labs/tree/prototype/pipelines) and discussions on modularising Tuist even further, we can split the responsibilities of the generator to provide more flexibility and simplicity.

- Update the generator to return descriptors (it doesn't directly perform any operations - it's side effect free)
- Create a dedicated component to write those descriptions to disk as well as perform any required side effects
- Move some of the interactors that performed side effects out of the xcodeproj generation to help group them (e.g. CocoaPods / Swift PM)
- Create a new top level component to orchestrate all those steps to achieve the previous behaviour

_**Note:** These changes should have no impact on end users of Tuist_

### Implementation

- [x] Prototype `Descriptors` by having existing components return descriptors instead of performing actions (initially as duplicate methods for testing/prototyping)
- [x] Integrate a prototype of a high level `ProjectGenerator` that performs all the previous tasks with the `tuist generate` command
- [x] Verify acceptance tests don't flag any regressions
- [x] Delete duplicate methods (the non-descriptor) variants and update their corresponding unit tests
- [x] Integrate the updated generator with the other tuist commands
- [x] Come up with better component names to clarify their purpose _(current names were temporary to avoid name collisions however could be confusing)_
- [x] Update change log

### Test Plan

- Verify all acceptance tests pass
- Test out running `tuist generate` on any of the fixtures
2020-03-11 15:45:52 +00:00
Zhuhao Wang cb55e98544
Add support for customizing profile and analyze action 2020-03-11 17:50:09 +08:00
Pedro Piñera 14124b8422 Rename TuistConfig to Config 2020-03-10 17:28:16 +01:00
Oliver Atkinson 8b459052f6 swiftformat . 2020-03-05 21:48:10 +00:00
Oliver Atkinson 489b5b66b1 Create logger.pretty and use PrintableString 2020-03-05 21:45:40 +00:00
Oliver Atkinson f0871503da refactor to use metadata, address code review comments 2020-03-05 19:59:26 +00:00
Oliver Atkinson 52fe8fd119 Merge remote-tracking branch 'origin/master' into verbose-logging 2020-03-05 18:01:17 +00:00
Pedro Piñera 8370f38cf0 Add command to lint the projects 2020-03-02 19:30:12 +01:00
Pedro Piñera 22a5e70d82 Implement cacher 2020-02-26 18:43:33 +01:00