Unable to use swift package module in safari extension target in Xcode.

I have created a swift package CommonPackage with files that are common to two targets.

In my project I have two targets.

  • MainApp
  • Safari Extension target for MainApp

Now, I added this package in the Frameworks, Libraries section for both targets. I am able to use this package in the main app target, but when I import this package in my Safari Extension target in SFSafariExtensionHandler class , it is giving me the

No such module CommonPackage  error.

The package file is pretty generic:

 let package = Package(
name: "CommonPackage",
platforms: [
  .iOS(.v14)
],
products: [
    .library(
        name: "CommonPackage",
        targets: ["CommonPackage"]),
],
dependencies: [
    // Depends on another swift package, stored in separate repo.
],
targets: [
    .target(
        name: "CommonPackage",
        dependencies: []),
    .testTarget(
        name: "CommonPackage Tests",
        dependencies: ["CommonPackage"]),
]
)

Not sure why I am not able to use this package in the safari extension target. I spent many hours trying different solutions to resolve No such module error, but none worked. In one of WWDC video they show, this kind of modularization is supported, but in my case it is not. I started to think, is it because of the way my project is supported?

Note: The safari extension target is a child target to main app target, which means, the safari extension is added as a dependency in the main app target settings.

Really appreciate if someone can point me in right direction. I can provide more details in the question, but not sure what relevant details I need to include.

It seems my extension target CONFIG_BUILD_DIR is set to build, and when I change it to $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME), I'm able to build successfully.

Unable to use swift package module in safari extension target in Xcode.
 
 
Q