Skip to content
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

Adds SWIFT_PACKAGE preprocessor definition #221

Merged
merged 1 commit into from
Mar 11, 2023
Merged

Adds SWIFT_PACKAGE preprocessor definition #221

merged 1 commit into from
Mar 11, 2023

Conversation

lukewakeford
Copy link
Contributor

@lukewakeford lukewakeford commented Mar 6, 2023

Adds SWIFT_PACKAGE flag for resolving correct path to yoga imports.

Fixes issue #219 where including FlexLayout as a dependency of another swift package would fail to build - because it isn't possible to set the preprocessor definition FLEXLAYOUT_SWIFT_PACKAGE=1 without an Xcode project.

From the SPM Documentation:

You may be working with code that builds both as a package and not. For example, you may be packaging a project that also builds with Xcode.

In these cases, you can use the preprocessor definition SWIFT_PACKAGE to conditionally compile code for Swift packages.

In your source file:

#if SWIFT_PACKAGE
import Foundation
#endif

edit: I have update this PR to avoid breaking changes. It now avoids removing the FLEXLAYOUT_SWIFT_PACKAGE flag that people are already using.

#if FLEXLAYOUT_SWIFT_PACKAGE || SWIFT_PACKAGE

@lukewakeford lukewakeford changed the title Uses built in SWIFT_PACKAGE flag Replaces FLEXLAYOUT_SWIFT_PACKAGE with built in SWIFT_PACKAGE flag Mar 6, 2023
@lukewakeford lukewakeford changed the title Replaces FLEXLAYOUT_SWIFT_PACKAGE with built in SWIFT_PACKAGE flag Adds SWIFT_PACKAGE preprocessor definition Mar 7, 2023
@lucdion
Copy link
Member

lucdion commented Mar 7, 2023

@lukewakeford, I agree that it is a good idea to support the previous FLEXLAYOUT_SWIFT_PACKAGE, but why did you revert all other changes, including Readme and sample's xcodeproj changes? Your idea of using the SWIFT_PACKAGE preprocessor definition is a very good idea.

@lukewakeford
Copy link
Contributor Author

@lucdion glad you like it 👍🏻

why did you revert all other changes, including Readme and sample's xcodeproj changes?

Because adding a flag is still required when installing the package in to an Xcode project - and I actually think using the custom FLEXLAYOUT_SWIFT_PACKAGE flag in this context is better for clarity of what it's being used for. Also the SWIFT_PACKAGE flag is very generic and may have undesired affects on other frameworks if used in this scenario.

The only bit I wasn't sure about were the target settings in Package.swift - I'm not 100% sure what these are for so I reverted my change, that said, the project did build fine without them for me. What do you think?

cSettings: [
  .define("FLEXLAYOUT_SWIFT_PACKAGE")
],
cxxSettings: [
  .define("FLEXLAYOUT_SWIFT_PACKAGE"),
  .headerSearchPath("include/yoga/"),
  .headerSearchPath("./")
],
swiftSettings: [
  .define("FLEXLAYOUT_SWIFT_PACKAGE")
]

@lucdion lucdion merged commit 4677936 into layoutBox:master Mar 11, 2023
@lucdion
Copy link
Member

lucdion commented Mar 11, 2023

The release https://github.com/layoutBox/FlexLayout/releases/tag/1.3.30 includes your change. Thanks

@lukewakeford
Copy link
Contributor Author

Excellent thanks 🚀

stleamist added a commit to daangn/FlexLayout that referenced this pull request May 26, 2023
…package_flag"

This reverts commit 4677936, reversing
changes made to 1c9b64a.
cheonsong pushed a commit to pink-boss/FlexLayout that referenced this pull request Jun 1, 2023
…package_flag"

This reverts commit 4677936, reversing
changes made to 1c9b64a.
@lucdion
Copy link
Member

lucdion commented Jun 19, 2023

Hi @lukewakeford , someone has open a story that revert your changes: #226

To be honest, I am not sure what to think

You can comment directly on this new PR. Thanks

@lukewakeford
Copy link
Contributor Author

Thanks @lucdion i'll take another look. hopefully there is a way that both routes can still work.

@lucdion
Copy link
Member

lucdion commented Jun 19, 2023

Yes, thanks for checking that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants