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

Use of unresolved identifier 'ARTPush' #595

Closed
shantamg opened this issue Apr 27, 2017 · 22 comments
Closed

Use of unresolved identifier 'ARTPush' #595

shantamg opened this issue Apr 27, 2017 · 22 comments
Assignees

Comments

@shantamg
Copy link

shantamg commented Apr 27, 2017

I installed for ios per the instructions at Github PR 582 using CocoaPods.

I tried adding this to the AppDelegate (using the Swift instructions from this page):

optional func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    ARTPush.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken, realtime: self.getAblyRealtime())
}
​
optional func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    ARTPush.didFailToRegisterForRemoteNotificationsWithError(error, realtime: self.getAblyRealtime())
}
​
func getAblyRealtime() -> ARTRealtime {
    var options = ARTClientOptions()
    // Set up options; API key or auth URL, etc.
    return ARTRealtime(options: options)
}

but it seems like Ably is not loading. In Xcode I get lots of errors including "Use of unresolved identifier 'ARTPush'" and "Use of undeclared type 'ARTRealtime'".

I know this is vague, but I'm not sure what else to include here. Can someone help me get started?

@mattheworiordan mattheworiordan added the bug Something isn't working. It's clear that this does need to be fixed. label Apr 28, 2017
@tcard
Copy link
Contributor

tcard commented Apr 28, 2017

Hi! Sorry but I can't reproduce the problem you describe.

Are you doing import Ably at the top of your file?

@tcard tcard removed the bug Something isn't working. It's clear that this does need to be fixed. label Apr 28, 2017
@ricardopereira
Copy link
Contributor

@shantamg I think you're missing the import Ably. Could you try it? Thanks.

@ricardopereira
Copy link
Contributor

(Ups 😄 @tcard almost at the same time)

@shantamg
Copy link
Author

shantamg commented Apr 28, 2017

I actually did try that and got "No such module 'Ably'".

I have Ably in the Podfile, I did pod install and I see the Ably folder in the Pods folder...

I have also tried with and without use_frameworks! in the podfile.

@ricardopereira
Copy link
Contributor

@shantamg Could you share the Podfile with us, please?

@shantamg
Copy link
Author

platform :ios, '9.0'
use_frameworks!

target 'Reservations' do
  pod 'Ably', :git => '/~https://github.com/ably/ably-ios.git', :branch => 'push'
end

@ricardopereira
Copy link
Contributor

@shantamg and do you open the generated .xcworkspace file? (see https://guides.cocoapods.org/using/using-cocoapods.html#installation)

@shantamg
Copy link
Author

shantamg commented Apr 30, 2017 via email

@shantamg
Copy link
Author

shantamg commented May 9, 2017

Sorry for the delay.

I tried making a fresh xcode app, did pod init, updated the Podfile as above, ran pod install, opened the xcworkspace file, added import Ably to the top of the AppDelegate.swift file, and I get:

No such module 'Ably'

Xcode Version 8.3.2 (8E2002)

@ricardopereira
Copy link
Contributor

@shantamg Could you send us that fresh project please?

@shantamg
Copy link
Author

Test Ably.zip

@ricardopereira
Copy link
Contributor

@shantamg Sorry for the delay. I tried your example and it's working. You need to build it once so that the library becomes available.

@mattheworiordan
Copy link
Member

@shantamg can you confirm if you build it it works for you?

@shantamg
Copy link
Author

shantamg commented May 24, 2017

Ok, that makes sense. I did a build and now Ably loads, but I'm not sure where to find a working example.

The code I pasted above in the first comment gives me errors:

  • 'optional' can only be applied to protocol members
  • incorrect argument label in call (have ':realtime:', expected ':rest:')

Sorry if I'm still missing something. Just looking for a simple working example.

@tcard
Copy link
Contributor

tcard commented May 25, 2017

@shantamg Our fault! Those optional shouldn't be there, and the realtime label wasn't really available. It is now, so if you run pod update Ably on your project then it should work. I've removed optional from the docs snippet too. Thanks for the heads up!

@shantamg
Copy link
Author

shantamg commented May 25, 2017 via email

@shantamg
Copy link
Author

Still not quite there.
I did pod update and now the realtime label is available, and I got rid of the optional (which xcode suggested). Xcode also pointed out that 'didRegisterForRemoteNotificationsWithDeviceToken(_:realtime:)' has been renamed to 'didRegisterForRemoteNotifications(withDeviceToken:realtime:)' so I fixed that, but I still get a number of other errors:

  • expected declaration on the line after the end of each of the func application(...) ... { }
  • Variable 'options' was never mutated; consider changing to 'let' constant

Can you link to the docs you mentioned updating? The page I linked to in the first comment is the same as before.

For the sake of completeness I'll post all of the other warnings I'm seeing:

Swift Compiler Warning:
Umbrella header for module 'Ably' does not include header 'ARTLocalDevice+Private.h'
Umbrella header for module 'Ably' does not include header 'ARTPush+Private.h'
Umbrella header for module 'Ably' does not include header 'ARTPushAdmin+Private.h'

Well, here's an image of the rest of them. msgpack and SocketRocket semantic issues and Ably Lexical or Preprocessor Issue:

screen shot 2017-05-25 at 9 30 00 am

Thanks for looking into it and sorry for the trouble!

@tcard
Copy link
Contributor

tcard commented May 29, 2017

@shantamg

expected declaration on the line after the end of each of the func application(...) ... { }

This is a syntax error on your code.

Variable 'options' was never mutated; consider changing to 'let' constant

This is not an error, it's a warning. You can ignore it for now but eventually you'll have to set the options you want, at least your API key or other means of authentication in order to use Ably.

Swift Compiler Warning:
Umbrella header for module 'Ably' does not include header 'ARTLocalDevice+Private.h'
Umbrella header for module 'Ably' does not include header 'ARTPush+Private.h'
Umbrella header for module 'Ably' does not include header 'ARTPushAdmin+Private.h'

Thanks, should be fixed now. Also the ARTMsgpackEncoder warning.

About warnings on our dependencies, I'm afraid we can't do much about them. So you should just ignore them.

@shantamg
Copy link
Author

Thanks, that's great.

The only issue I'm still having is the "expected declaration". I'm not sure where the syntax error is. I have copied the code directly from the documentation.

@shantamg
Copy link
Author

shantamg commented Jun 1, 2017

Ok I figured it out -- there are zero width spaces in the code examples in the docs.

On the page where I got the code if you inspect the source of any code block, the blank lines look like this:

<pre class=" CodeMirror-line">
    <span style="padding-right: 0.1px;"><span cm-text="">&#8203;</span></span>
</pre>

That &#8203; is a zero width space (U+200B) which, after copying from the web, xcode complains about.

@mattheworiordan
Copy link
Member

@shantamg urr, that's a bit of an issue as we use CodeMirror to format the code. I'll see if the CodeMirror guys have any advice on this one as I am not sure what to do other than to hack a fix which replaces these zero width spaces with something else. We can do that easily, but I expect there's a good reason behind the use of these zero width spaces. See codemirror/codemirror5#4776

@shantamg
Copy link
Author

shantamg commented Jun 1, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants