admin管理员组

文章数量:1384868

I'm adding support for Expo Modules in an existing React Native app. I've been following the "Install Expo modules in an existing React Native project"-guide here, but I run into problems after changes to the iOS project. I'm using expo version 51.0.39.

I have a swift file in the project, that contains a class that conforms to PKAddPaymentPassViewControllerDelegate. After adding the expo setup, I'm now seeing an error when I try to build the project. This used to work, until I added the changes from the expo setup guide. I also added #import "ExpoModulesCore-Swift.h" in AppDelegate.mm to resolve an issue similar to the one described here. If I simply remove the one protocol conformance to PKAddPaymentPassViewControllerDelegate it does build successfully.

What can I do to make this build successful?

Mentioned swift class:

class AddPaymentPassHandler: NSObject, PKAddPaymentPassViewControllerDelegate {
    // protocol conformance and other good stuff
}

Errors:

  • Type argument 'PKAddPaymentPassViewController' must be a pointer (requires a '*')
  • Type arguments cannot be applied to non-parameterized class 'NSObject'
  • Unknown class name 'PKAddPaymentPassViewControllerDelegate'; did you mean 'PKAddPaymentPassViewController'?

I'm adding support for Expo Modules in an existing React Native app. I've been following the "Install Expo modules in an existing React Native project"-guide here, but I run into problems after changes to the iOS project. I'm using expo version 51.0.39.

I have a swift file in the project, that contains a class that conforms to PKAddPaymentPassViewControllerDelegate. After adding the expo setup, I'm now seeing an error when I try to build the project. This used to work, until I added the changes from the expo setup guide. I also added #import "ExpoModulesCore-Swift.h" in AppDelegate.mm to resolve an issue similar to the one described here. If I simply remove the one protocol conformance to PKAddPaymentPassViewControllerDelegate it does build successfully.

What can I do to make this build successful?

Mentioned swift class:

class AddPaymentPassHandler: NSObject, PKAddPaymentPassViewControllerDelegate {
    // protocol conformance and other good stuff
}

Errors:

  • Type argument 'PKAddPaymentPassViewController' must be a pointer (requires a '*')
  • Type arguments cannot be applied to non-parameterized class 'NSObject'
  • Unknown class name 'PKAddPaymentPassViewControllerDelegate'; did you mean 'PKAddPaymentPassViewController'?
Share Improve this question asked Mar 19 at 15:09 WiingaardWiingaard 4,3024 gold badges40 silver badges71 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

I realised that my problem was caused by a faulty header import in AppDelegate.mm

We used to import #import "AppName-Swift.h" in AppDelegate.mm probably for legacy reasons. When I removed this import, the above-mentioned error went away and I was able to build successfully. Furthermore, I was able to also remove #import "ExpoModulesCore-Swift.h" as mentioned above.

Removing headers is not actual solution if you actually use the Appname-Swift.h header - in such cases you need to find which additional headers to import in order to fix the issue. The solution for current issue can be

#import <PassKit/PassKit>

Found the solution in this thread: https://stackoverflow/a/34397364/1679620

本文标签: iosCan39t build PKAddPaymentPassViewControllerDelegate when setting up Expo ModulesStack Overflow