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-15154] ObjC projects using SPM fail when we expose our models into another module #57480

swift-ci opened this issue Sep 4, 2021 · 9 comments
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. transfer candidate The issue may belong in another repository


Copy link

swift-ci commented Sep 4, 2021

Previous ID SR-15154
Radar rdar://problem/82827693
Original Reporter taquitos (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 3
Labels Bug
Assignee None
Priority Medium

md5: 4659038e109b6bed99ec521e272addf0

Issue Description:

We create an ObjC App that uses our SPM package "RevenueCat".
In our app, we create an object that uses an object from the "RevenueCat" package as part of its api.

We expose this object's header (which exposes the method containing the RevenueCat object as a parameter) as a public header.

We create a Swift test target that depends on the ObjC App and has a bridging header for that object we created.

We attempt to use the API in a test. API that doesn't include RevenueCat objects is fine, but any API that uses RevenueCat objects in the parameter is not found.

Xcode 12.5.1 (Build version 12E507) & Xcode 13 Beta 5

M1 Mac as well as Intel mac.

Swift Package Manager - Swift 5.4.0

Swift Package Manager - Swift 5.5.0

Component: Package Manager

Reproduction project:

Attempt to build the test target.

You'll get
`Value of type 'TaquitosAreTheBest' has no member 'purchaserInfo'`

Copy link

@swift-ci create

Copy link

We ran into a similar issue, I believe a workaround is to import the header instead of using a forward declaration. I know it's not the best practice for Obj-C but makes it usable at least.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Copy link

I have faced similar issue. This bug is also reproduces in mixed Swift/Objective-C project (not only in Test target).
Case: header file has forward class declaration from SPM and this type used for declare properties or parameters in this header.
Those properties and parameters won't be exposed into Swift.
You will receive build error:


Copy link

👋 We have encountered this same issue while converting the Braintree SDK from Obj-C to Swift. Our SDK is comprised of several sub-modules, and while we thought we could convert to Swift module-by-module, this SPM bug has us blocked and forced to convert our entire SDK at once.

Our team has created a Swift Forum post on the issue here, for those that want to follow along / try to gain traction.

@AnthonyLatsis AnthonyLatsis added the transfer candidate The issue may belong in another repository label Mar 5, 2023
Copy link

cc @tomerd

Copy link

mamouneyya commented Mar 17, 2023

Sharing this workaround which we have been using for a while now to go around this. Just add this to your app's build settings (or whatever consumer of the package that has the Obj-C types). Even better if you're using a .xcconfig file since you can add a comment explaining why this weird hack is needed:

// Until the following Swift Package Manager bug is
// fixed, we have to explicitly load the generated
// module map of any dependency that has ObjC bridged
// types (a.k.a. `@objc` annotated Swift types). Other-
// wise the module won't be accessible from ObjC headers
// Ref:
OTHER_SWIFT_FLAGS = $(inherited) -Xcc "-fmodule-map-file=${OBJROOT}/GeneratedModuleMaps-${PLATFORM_NAME}/PackageWithObjC.modulemap"

Copy link

@tomerd Please help me transfer this if it is indeed a package manager issue.

Copy link

tomerd commented Apr 18, 2023

cc @abertelrud @neonichu

Copy link

Sounds like an Xcode issue to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. transfer candidate The issue may belong in another repository
None yet

No branches or pull requests

9 participants