Hi!
I use SwiftGen in most of my current projects, and things could not be better :)
We have a fairly large Localizable.strings file at work, but SwiftGen runs fast when building in Xcode. It finishes in a couple of seconds.
However, when we build the app with Fastlane, both locally and at our build server, SwiftGen takes a long time (~ 1.5 min), see screenshot:
Any ideas to why this is the case?
Hi
What version of SwiftGen are you using?
Could it be that environment variables used by your script build phase are different between Xcode and Fastlane, making something like swiftgen strings $SOME_PATH parse a different directory on CI than in Xcode, or something similar?
What does your script build phase look like?
Hi Ali, sorry for the slow reply!
(The SwiftGen presentation went great btw :)
We use SwiftGen 4. The build phase looks like this:
$PODS_ROOT/SwiftGen/bin/swiftgen strings -t swift3 --output ${PROJECT_DIR}/xxx/SupportingFiles/Localizable.swift ${PROJECT_DIR}/xxx/SupportingFiles/sv.lproj/Localizable.strings
Thx!
Could you look at the full log (the one not cleaned by xcpretty) to see if we have a more verbose output and details about what's going on during this build phase?
This full log should be visible in ~/Library/Logs/gym/<Project>-<Scheme>.log iirc.
(Or you can also disable xcpretty in your Fastfile on your call to gym)
Hi again,
I had a look at the build log, but it doesn't say me much. SwiftGen takes 10+ minutes, but I cannot understand why. This happens both on my machine and on the build server, and only when buolding with Fastlane. In XCode, SwiftGen is super fast.
Would you like to see the full build log, if it tells you anything? If so, how would you like me to dump the log? It's monstrously huge.
Post it on http://pastebin.com or something similar.
@danielsaidi also in case you can share the project (or at least a skimmed version of it containing just your big Localizable.strings without any of the sensitive information nor rest of the sensitive files that don't affect the process, as long as it reproduces the issue) that would allow us to test on our end locally.
I've tested with a project of mine also using Fastlane and didn't see any timing issue but maybe my Localizable.strings didn't contain that specific case you might have that introduce the issue in my end, so interested in yours
Things piled up here at work, so I haven't had time to work more on this, other than confirming that running SwiftGen on the strings file is lightning fast both in Xcode and when calling the SwiftGen script from the terminal. Keep this thread alive, and I will setup a new Fastlane lane that only builds the application and see if I can pinpoint the problem.
Ok, so here's an anonymized dump of the SwiftGen build phase log when running a local Xcode build from within Xcode: http://pastebin.com/XgBUNxFS
The build phase is still this right?
$PODS_ROOT/SwiftGen/bin/swiftgen strings -t swift3 --output ${PROJECT_DIR}/xxx/SupportingFiles/Localizable.swift ${PROJECT_DIR}/xxx/SupportingFiles/sv.lproj/Localizable.strings
Could you, for comparison's sake, also provide the log when building via fastlane?
Yep, I have prepared the build server log as well, but when I diff the local Xcode build phases log with the build server one, Sublime says the logs are identical.
Ok, I have created a build-only lane with the following setup:
desc "Build the app"
lane :build do
begin
use_dev_settings
gym(
scheme: "DEBUG_BUILD_SAME_AS_WHEN_RUNNING_IN_APP",
workspace: "PROJECT_NAME.xcworkspace",
clean: true,
use_legacy_build_api: true
)
end
end
When running locally, SwiftGen now takes two minutes. The corresponding time on the build server is now 10:15 minutes.
I now noticed that the Fastlane builds are using the legacy build switch. I will investigate if this may cause the build phase to execute slowly.
Ok, I will call bullshit on this build log. Adding an empty run script build phase after the SwiftGen phase shows that SwiftGen actually finishes immediately:
The logger must then enter silent mode for a looooong while...giving the illusion of being stuck at the SwiftGen state. Sorry for wasting your time :(
No problem 😄
Can I assume this is closed then?
@danielsaidi Ah, cool. That's also why I was interested by the full log output, not the one prettified by xcpretty (which filters the log output and reformat it nicely, but sometimes filtering too much stuff), but the one in the log file (~/Library/Logs/gym/<Project>-<Scheme>.log) which isn't filtered.
Maybe you'll see the same pause after the last script build phase and before the "Compile Sources" build phase, but maybe you'll see more logs, something like "Resolving dependencies" or whatnot that would have been filtered by xcpretty (hence the impression of being stuck) but would be present in the full log showing that there was some activity anyway…
Anyway, thanks for the feedback, it was an interesting one. I assume we can close this indeed then :wink:
Yeah, this was the last script phase before Compile Sources :D Thank you!