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

Conversion of swift 2.3 code to swift 3 #44

Open
shrivastavaharsh opened this issue Sep 14, 2016 · 15 comments
Open

Conversion of swift 2.3 code to swift 3 #44

shrivastavaharsh opened this issue Sep 14, 2016 · 15 comments

Comments

@shrivastavaharsh
Copy link

shrivastavaharsh commented Sep 14, 2016

I am having issues related to conversion, whenever I am trying to open xib with button action I am getting this error found nil while unwrapping optional, another issue is related to response http code. If you can provide converted syntax of the code that will be great!

Thanks

@samscam
Copy link
Contributor

samscam commented Sep 18, 2016

@shrivastavaharsh I've got a swift-3 branch on the go if you're interested.
@watsonbox sorry but there's another massive pull request in the making there ;)

@watsonbox
Copy link
Owner

watsonbox commented Sep 19, 2016

@shrivastavaharsh I'd be happy to look at this for possible merging once it's ready, although there appears to be a fair amount of stuff on that branch that isn't swift-3 specific.. Also are there a lot of changes required? I haven't looked at it yet. Does the Travis CI env support Swift 3?

@shrivastavaharsh
Copy link
Author

I looks like to me that there is some syntax changes required, such as some response http code, plus xib file look different also, I am new to swift. I am getting error of usual found nil while unwrapping optional value, which I am unable to debug. Lot of changes is been made by xcode also which could be reason of error.

@shrivastavaharsh
Copy link
Author

@samscam I am getting this runtime exception
partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
And on debug console -
fatal error: unexpectedly found nil while unwrapping an Optional value

I have already checked all the outlets everything is fine, is it something related to swift 3?

Thanks!

@samscam
Copy link
Contributor

samscam commented Sep 26, 2016

@shrivastavaharsh that sounds like a standard unwrapped optional bug. Very sorry but I can't glean much without knowing which actual line of code it failed on and if it was coming from GPA (in which case we can help) or your own code (in which case we can't).

There are plenty of guides on how optionals work in swift out there which might help you.

@shrivastavaharsh
Copy link
Author

@samscam Thanks for your reply! the actual line code which is producing that bug is topConstraint.constant = topLayoutGuide.length

This line is present in GPA code in the viewWillLayoutSubviews func.

@samscam
Copy link
Contributor

samscam commented Sep 26, 2016

Ok well that does sound like you've lost an outlet. In GooglePlacesAutocomplete.xib there should be a constraint between the top of the search bar and the view. That should be connected to the topConstraint outlet of the file's owner in IB. It's definitely hooked up in the one one provided here... and definitely not a result of swift 3 conversion!

@shrivastavaharsh
Copy link
Author

@samscam I can see the outlet defined @IBOutlet weak var topConstraint: NSLayoutConstraint!
in my implementation also. It was working before update and I didnt connected anything.

@samscam
Copy link
Contributor

samscam commented Sep 26, 2016

@watsonbox Yes it's got all my other changes in it too :)

  1. The PlaceDetail and LocationBias model have been somewhat extended to include CLLocation and CLRegion properties - this is non breaking but does add a dependency on CoreLocation. It's also very useful :)
  2. There's some refactoring and addition of a GooglePlacesAutocompleteService which performs the calling of the api and mapping of JSON to Place objects - previously this was embedded in the GooglePlacesAutocompleteContainer class. This way it's possible to make the api calls away from the bundled UI. I'd still like to make this separation cleaner, document it, and test the UI and API chunks in isolation.
  3. I added a few lines of code in the example app to substitute in the API_KEY from an environment variable. The tests use the substitution too (even though they don't make real network calls).
  4. Apart from that, it's all reasonable conversion stuff.

Travis does XCode 8 and after some head scratching (blinking cursors and api changes to FBSnapshotTestCase) as well as the inevitable re-do of the images because the OS looks different, the tests pass.

@shrivastavaharsh
Copy link
Author

@samscam I changed the top constraint force unwrap ! to optional ? then its working. I hope it wont effect functionality. btw thanks for your work!

@irace
Copy link

irace commented Oct 26, 2016

@watsonbox Any update here, with regards to supporting Swift 3?

@varun-naharia
Copy link

I updated the code for swift 3 http://github.com/varun-naharia/ios_google_places_autocomplete and created a pull request

@ErAshu
Copy link

ErAshu commented Oct 25, 2017

Hi @varun-naharia
please find the attached screenshot. How we remove this error.
screen shot 2017-10-25 at 11 59 58 pm

@varun-naharia
Copy link

@ErAshu
Copy link

ErAshu commented Oct 27, 2017

Yes, I am using this. Simple download and run demo.

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

No branches or pull requests

6 participants