-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Xcodeproj] Avoid generating module.modulemap
if umbrella header exists, on creating Clang Module targets
#1406
Conversation
…ating the clangModule target If clang module has umbrella header: - Add headers to `HeadersBuildPhase` - Set CLANG_ENABLE_MODULES = YES - Set DEFINES_MODULE = YES - Don’t generate `module.modulemap`
`Xcode.BuildFile.Settings` and` Xcode.BuildSettingsTable.BuildSettings` conform to that.
This looks fine to me but I am not completely sure if there would be any unexpected fallout from this. @ddunbar @abertelrud Can you guys review this patch? |
Sources/Xcodeproj/pbxproj().swift
Outdated
isGenerated = true | ||
let umbrellaHeaderName = clangTarget.c99name + ".h" | ||
if includeGroup.subitems.contains(where: { $0.path == umbrellaHeaderName }) { | ||
// if umbrellaHeader exists, we can use module. |
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 would say something like:
// If an umbrella header exists, enable Xcode's builtin module's feature rather than generating
// a custom module map. This increases the compatibility of generated Xcode projects.
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.
That said...
Why can't we always generate a module.modulemap file, and then set the MODULEMAP_FILE build setting to point at it. That should let Xcode's builtin logic work, but can work universally without needing the else
branch here.
This change seems reasonable to me, but I would prefer if we could always generate a file for |
My main concern here is I don't want to land a change which improves compatibility, but only for some targets, and in a way which wouldn't be discoverable to a user. |
Sources/Xcodeproj/pbxproj().swift
Outdated
if includeGroup.subitems.contains(where: { $0.path == umbrellaHeaderName }) { | ||
// If an umbrella header exists, enable Xcode's builtin module's feature rather than generating | ||
// a custom module map. This increases the compatibility of generated Xcode projects. | ||
targetSettings.common.CLANG_ENABLE_MODULES = "YES" |
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 this different from DEFINES_MODULE?
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.
Xcode's Quick Help said:
CLANG_ENABLE_MODULES
--
Boolean
Enables the use of modules for system APIs. System headers are imported as semantic modules instead of raw headers. This can result in faster builds and project indexing.
I am setting this by mimicking the framework target settings generated by Xcode.
I do not know if it is essential to set this to YES, but I have never had any troubles with doing this.
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 do not know if it is essential to set this to YES,
I confirmed that this setting is required by testing on https://github.com/jpsim/Yams
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.
Ah cool. Can you also implement the MODULEMAP_FILE
setting that @ddunbar suggested?
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'll try.
Updated to:
|
Sources/Xcodeproj/pbxproj().swift
Outdated
} | ||
targetSettings.common.CLANG_ENABLE_MODULES = "YES" | ||
targetSettings.common.DEFINES_MODULE = "YES" |
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 does not set DEFINES_MODULE=YES
if user defined modulemap exists, since I don't know about the issue mentioned in following comment:
// Disable defines target for clang target because our clang targets are not proper framework targets.
// Also see: <rdar://problem/29825757>
targetSettings.common.DEFINES_MODULE = "NO"
Thank you so much for taking the initiative to open up this pull request, @norio-nomura! Curious to know your thoughts on the request as it sits, @ddunbar. |
Sorry for the very long delay, I am testing and experimenting with this today... |
Any updates on this? |
Sorry that this PR has been sitting for so long on me. I created a new PR based on @norio-nomura work. Thank you for working on this! |
This was rewritten #955 for master.
This PR increases the portability of generated Xcode project by reducing the use of
module.modulemap
which absolute path contains.HeadersBuildPhase
CLANG_ENABLE_MODULES
=YES
DEFINES_MODULE
=YES
module.modulemap
CLANG_ENABLE_MODULES
=YES
to test target so that we can import clang module.In the course of testing to create a package written only in Objective-C, I came up with this change.
e.g: https://github.com/norio-nomura/GTMNSString_HTML