Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Objective-C headers build fine with swift but not with Xcode

On my M4 Mac running macOS 15.5 using Xcode 16.4 & Xcode CLT 16.4, Swift code in my Swift Package Manager 5.9 project (https://github.com/mas-cli/mas) builds fine against some included Objective-C headers via the following command line:

swift build -c release

But cannot find modules for the included Objective-C headers when building inside Xcode 16.4 or with the following command line on the same Mac:

xcodebuild -scheme mas -configuration Release -destination platform=macOS,arch=arm64,variant=macos

The error is:

Sources/mas/AppStore/AppleAccount.swift:9:16: error: no such module 'StoreFoundation'

How can I get Xcode / xcodebuild to work?

Note that the project is normally built by running:

Scripts/build

which runs:

swift build -c release

after running the following script, which must be run before any build (swift, Xcode, or xcodebuild) because it generates a necessary file (Sources/mas/Package.swift):

Scripts/generate_package_swift

I've tried moving the Objective-C headers into include subfolders of their existing module folders, using double quotes instead of angle brackets for the #import statements, having module.modulemap files in the include subfolders or their parent module folder, and moving the module folders one level up the file hierarchy, to no avail.

I've also tried various changes to the root-level Package.swift (not the generated one deeper in the hierarchy, which isn't inclined in the build configuration), like making separate library targets for each of the Objective-C modules, various swiftSettings & linkerSettings, etc.

Maybe some of those changes would have helped, but maybe they were in incorrect combinations.

Thanks for any help.

Objective-C headers build fine with swift but not with Xcode
 
 
Q