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

[SR-9559] Import generated Xcode project via SwiftPM built from a project with Clang library dependency in an app target causes a build failure #4736

Closed
pitiphong-p opened this issue Dec 21, 2018 · 1 comment
Labels

Comments

@pitiphong-p
Copy link

Previous ID SR-9559
Radar None
Original Reporter @pitiphong-p
Type Bug
Status Closed
Resolution Invalid
Environment

Swift 4.2.1 Xcode 10.1

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 82e8a19f301b596ce1e99c01395f5096

Issue Description:

I have an issue with Swift PM and generated Xcode project. Here's a summary of the project setup

  1. I have a framework project defined and generated with Swift PM Package.swift

  2. In that Package.swift, it has a few dependencies which are Swift library and Clang library. In this case is the Swift gRPC project which include CgRPC as a dependency

  3. I generated the Xcode project file with that `swift package-manager --generate-xcodeproj` command and add that project into my main app Xcode project

  4. I added the built framework as an dependency and try to build it

The result is a build failed with `missing module CgRPC` error.

I try to investigate on this and found that

  1. CgRPC has a module.modulemap file in its `include` folder with its umbrella header along with some header files in a few folders

  2. Since it has a few folders in the include folder, it can't be able to rely on Swift PM module map generation code due to that Swift PM has a flat header folder requirement

  3. SwiftPM will use the defined `module.modulemap` file if it existed (which is in this case)

  4. However the default behavior is that Swift PM won't enable module for Clang target even there is a built in module.modulemap file. It will enable for only the case that it can't find built in module map but it can find an umbrella header. https://github.com/apple/swift-package-manager/blame/master/Sources/Xcodeproj/pbxproj().swift#L583

  5. I tried to modify the generated Xcode project file by enable that CgRPC target as a module and add its umbrella header to the Add Header build phase and it works. The app target can be built successfully and the auto complete in both the source editor and debugging console works

So my question is that, is this an intended behavior? Should we change the behavior of the built-in module map case to be the same as the built-in umbrella header case?

@pitiphong-p
Copy link
Author

Here's my initial implementation for the fix by adding those headers to the Add Header Phase for Clang Lib Target
https://github.com/pitiphong-p/swift-package-manager/tree/add-included-header-for-clang-lib-target

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant