pusher / push-notifications-swift

Swift SDK for the Pusher Beams product:
https://www.pusher.com/beams
MIT License
34 stars 24 forks source link

Module 'PushNotifications' not found after installing with CocoaPods, but not with Carthage #107

Closed siers closed 5 years ago

siers commented 5 years ago

Hello,

I used to have

github "pusher/push-notifications-swift"

and @import PushNotifications; in the .m file worked, but I had defined other dependencies in the Podfile already, so I thought I'd only use the Podfile, but the import then no longer works. The pod install went fine and I added PushNotifications.framework to the Linked Frameworks and Libraries (though was that required?). The PushNotifications is also visible in Pods > Pods in the project tree.

Do you have any ideas or suggestions? Thanks.


Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
use_frameworks!

target 'ReactCake' do
  pod 'GoogleSignIn'
  pod 'Intercom', '> 5.2'
  pod 'PushNotifications', '~> 1.2.0'
end

# https://github.com/CocoaPods/CocoaPods/issues/8118
pre_install do |installer|
  installer.analysis_result.specifications.each do |s|
    s.swift_version = '4.2.1' unless s.swift_version
  end
end
lukabratos commented 5 years ago

Hi

Can you check if Framework Search Paths are correctly set? Build Settings -> Search Paths -> Framework Search Paths

There's a lot of relevant questions and answers on the Google too, did you manage to go through them?

siers commented 5 years ago

Hi

I tried adding "${PODS_ROOT}/PushNotifications/Sources" to both Debug/Release path lists of Framework Search Paths, but to no avail. :( I ran through the google issues as well.

The swift_version in the build settings is set to latest – 4.2, I opened the project with .xcworkspace, and I tried some other things too.

I can't make it work, I guess it'll have to stay this way.

lukabratos commented 5 years ago

Hey @siers

I think that the issue is probably in the project configuration or in the Podfile.

To test that CocoaPods integration works on your machine, what if you create a test project and specify just Beams as a dependency, like:

platform :ios, '10.0'

target 'YourProject' do
  use_frameworks!

  pod 'PushNotifications'
end

You've mentioned that you've tried some other things too but it was unsuccessful. What were the errors that you have received?

I hope that we can solve this issue together.

Let me know,

Luka

alvincrespo commented 5 years ago

We're having a similar issue.

Use of undeclared identifier 'PushNotifications'

Our team is using Carthage, but Xcode 10.2 can't seem to compile the project. Even though our settings haven't changed.

Should I open a new ticket since this is slightly different?

lukabratos commented 5 years ago

Hi @alvincrespo

I was unable to reproduce this issue. What I did:

1.) I have created a new Single View App project in Xcode Version 10.2 (10E125) using Objective-C language option. 2.) I have created Cartfile and specified PushNotifications dependency: github "pusher/push-notifications-swift" Output after running carthage update:

master└─ $ carthage update
*** Fetching push-notifications-swift
*** Checking out push-notifications-swift at "1.3.0"
*** xcodebuild output can be found in /var/folders/1h/6pms64hs4pq367kr8477xkgm0000gn/T/carthage-xcodebuild.FrKGQP.log
*** Building scheme "PushNotifications" in PushNotifications.xcworkspace

3.) I have then added generated .framework into the project. 4.) I have imported PushNotifications:

#import <UIKit/UIKit.h>
@import PushNotifications;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) PushNotifications *beams;

Project successfully builds.

P.S. Are you using React Native?

alvincrespo commented 5 years ago

@lukabratos Interesting. Wondering if it has something to do with react natives project setup?

We're using b8ne/react-native-pusher-push-notifications, which recommends installing this package (pusher/push-notifications-swift).

We went through the Carthage Installation process and then made the updates recommended in issue pusher/push-notifications-swift#65.

Update: This morning we got it to build properly in Xcode 10.1.

Any recommendations or suggestions on how to debug?

alvincrespo commented 5 years ago

Oh! I should have mentioned that we're using React Native! Apologies for not putting that info in my original comment.

synackal commented 5 years ago

For the record I am also running into this issue building from a react-native project following extremely closely to what @alvincrespo is describing. I am able to get it to build in Xcode when targeting a generic device but not when targeting a simulator. Likewise, invoking the react-native run-ios command also fails to build:

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:24:7: use of undeclared identifier 'PushNotifications'

    [[PushNotifications shared] startWithInstanceId:instanceId];
                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:25:7: use of undeclared identifier 'PushNotifications'

    [[PushNotifications shared] registerForRemoteNotifications];
      ^

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:35:7: use of undeclared identifier 'PushNotifications'

    [[PushNotifications shared]
      ^

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:53:7: use of undeclared identifier 'PushNotifications'

    [[PushNotifications shared]
      ^

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:72:7: use of undeclared identifier 'PushNotifications'

    [[PushNotifications shared]
      ^

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:116:5: use of undeclared identifier 'PushNotifications'

  [[PushNotifications shared] handleNotificationWithUserInfo:userInfo];
      ^

❌  /Users/xxx/Documents/projects/xxx/clients/xxx/node_modules/react-native-pusher-push-notifications/ios/RNPusherPushNotifications.m:127:5: use of undeclared identifier 'PushNotifications'

  [[PushNotifications shared] registerDeviceToken:deviceToken
    ^

** BUILD FAILED **

Xcode Version 10.2 (10E125)

lukabratos commented 5 years ago

Hi @alvincrespo & @synackal 👋

We're not officially supporting React Native at the moment so I cannot help you much.

To answer your question:

Interesting. Wondering if it has something to do with react natives project setup?

It might be. I would advise that you check issues list on the official React Native repo or open a new one, citing the problem that you're experiencing with the newest Xcode version. You could also do that on b8ne/react-native-pusher-push-notifications because people are using the same technology as you do so they might help you better than I can.

Things are moving very fast both in iOS and React Native world so all kind of problems are possible.

I'm closing this issue for now but feel free to continue conversation if you would like to add anything.

Thanks!