The default generated project does not include a LaunchScreen storyboard (#1911)

* The default generated project does not include a LaunchScreen storyboard

* Fix a location of LaunchScreen.stencil

* Support launch screen per platform
This commit is contained in:
Daniel Jankowski 2020-10-19 10:27:41 +02:00 committed by GitHub
parent 75acfe87bf
commit d250c5408a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 3 deletions

View File

@ -18,6 +18,8 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
- Allow build phase scripts to disable dependency analysis [#1883](https://github.com/tuist/tuist/pull/1883) by [@bhuemer](https://github.com/bhuemer). - Allow build phase scripts to disable dependency analysis [#1883](https://github.com/tuist/tuist/pull/1883) by [@bhuemer](https://github.com/bhuemer).
- The default generated project does not include a LaunchScreen storyboard [#265](https://github.com/tuist/tuist/issues/265) by [@mollyIV](https://github.com/mollyIV).
## 1.21.0 - PBWerk ## 1.21.0 - PBWerk
### Added ### Added

View File

@ -43,7 +43,19 @@ public final class TemplateGenerator: TemplateGenerating {
attributes.reduce(template.files) { files, attribute in attributes.reduce(template.files) { files, attribute in
files.map { files.map {
let path = RelativePath($0.path.pathString.replacingOccurrences(of: "{{ \(attribute.key) }}", with: attribute.value)) let path = RelativePath($0.path.pathString.replacingOccurrences(of: "{{ \(attribute.key) }}", with: attribute.value))
return Template.File(path: path, contents: $0.contents)
var contents = $0.contents
if case let Template.Contents.file(path) = contents {
contents = .file(
AbsolutePath(
path.pathString.replacingOccurrences(
of: "{{ \(attribute.key) }}", with: attribute.value
)
)
)
}
return Template.File(path: path, contents: contents)
} }
} }
} }

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
</dependencies>
<scenes/>
</document>

View File

@ -46,7 +46,8 @@ extension Project {
let infoPlist: [String: InfoPlist.Value] = [ let infoPlist: [String: InfoPlist.Value] = [
"CFBundleShortVersionString": "1.0", "CFBundleShortVersionString": "1.0",
"CFBundleVersion": "1", "CFBundleVersion": "1",
{% if platform == "macOS" %}"NSMainStoryboardFile"{% else %}"UIMainStoryboardFile"{% endif %}: "" {% if platform == "macOS" %}"NSMainStoryboardFile"{% else %}"UIMainStoryboardFile"{% endif %}: "",
"UILaunchStoryboardName": "LaunchScreen"
] ]
let mainTarget = Target( let mainTarget = Target(
@ -56,7 +57,7 @@ extension Project {
bundleId: "io.tuist.\(name)", bundleId: "io.tuist.\(name)",
infoPlist: .extendingDefault(with: infoPlist), infoPlist: .extendingDefault(with: infoPlist),
sources: ["Targets/\(name)/Sources/**"], sources: ["Targets/\(name)/Sources/**"],
resources: [], resources: ["Targets/\(name)/Resources/**"],
dependencies: dependencies dependencies: dependencies
) )

View File

@ -24,6 +24,8 @@ let template = Template(
templatePath: templatePath("AppProject.stencil")), templatePath: templatePath("AppProject.stencil")),
.file(path: appPath + "/Sources/AppDelegate.swift", .file(path: appPath + "/Sources/AppDelegate.swift",
templatePath: "AppDelegate.stencil"), templatePath: "AppDelegate.stencil"),
.file(path: appPath + "/Resources/LaunchScreen.storyboard",
templatePath: templatePath("LaunchScreen+\(platformAttribute).stencil")),
.file(path: appPath + "/Tests/AppTests.swift", .file(path: appPath + "/Tests/AppTests.swift",
templatePath: templatePath("AppTests.stencil")), templatePath: templatePath("AppTests.stencil")),
.file(path: kitFrameworkPath + "/Sources/\(nameAttribute)Kit.swift", .file(path: kitFrameworkPath + "/Sources/\(nameAttribute)Kit.swift",

View File

@ -30,6 +30,8 @@ let template = Template(
templatePath: "main.stencil"), templatePath: "main.stencil"),
.file(path: appPath + "/Sources/ContentView.swift", .file(path: appPath + "/Sources/ContentView.swift",
templatePath: "ContentView.stencil"), templatePath: "ContentView.stencil"),
.file(path: appPath + "/Resources/LaunchScreen.storyboard",
templatePath: templatePath("LaunchScreen+\(platformAttribute).stencil")),
.file(path: appPath + "/Tests/AppTests.swift", .file(path: appPath + "/Tests/AppTests.swift",
templatePath: templatePath("AppTests.stencil")), templatePath: templatePath("AppTests.stencil")),
.file(path: kitFrameworkPath + "/Sources/\(nameAttribute)Kit.swift", .file(path: kitFrameworkPath + "/Sources/\(nameAttribute)Kit.swift",

View File

@ -98,19 +98,25 @@ final class TemplateGeneratorTests: TuistTestCase {
func test_files_are_generated_with_attributes() throws { func test_files_are_generated_with_attributes() throws {
// Given // Given
let sourcePath = try temporaryPath()
let files = [ let files = [
Template.File(path: RelativePath("{{ name }}"), contents: .string("{{ contentName }}")), Template.File(path: RelativePath("{{ name }}"), contents: .string("{{ contentName }}")),
Template.File(path: RelativePath("{{ directoryName }}/{{ fileName }}"), contents: .string("bContent")), Template.File(path: RelativePath("{{ directoryName }}/{{ fileName }}"), contents: .string("bContent")),
Template.File(path: RelativePath("file"), contents: .file(sourcePath.appending(component: "{{ filePath }}"))),
] ]
let template = Template.test(files: files) let template = Template.test(files: files)
let name = "test name" let name = "test name"
let contentName = "test content" let contentName = "test content"
let fileContent = "test file content"
let directoryName = "test directory" let directoryName = "test directory"
let fileName = "test file" let fileName = "test file"
let filePath = "test file path"
let destinationPath = try temporaryPath() let destinationPath = try temporaryPath()
try FileHandler.shared.write(fileContent, path: sourcePath.appending(component: filePath), atomically: true)
let expectedFiles: [(AbsolutePath, String)] = [ let expectedFiles: [(AbsolutePath, String)] = [
(destinationPath.appending(component: name), contentName), (destinationPath.appending(component: name), contentName),
(destinationPath.appending(components: directoryName, fileName), "bContent"), (destinationPath.appending(components: directoryName, fileName), "bContent"),
(destinationPath.appending(component: filePath), fileContent),
] ]
// When // When
@ -121,6 +127,7 @@ final class TemplateGeneratorTests: TuistTestCase {
"contentName": contentName, "contentName": contentName,
"directoryName": directoryName, "directoryName": directoryName,
"fileName": fileName, "fileName": fileName,
"filePath": filePath,
]) ])
// Then // Then