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

Pass Info.plist as dictionary #380

Merged
merged 17 commits into from Jul 15, 2019

Conversation

@pepibumur
Copy link
Contributor

commented May 29, 2019

Short description 📝

This PR adds a new InfoPlist case:

enum InfoPlist {
  case dictionary([String: Any])
}

When the InfoPlist content is given, Tuist generates a file under SRCROOT/Derived/InfoPlists/#{target}.plist and sets it as the target's Info.plist.

Implementation 👩‍💻👨‍💻

  • Update the models.
  • Generate the Info.plist files.
  • Clean Info.plist files that are not necessary anymore.
  • Update the ProjectFileElements to include the derived files.
  • Update the build settings generation logic to set the right path.
  • Add acceptance test

Test plan

  • Unit tests
  • Acceptance tests
    • Test that verifies that a framework with a generated Info.plist file can be compiled and the Info.plist in the product bundle contains the expected content.

@pepibumur pepibumur self-assigned this May 29, 2019

import Basic
import Foundation

enum DerivedFile {

This comment has been minimized.

Copy link
@pepibumur

pepibumur May 29, 2019

Author Contributor

I used Derived in honor of the so beloved DerivedData :trollface:

@codecov

This comment has been minimized.

Copy link

commented May 29, 2019

Codecov Report

Merging #380 into master will decrease coverage by 0.51%.
The diff coverage is 63.98%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #380      +/-   ##
==========================================
- Coverage    92.3%   91.78%   -0.52%     
==========================================
  Files         316      294      -22     
  Lines       15983    14803    -1180     
==========================================
- Hits        14753    13587    -1166     
+ Misses       1230     1216      -14
Impacted Files Coverage Δ
...TuistCore/Extensions/Dictionary+AnyEquatable.swift 0% <0%> (ø)
Tests/TuistGeneratorTests/Models/TargetTests.swift 98.88% <100%> (-0.04%) ⬇️
...TuistGenerator/Generator/ProjectFileElements.swift 97.62% <100%> (+0.1%) ⬆️
...ts/TuistGeneratorTests/Models/InfoPlistTests.swift 100% <100%> (ø) ⬆️
...TuistGeneratorTests/Derived/DerivedFileTests.swift 100% <100%> (ø)
Sources/TuistGenerator/Linter/TargetLinter.swift 96.47% <100%> (-0.31%) ⬇️
Tests/ProjectDescriptionTests/TargetTests.swift 100% <100%> (ø) ⬆️
Tests/ProjectDescriptionTests/InfoPlistTests.swift 100% <100%> (ø) ⬆️
...tKitTests/Generator/GeneratorModelLoaderTest.swift 98.47% <100%> (ø) ⬆️
...ces/TuistGenerator/Generator/ConfigGenerator.swift 99.07% <100%> (-0.01%) ⬇️
... and 100 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 3060c5f...f1a2e31. Read the comment docs.

Sources/ProjectDescription/InfoPlist.swift Outdated Show resolved Hide resolved
Sources/ProjectDescription/InfoPlist.swift Outdated Show resolved Hide resolved
docs/usage/2-manifest.mdx Show resolved Hide resolved
@pepibumur pepibumur referenced this pull request May 29, 2019
5 of 5 tasks complete

@ollieatkinson ollieatkinson added this to the 0.16.0 milestone Jun 7, 2019

@pepibumur pepibumur force-pushed the dictionary-plist branch from 3b1b6f8 to dc75d09 Jun 8, 2019

@xcoderobot

This comment has been minimized.

Copy link

commented Jun 8, 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.

Rubocop violations

File Line Reason
features/step_definitions/generate.rb 3 Line is too long. [164/120] (https://shopify.github.io/ruby-style-guide/#80-character-limits)
features/step_definitions/generate.rb 18 Line is too long. [167/120] (https://shopify.github.io/ruby-style-guide/#80-character-limits)
features/step_definitions/generate.rb 45 Line is too long. [125/120] (https://shopify.github.io/ruby-style-guide/#80-character-limits)
features/step_definitions/generate.rb 57 Line is too long. [122/120] (https://shopify.github.io/ruby-style-guide/#80-character-limits)

Generated by 🚫 Danger

@pepibumur pepibumur force-pushed the dictionary-plist branch from dc75d09 to f6402ab Jun 8, 2019

@pepibumur pepibumur force-pushed the dictionary-plist branch from f6758d5 to dbc42d5 Jun 20, 2019

@kwridan kwridan removed this from the 0.16.0 milestone Jun 22, 2019

@pepibumur pepibumur force-pushed the dictionary-plist branch 2 times, most recently from 1052aec to 717eac5 Jul 10, 2019

@codecov-io

This comment has been minimized.

Copy link

commented Jul 11, 2019

Codecov Report

Merging #380 into master will decrease coverage by 0.42%.
The diff coverage is 74.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #380      +/-   ##
==========================================
- Coverage   92.39%   91.96%   -0.43%     
==========================================
  Files         316      319       +3     
  Lines       16126    16259     +133     
==========================================
+ Hits        14899    14952      +53     
- Misses       1227     1307      +80
Impacted Files Coverage Δ
...TuistCore/Extensions/Dictionary+AnyEquatable.swift 0% <0%> (ø)
...torTests/Generator/DerivedFileGeneratorTests.swift 100% <100%> (ø)
...atorTests/Generator/ProjectFileElementsTests.swift 99.63% <100%> (ø) ⬆️
Sources/TuistGenerator/Linter/TargetLinter.swift 96.77% <100%> (ø) ⬆️
Tests/ProjectDescriptionTests/TargetTests.swift 100% <100%> (ø) ⬆️
...tKitTests/Generator/GeneratorModelLoaderTest.swift 98.47% <100%> (ø) ⬆️
...ts/TuistGeneratorTests/Models/InfoPlistTests.swift 100% <100%> (ø) ⬆️
...neratorTests/Generator/ProjectGeneratorTests.swift 99.19% <100%> (ø) ⬆️
...es/TuistGenerator/Generator/ProjectGenerator.swift 96.25% <100%> (+0.14%) ⬆️
Tests/ProjectDescriptionTests/InfoPlistTests.swift 100% <100%> (ø) ⬆️
... and 12 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 7923e06...a219520. Read the comment docs.

@pepibumur pepibumur changed the title [WIP] Pass Info.plist as dictionary Pass Info.plist as dictionary Jul 12, 2019

@pepibumur pepibumur requested a review from tuist/core Jul 12, 2019

@pepibumur

This comment has been minimized.

Copy link
Contributor Author

commented Jul 12, 2019

This is ready for review @tuist/core. You can use the ios_app_with_frameworks fixture to try out the changes. The Framework1 target from that project takes the Info.plist as a dictionary.

@ollieatkinson
Copy link
Member

left a comment

Just one comment, but not a merge-blocker.

Diff coverage is at 70% - just double check you're happy with that figure.

Framework1 correctly generates with the new feature.

Code changes look good to me, some nice solutions in this P/R! Good Job!

fixtures/.gitignore Show resolved Hide resolved
@kwridan
Copy link
Contributor

left a comment

Nice work!

Sources/TuistGenerator/Models/InfoPlist.swift Outdated Show resolved Hide resolved
}
"""

XCTAssertCodableEqualToJson(subject, expected)
}

func test_toJSON_when_dictionary() throws {

This comment has been minimized.

Copy link
@kwridan

kwridan Jul 13, 2019

Contributor

minor suggestion (possibly for next time we're in the area) - we can test

Manifest Type -> Encode -> Data -> Decode -> ManifestType

And then verify the resulting manifest type equals the original one, this may simplify the test and will ensure both the encode and decode paths are covered in one shot! :)

This comment has been minimized.

Copy link
@pepibumur

pepibumur Jul 13, 2019

Author Contributor

This is a good idea. I'll update it as you suggested.

features/generate.feature Show resolved Hide resolved
import TuistCore
import XcodeProj

protocol DerivedFileGenerating {

This comment has been minimized.

Copy link
@kwridan

kwridan Jul 13, 2019

Contributor

👍 this is great!

We can re-use this when continuing work on static frameworks resources to generate the Bundle.swift :)

This comment has been minimized.

Copy link
@pepibumur

pepibumur Jul 13, 2019

Author Contributor

Yeah! That's the idea. I think generating resources and code on the fly will show up in other features so I thought about having a component that helps with that.

@ollieatkinson

This comment has been minimized.

Copy link
Member

commented Jul 13, 2019

Not sure if it's specific to me, but running

swift run tuist generate --path fixtures/ios_app_with_frameworks

I get the following error when it tries to load the App manifest:

$ /usr/bin/xcrun swiftc --driver-mode=swift -suppress-warnings -I /Users/oat01/tuist/development/tuist/.build/x86_64-apple-macosx/debug -L /Users/oat01/tuist/development/tuist/.build/x86_64-apple-macosx/debug -F /Users/oat01/tuist/development/tuist/.build/x86_64-apple-macosx/debug -lProjectDescription /Users/oat01/tuist/development/tuist/fixtures/ios_app_with_frameworks/App/Project.swift --dump
Stack dump:
0.	Program arguments: /Applications/Xcode/xcode-10.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /Users/oat01/tuist/development/tuist/fixtures/ios_app_with_frameworks/App/Project.swift -enable-objc-interop -sdk /Applications/Xcode/xcode-10.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/oat01/tuist/development/tuist/.build/x86_64-apple-macosx/debug -F /Users/oat01/tuist/development/tuist/.build/x86_64-apple-macosx/debug -suppress-warnings -color-diagnostics -module-name Project -lProjectDescription -- --dump 
0  swift                       0x0000000105bd2ee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                       0x0000000105bd26bc SignalHandler(int) + 348
2  libsystem_platform.dylib    0x00007fff599ceb5d _sigtramp + 29
3  libswiftFoundation.dylib    0x00007fff900c12d8 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVWV + 64
4  libswiftCore.dylib          0x00007fff58fc7de9 $sSS23_bridgeToObjectiveCImplyXlyF + 9
5  libswiftFoundation.dylib    0x00007fff5935c153 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLV6encode_6forKeyySS_xtKF + 3747
6  libswiftFoundation.dylib    0x00007fff593c1c0c $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP6encode_6forKeyySS_0P0QztKFTWTm + 12
7  libswiftFoundation.dylib    0x00007fff59364fb0 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP6encode_6forKeyySS_0P0QztKFTW + 16
8  libswiftCore.dylib          0x00007fff58f6ee54 $ss26_KeyedEncodingContainerBoxC6encode_6forKeyySS_0G0QztKF + 36
9  libswiftCore.dylib          0x00007fff58f6711b $ss22KeyedEncodingContainerV6encode_6forKeyySS_xtKF + 75
10 libProjectDescription.dylib 0x000000010b2cc34d $s18ProjectDescription11FileElementO6encode2toys7Encoder_p_tKF + 685
11 libProjectDescription.dylib 0x000000010b2cc703 $s18ProjectDescription11FileElementOSEAASE6encode2toys7Encoder_p_tKFTW + 35
12 libswiftCore.dylib          0x00007fff591c5397 $sSE6encode2toys7Encoder_p_tKFTj + 7
13 libswiftFoundation.dylib    0x00007fff59351705 $s10Foundation13__JSONEncoder33_12768CA107A31EF2DCE034FD75B541C9LLC4box_ySo8NSObjectCSgSE_pKF + 6629
14 libswiftFoundation.dylib    0x00007fff59366c61 $s10Foundation29_JSONUnkeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLV6encodeyyxKSERzlF + 673
15 libswiftFoundation.dylib    0x00007fff593c3017 $s10Foundation29_JSONUnkeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVs07UnkeyedcD0AAsAEP6encodeyyqd__KSERd__lFTWTm + 7
16 libswiftFoundation.dylib    0x00007fff59368050 $s10Foundation29_JSONUnkeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVs07UnkeyedcD0AAsAEP6encodeyyqd__KSERd__lFTW + 16
17 libswiftCore.dylib          0x00007fff58f799aa $sSasSERzlE6encode2toys7Encoder_p_tKF + 650
18 libswiftCore.dylib          0x00007fff58f7a0a9 $sSayxGSEsSERzlSE6encode2toys7Encoder_p_tKFTWTm + 25
19 libswiftCore.dylib          0x00007fff58f79aa0 $sSayxGSEsSERzlSE6encode2toys7Encoder_p_tKFTW + 16
20 libswiftCore.dylib          0x00007fff591c5397 $sSE6encode2toys7Encoder_p_tKFTj + 7
21 libswiftFoundation.dylib    0x00007fff59351705 $s10Foundation13__JSONEncoder33_12768CA107A31EF2DCE034FD75B541C9LLC4box_ySo8NSObjectCSgSE_pKF + 6629
22 libswiftFoundation.dylib    0x00007fff593605b1 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLV6encode_6forKeyyqd___xtKSERd__lF + 4097
23 libswiftFoundation.dylib    0x00007fff593c1e93 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP6encode_6forKeyyqd___0P0QztKSERd__lFTWTm + 19
24 libswiftFoundation.dylib    0x00007fff593651b8 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP6encode_6forKeyyqd___0P0QztKSERd__lFTW + 24
25 libswiftCore.dylib          0x00007fff58f66f4e $ss30KeyedEncodingContainerProtocolPsE15encodeIfPresent_6forKeyyqd__Sg_0I0QztKSERd__lF + 238
26 libswiftFoundation.dylib    0x00007fff593654a8 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP15encodeIfPresent_6forKeyyqd__Sg_0R0QztKSERd__lFTW + 24
27 libswiftCore.dylib          0x00007fff58f6f4f7 $ss26_KeyedEncodingContainerBoxC15encodeIfPresent_6forKeyyqd__Sg_0I0QztKSERd__lF + 39
28 libswiftCore.dylib          0x00007fff58f67db3 $ss22KeyedEncodingContainerV15encodeIfPresent_6forKeyyqd__Sg_xtKSERd__lF + 83
29 libProjectDescription.dylib 0x000000010b2ead4c $s18ProjectDescription6TargetC6encode2toys7Encoder_p_tKF + 1468
30 libProjectDescription.dylib 0x000000010b2eba52 $s18ProjectDescription6TargetCSEAASE6encode2toys7Encoder_p_tKFTW + 34
31 libswiftCore.dylib          0x00007fff591c5397 $sSE6encode2toys7Encoder_p_tKFTj + 7
32 libswiftFoundation.dylib    0x00007fff59351705 $s10Foundation13__JSONEncoder33_12768CA107A31EF2DCE034FD75B541C9LLC4box_ySo8NSObjectCSgSE_pKF + 6629
33 libswiftFoundation.dylib    0x00007fff59366c61 $s10Foundation29_JSONUnkeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLV6encodeyyxKSERzlF + 673
34 libswiftFoundation.dylib    0x00007fff593c3017 $s10Foundation29_JSONUnkeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVs07UnkeyedcD0AAsAEP6encodeyyqd__KSERd__lFTWTm + 7
35 libswiftFoundation.dylib    0x00007fff59368050 $s10Foundation29_JSONUnkeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVs07UnkeyedcD0AAsAEP6encodeyyqd__KSERd__lFTW + 16
36 libswiftCore.dylib          0x00007fff58f799aa $sSasSERzlE6encode2toys7Encoder_p_tKF + 650
37 libswiftCore.dylib          0x00007fff58f7a0a9 $sSayxGSEsSERzlSE6encode2toys7Encoder_p_tKFTWTm + 25
38 libswiftCore.dylib          0x00007fff58f79aa0 $sSayxGSEsSERzlSE6encode2toys7Encoder_p_tKFTW + 16
39 libswiftCore.dylib          0x00007fff591c5397 $sSE6encode2toys7Encoder_p_tKFTj + 7
40 libswiftFoundation.dylib    0x00007fff59351705 $s10Foundation13__JSONEncoder33_12768CA107A31EF2DCE034FD75B541C9LLC4box_ySo8NSObjectCSgSE_pKF + 6629
41 libswiftFoundation.dylib    0x00007fff593605b1 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLV6encode_6forKeyyqd___xtKSERd__lF + 4097
42 libswiftFoundation.dylib    0x00007fff593c1e93 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP6encode_6forKeyyqd___0P0QztKSERd__lFTWTm + 19
43 libswiftFoundation.dylib    0x00007fff593651b8 $s10Foundation27_JSONKeyedEncodingContainer33_12768CA107A31EF2DCE034FD75B541C9LLVyxGs05KeyedcD8ProtocolAAsAFP6encode_6forKeyyqd___0P0QztKSERd__lFTW + 24
44 libswiftCore.dylib          0x00007fff58f6f0c7 $ss26_KeyedEncodingContainerBoxC6encode_6forKeyyqd___0G0QztKSERd__lF + 39
45 libswiftCore.dylib          0x00007fff58f67633 $ss22KeyedEncodingContainerV6encode_6forKeyyqd___xtKSERd__lF + 83
46 libProjectDescription.dylib 0x000000010b2d41ac $s18ProjectDescription0A0C6encode2toys7Encoder_p_tKF + 444
47 libProjectDescription.dylib 0x000000010b2d48e2 $s18ProjectDescription0A0CSEAASE6encode2toys7Encoder_p_tKFTW + 34
48 libswiftCore.dylib          0x00007fff591c5397 $sSE6encode2toys7Encoder_p_tKFTj + 7
49 libswiftFoundation.dylib    0x00007fff59351705 $s10Foundation13__JSONEncoder33_12768CA107A31EF2DCE034FD75B541C9LLC4box_ySo8NSObjectCSgSE_pKF + 6629
50 libswiftFoundation.dylib    0x00007fff5934f4bc $s10Foundation11JSONEncoderC6encodeyAA4DataVxKSERzlF + 476
51 libswiftFoundation.dylib    0x00007fff594581fe $s10Foundation11JSONEncoderC6encodeyAA4DataVxKSERzlFTj + 14
52 libProjectDescription.dylib 0x000000010b2caa73 $s18ProjectDescription12dumpIfNeededyyxSERzlF + 403
53 libProjectDescription.dylib 0x000000010b2d29c7 $s18ProjectDescription0A0C4name8settings7targets7schemes15additionalFilesACSS_AA8SettingsCSgSayAA6TargetCGSayAA6SchemeCGSayAA11FileElementOGtcfc + 311
54 libProjectDescription.dylib 0x000000010b2d2830 $s18ProjectDescription0A0C4name8settings7targets7schemes15additionalFilesACSS_AA8SettingsCSgSayAA6TargetCGSayAA6SchemeCGSayAA11FileElementOGtcfC + 112
55 libProjectDescription.dylib 0x00000001071936da $s18ProjectDescription0A0C4name8settings7targets7schemes15additionalFilesACSS_AA8SettingsCSgSayAA6TargetCGSayAA6SchemeCGSayAA11FileElementOGtcfC + 4226551578
56 swift                       0x000000010246a38d llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 365
57 swift                       0x0000000102470762 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 1090
58 swift                       0x0000000101a39831 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 58929
59 swift                       0x0000000101a2792e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
60 swift                       0x00000001019c59ce main + 1246
61 libdyld.dylib               0x00007fff597e33d5 start + 1
Segmentation fault: 11
@ollieatkinson

This comment has been minimized.

Copy link
Member

commented Jul 13, 2019

Ignore the above, looks like a bug with swift run not compiling the latest ProjectDescription.framework.

The following works:

$ swift build --product tuist
$ swift run tuist generate --path fixtures/ios_app_with_frameworks

@pepibumur pepibumur force-pushed the dictionary-plist branch from d962e4b to a219520 Jul 14, 2019

@pepibumur pepibumur merged commit 58c6580 into master Jul 15, 2019

7 of 9 checks passed

Header rules No header rules processed
Details
Pages changed 18 new files uploaded
Details
Mixed content No mixed content detected
Details
Redirect rules 1 redirect rule processed
Details
ci/circleci: cli Your tests passed on CircleCI!
Details
ci/circleci: galaxy Your tests passed on CircleCI!
Details
ci/circleci: install Your tests passed on CircleCI!
Details
danger/danger ⚠️ 1 Warning. Don't worry, everything is fixable.
Details
deploy/netlify Deploy preview ready!
Details

@pepibumur pepibumur deleted the dictionary-plist branch Jul 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.