Re-Order "Copy Bundle Resources" before "Compile Sources"
In order to execute third party framework I had to move "Copy Bundle Resources" before "Compile Sources" in "Build Phases".
Is there any way to change Build Phases order of those two setting in the project.yml file?
I do face the same problem. I also want to move the Copy bundle Resources phase before the Compile Sources. I do not see a way of doing it. I now need to patch in a custom script in thepostGenCommand command.
There are multiple possible solutions:
- Always place the
Copy bundle ResourcesbeforeCompile Sources(but this is non default for an new Xcode project. - Add a property to a target where you can toggle if you want this behaviour. (something like:
Target.shouldCopyResourcesBeforeSourceCompile
And here -> https://github.com/yonaskolb/XcodeGen/blob/master/Sources/XcodeGenKit/PBXProjGenerator.swift#L1080 the following code:
func addresourcesBuildPhase() {
let resourcesBuildPhaseFiles = getBuildFilesForPhase(.resources) + copyResourcesReferences
if !resourcesBuildPhaseFiles.isEmpty {
let resourcesBuildPhase = addObject(PBXResourcesBuildPhase(files: resourcesBuildPhaseFiles))
buildPhases.append(resourcesBuildPhase)
}
}
if target.shouldCopyResourcesBeforeSourceCompile {
addresourcesBuildPhase()
}
let sourcesBuildPhaseFiles = getBuildFilesForPhase(.sources)
let shouldSkipSourcesBuildPhase = sourcesBuildPhaseFiles.isEmpty && target.type.canSkipCompileSourcesBuildPhase
if !shouldSkipSourcesBuildPhase {
let sourcesBuildPhase = addObject(PBXSourcesBuildPhase(files: sourcesBuildPhaseFiles))
buildPhases.append(sourcesBuildPhase)
}
buildPhases += try target.postCompileScripts.map { try generateBuildScript(targetName: target.name, buildScript: $0) }
if !target.shouldCopyResourcesBeforeSourceCompile {
addresourcesBuildPhase()
}
- Add an property to a target to manually order all build phases. (The
PBXProjGenerator.swiftneeds some refactoring to support his. Because the data for an phase is now coupled to the order. - Add an property to a target to order all build phases and filter the phases at the end to have your wanted ordering.
- Add support to place files before the
compile sourcesphase with thebuildPhase.copyFilesoption.
@yonaskolb witch direction do you suggest?
We're facing the same issue with our app. @yonaskolb any thoughts on this?
So I understand the problem better, how is this failing? What step or framework has this requirement and why does it break?
In the project I'm using it it validates the assets during the build phase. Thus the assets should be already located in the app otherwise I'm not able to validate the assets.
In the project I'm using it it validates the assets during the build phase. Thus the assets should be already located in the app otherwise I'm not able to validate the assets.
The compile sources step validates the resources, or how does it do that? Or is it a custom run script?
In any case maybe a property on target resourcesBeforeSourcesBuildPhase could be the way to go. A list of phase types for total order control might be powerful, but perhaps overkill for the complexity it would add
Happy to accept a PR
Indeed the validation is done in a custom build script.
Thank you for pointing me out for the direction to go. I've created a pr to add this to the project. See https://github.com/yonaskolb/XcodeGen/pull/1351
This issue can now be closed because it is resolved by https://github.com/yonaskolb/XcodeGen/pull/1351 and is released in https://github.com/yonaskolb/XcodeGen/releases/tag/2.35.0