Skip to content

Support Modular Framework modulemap #251

Closed
@frogcjn

Description

@frogcjn

What is the problem or limitation you are having?

As discussed in #249

we should update the location of module.modulemap and its content to fit the preference of Darwin-styled framework.
it will support Xcode automatically mapping to Xcode's Framework Search Paths (-F) instead of changing Build Settings of Header Search Paths.

Describe the solution you'd like

  1. We should update the module.modulemap into the right location into Python.framework/Modules folder
    and update its content to:
framework module Python {
    umbrella header "Python.h"
    export *
    link "Python"
}
  1. edit the content in the file Headers/cpython/pyatomic.h:

    • replace cpython/pyatomic_gcc.h with pyatomic_gcc.h
    • replace cpython/pyatomic_std.h with pyatomic_std.h
    • replace cpython/pyatomic_msc.h with pyatomic_msc.h
  2. Delete the setting of Target - Build settings - Search path - Header Search Paths in Xcode

Describe alternatives you've considered

Keep current design, but notice developer to adjust Target - Build settings - Search path - Header Search Paths to $(BUILT_PRODUCTS_DIR)/Python.framework/Headers in Xcode.

Additional context

the difference between framework module a non-framework module is:
https://chatgpt.com/share/67b02a23-00d8-8004-abdc-f21bf070b7c5

the difference between framework modulemap and non-framework modulemap module is:
https://chatgpt.com/share/67b029dd-5ae4-8004-a4ab-7a0c37db8f11

The right location of framework modulemap is also documented on clang website:
截屏2025-02-14 20 26 04

  1. make sure the framework modulemap file in the Python.framework/Modules folder has framework keyword and link "python" line as:
framework module Python {
    umbrella header "Python.h"
    export *
    link "Python"
}
  1. Delete the setting of Target - Build settings - Search path - Header Search Paths in Xcode

  2. Click Product -> Clear Build Folder... and build it again,
    the 100 warnings about headers will disappear on macOS.

I have tried several times upon my own instructions on macOS
https://www.notion.so/frogcjn/Swift-with-Python-Step-by-Step-1984959764ca80999f25cf9897df83bc

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions