Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Support use_frameworks in Swift example #15

Open
@louiszawadzki

Description

@louiszawadzki

Hi!

The Swift example as it is does not support apps using use_frameworks! in their Podfile.
When using frameworks, the Swift import is different.

Instead of:

#import "ProductModuleName-Swift.h"

It should be:

#import <ProductName/ProductModuleName-Swift.h>

So users with use_frameworks! will get an error at build stating that:

fatal error: 'ProductModuleName-Swift.h' file not found

To handle both cases from inside the library, we can use #if __has_include as recommended on this Cocoapods issue.
I'd recommend changing the import in calculator/ios/RNCalculator.mm to be (not tested):

#if __has_include("calculator-Swift.h")
#import <calculator-Swift.h>
#else
#import <calculator/calculator-Swift.h>
#endif

For reference, here is the link to the change we ended up making.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions