I am developing a server in Swift and using the Swift Package Manager. And find it convenient when doing my development on my Mac OS system to generate a Xcode project to use Xcode as my IDE (i.e., From time to time, my package dependencies have to be updated. I've been using swift package generate-xcodeproj
to do this. My problem comes in at this point-- I have created some settings in Xcode. E.g., I've set a DEBUG flag, and I have a .plist file that is in the Copy Files Phase. These get lost when I regenerate the Xcode project. It seems I cannot simply use swift package update
because sometimes files change in the dependencies and these don't get propagated to the Xcode project.
What I'd like is a means to separately establish Xcode settings in a file outside of Xcode, that can be imported into Xcode when I do the swift package generate-xcodeproj
. I have not seen a way to do this.
A related question is: When I do a swift build
I'd like those same build settings to be used.
Suggestions?
I can't help with Copy Files Phase
.
However I have just been toying with conditional compilation, like this:
swift package generate-xcodeproj --xcconfig-overrides Sandbox.xcconfig
FLAG_SANDBOX = -DSANDBOX
OTHER_SWIFT_FLAGS = $(FLAG_SANDBOX)
This creates an Xcode project where SANDBOX
is definded.
This can be used in swift code like this
#if SANDBOX
print("sandbox")
#else
print("production")
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With