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
Set 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' to YES in Debug mode #8172
Set 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' to YES in Debug mode #8172
Conversation
23bc25a
to
6810804
Compare
@amorde isn't this maybe fixed with updated xcodeproj gem settings? |
6810804
to
d1bbbac
Compare
@dnkoutso Does the xcodeproj gem generate some of the build settings for CocoaPods? |
I tried updating the spec submodule to fix the tests, but I think that caused other failures |
hmm, the only thing that changed with my fix to Xcodeproj were Swift optimization settings, I didn't see any changes related to this |
but yes @icecrystal23 Xcodeproj defines the default build settings for the different targets (ex. App, Framework, static library, watch extension, etc.) |
Should I make this fix in there, then? |
haven't had a chance to take a deeper look at this - what does Xcode do if you were to mimic the setup using Xcode's UI? As in creating the targets manually within Xcode |
The Xcode UI does not set this setting. This is actually a workaround for a bug in Xcode 10 (I had a bug filed with Apple, and they told me to use this workaround... I'm not sure if I convinced them that it is their bug or not). It only seems to affect unit test targets. For some reason, Xcode 10 fails to recognize which Swift standard libraries are required for frameworks embedded in unit test targets. |
We had been working around this with a post_install hook for our projects, but then I started seeing the same unit test failure when I tried to push one of our internal CocoaPod libraries to our internal spec repo. |
I see, thanks for the background info. Do you have an openradar link? If this is a workaround for an Xcode bug I feel like it should be in CocoaPods instead of Xcodeproj but don't feel strongly either way |
@installer.send(:add_target).resolved_build_setting('ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES').should == { | ||
'Release' => nil, | ||
'Debug' => 'YES', | ||
'Test' => nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like Test
would need the fix as well, no? is the fix only applied to Debug
configurations so that it only applies to unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was only applied to Debug mostly so it doesn't affect Release mode and app size. I don't actually know what the Test configuration is typically used for; we don't use that one ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CocoaPods has the concept of build configurations which behave similar to the standard Debug
& Release
(can't seem to find any docs on it atm) so I think this would need to be applied to any Debug-like configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way to tell which configurations are supposed to behave like Debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the debug?
method on Xcodeproj::Project::Object::XCBuildConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the implementation to use the debug?
check, but it still results in Test
being nil
for this test
@amorde http://www.openradar.me/radar?id=4970867087900672 |
Thanks for the radar link, sounds like this is something specific about mismatched Swift versions and test bundles. I think the change might be too broad here since it will apply to any target (not just targets which have associated test bundles). I'd like another dev to weigh in on this as I feel like I'm missing part of the picture here |
Also realized this seems related: #8139 |
We've got this problem and our Swift version is currently set to 4.0 for all targets. |
… embed necessary swift libraries
d1bbbac
to
acae0ba
Compare
Haven't forgotten about this - if anyone needs a workaround while this is in review: post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
end
end
end Edit: @icecrystal23 has a more comprehensive workaround here #8139 (comment) |
Has it still being forgotten about? :) |
I'm hesitant to put specific workarounds like this in if it's something that Xcode will fix, especially given it's specific to certain Swift versions and its something we might have to keep around for a while or immediately remove on the next Xcode patch |
Looks like this is fixed in the latest Xcode beta, so I'm going to close this. Still, thanks for the PR! |
We're seeing similar issues again in Xcode 11 betas (as noted in #8139 ). The workaround is simple and only affects DEBUG builds. Can you reconsider accepting this PR? |
This works around a bug in Xcode 10 where unit test targets don't correctly embed the necessary Swift libraries into unit test targets.