Support paths directly to xcassets

Pretend xcassets are files to allow top-level xcassets in the spec.
This commit is contained in:
Brandon Kase
2017-11-08 11:10:21 -08:00
parent 5789a1110a
commit 496a7cc4b0
6 changed files with 114 additions and 2 deletions
@@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
@@ -16,6 +16,7 @@
BF2445564001 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = VG2858723001 /* LaunchScreen.storyboard */; };
BF2513089601 /* LocalizedStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = VG3182922801 /* LocalizedStoryboard.storyboard */; };
BF2535278401 = {isa = PBXBuildFile; fileRef = FR4387045301 /* Framework_watchOS.framework */; };
BF2754797601 /* StandaloneAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FR5557707101 /* StandaloneAssets.xcassets */; };
BF3008399601 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FR3032072503 /* Alamofire.framework */; };
BF3154421201 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FR5980633301 /* Assets.xcassets */; settings = {COMPILER_FLAGS = "-Werror"; }; };
BF3314441201 = {isa = PBXBuildFile; fileRef = FR5251191201 /* Framework_macOS.framework */; };
@@ -86,6 +87,7 @@
FR4722960401 /* Framework_iOS.framework */ = {isa = PBXFileReference; explicitFileType = framework; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = Framework_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FR4822987701 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LocalizedStoryboard.storyboard; sourceTree = "<group>"; };
FR5251191201 /* Framework_macOS.framework */ = {isa = PBXFileReference; explicitFileType = framework; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = Framework_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FR5557707101 /* StandaloneAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = StandaloneAssets.xcassets; sourceTree = "<group>"; };
FR5980633301 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
FR6218091901 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
FR6334256101 /* config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = config.xcconfig; sourceTree = "<group>"; };
@@ -236,6 +238,7 @@
G66512504301 /* StandaloneFiles */ = {
isa = PBXGroup;
children = (
FR5557707101 /* StandaloneAssets.xcassets */,
FR2554453101 /* Standalone.swift */,
);
name = StandaloneFiles;
@@ -293,8 +296,8 @@
children = (
G83406189501 /* Configs */,
G32346300301 /* FileGroup */,
G82523211001 /* App_iOS */,
G66512504301 /* StandaloneFiles */,
G82523211001 /* App_iOS */,
G78312289901 /* App_iOS_Tests */,
G46615002701 /* Framework */,
G86202385201 /* Products */,
@@ -526,6 +529,7 @@
BF4414242001 /* Localizable.stringsdict in Resources */,
BF2513089601 /* LocalizedStoryboard.storyboard in Resources */,
BF2250910101 /* Main.storyboard in Resources */,
BF2754797601 /* StandaloneAssets.xcassets in Resources */,
);
};
/* End PBXResourcesBuildPhase section */
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
+1
View File
@@ -12,6 +12,7 @@ targets:
type: application
platform: iOS
sources:
- StandaloneFiles/StandaloneAssets.xcassets
- path: App_iOS
compilerFlags:
- "-Werror"
+2 -1
View File
@@ -563,7 +563,8 @@ public class PBXProjGenerator {
func getSources(sourceMetadata source: Source, path: Path, depth: Int = 0) throws -> (sourceFiles: [SourceFile], groups: [PBXGroup]) {
// if we have a file, move it to children and use the parent as the path
let (children, path) = path.isFile ?
// pretend xcassets are files
let (children, path) = path.isFile || path.extension == "xcassets" ?
([path], path.parent()) :
(try path.children().sorted(), path)
@@ -304,6 +304,7 @@ func projectGeneratorTests() {
Sources:
A:
- a.swift
- Assets.xcassets
- B:
- b.swift
- c.jpg
@@ -313,6 +314,7 @@ func projectGeneratorTests() {
target.sources = [
"Sources/A/a.swift",
"Sources/A/B/b.swift",
"Sources/A/Assets.xcassets",
"Sources/A/B/c.jpg",
]
spec.targets = [target]
@@ -321,6 +323,7 @@ func projectGeneratorTests() {
try project.expectFile(paths: ["Sources/A", "a.swift"], names: ["A", "a.swift"], buildPhase: .sources)
try project.expectFile(paths: ["Sources/A/B", "b.swift"], names: ["B", "b.swift"], buildPhase: .sources)
try project.expectFile(paths: ["Sources/A/B", "c.jpg"], names: ["B", "c.jpg"], buildPhase: .resources)
try project.expectFile(paths: ["Sources/A", "Assets.xcassets"], names: ["A", "Assets.xcassets"], buildPhase: .resources)
}
}
}