Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Issues when converting Swift version to latest syntax #16

Closed
sweber6106 opened this issue Dec 28, 2015 · 16 comments
Closed

Issues when converting Swift version to latest syntax #16

sweber6106 opened this issue Dec 28, 2015 · 16 comments

Comments

@sweber6106
Copy link

Cloned this repo, checked out the "swift" branch, and copied the CouchbaseLite.framework into the Frameworks directory. On launching with the latest Xcode tools, the user is prompted to "update to the latest syntax", which I did. The update task completes, but the subsequent build fails (see below).
screen shot 2015-12-28 at 5 34 27 pm

@snej
Copy link
Contributor

snej commented Dec 29, 2015

That's weird, you should not be getting prompted to update. I checked in a commit (4d1e48c) with the Swift 2 conversion earlier today. Make sure you've got the latest commits on the branch.

@snej
Copy link
Contributor

snej commented Dec 29, 2015

Also, what exactly is the version number of Xcode you're using? I don't believe there's a release newer than 7.2 (7C68) which is what I have. I would not recommend using a beta Xcode if you're new to iOS development, especially if you're using Swift.

@sweber6106
Copy link
Author

7C68 is what I'm using. Just did the following steps:

git clone git://github.com/couchbaselabs/Grocery-Sync-iOS.git
Grocery-Sync-iOS-4

cd Grocery-Sync-iOS-4

git checkout swift

< double click GrocerySync.xcodeproj in Finder >

Xcode launches and displays the "Convert to latest Swift syntax?" dialog.

< Click on "Convert" >

Xcode now says "Convert to Latest Swift Syntax has already been run.
Running the conversion more than once can introduce errors."

< Click cancel >

< Copy in the CouchbaseLite framework >

< Click "play" icon to build >

Xcode displays as follows: attached

< Click on "Update to recommended settings" >

Xcode displays the changes it wants to make: attached

< Click "update" >

Xcode displays warning about "uncommitted changes": attached

< Click continue >

< Changes appear to be performed and warning clears >

< Click build >

Still have the errors: attached

On Tue, Dec 29, 2015 at 1:57 AM, Jens Alfke [email protected]
wrote:

Also, what exactly is the version number of Xcode you're using? I don't
believe there's a release newer than 7.2 (7C68) which is what I have. I
would not recommend using a beta Xcode if you're new to iOS development,
especially if you're using Swift.


Reply to this email directly or view it on GitHub
#16 (comment)
.

@snej
Copy link
Contributor

snej commented Dec 29, 2015

That's bizarre. If you look at the commit, you can see that the project file includes LastSwiftMigration = 0720 which means Xcode 7.2.0 ran its Swift update already.

Maybe you're double-clicking the project in the wrong folder, and that's a checkout that doesn't have the latest commits?

@sweber6106
Copy link
Author

Lots more smashing my head on this. Deleting everything, recloning,
using "open
GrocerySync.xcodeproj" instead of double-clicking anything. Same dialog
for updating (which I cancel), same errors. The Objective-C version builds
and runs. The Swift version seems not to. Ideas?

On Tue, Dec 29, 2015 at 1:07 PM, Jens Alfke [email protected]
wrote:

That's bizarre. If you look at the commit
4d1e48c,
you can see that the project file includes LastSwiftMigration = 0720
which means Xcode 7.2.0 ran its Swift update already.

Maybe you're double-clicking the project in the wrong folder, and that's a
checkout that doesn't have the latest commits?


Reply to this email directly or view it on GitHub
#16 (comment)
.

@snej
Copy link
Contributor

snej commented Dec 29, 2015

Well, do a git status and make sure you're on commit f5ff0510cf0d9ab3223b065ed74de5f4a70bc3c1, and that there are no locally modified files.

In Xcode, press Cmd-Shift-Opt K, or hold down the Option key and choose Product > Clean Build Folder. This will blow away any local state related to the project (object code, indexes, etc.) Then quit and relaunch Xcode. Open the About box to make sure you're running the copy of Xcode you think you are (I sometimes have a regular and a beta version around, and they're easy to mix up.)

@snej
Copy link
Contributor

snej commented Dec 29, 2015

I just looked at the errors you get, and realized that we must have different versions of the CBL headers. That led me to discover that the CBL framework in my Grocery Sync checkout's Frameworks folder was not 1.1.1 but some older build — yikes! There were some changes in the API headers to produce a cleaner binding to Swift, and my source tree didn't have those.

So I downloaded 1.1.1 and copied it into my GrocerySync folder, reproduced your build errors, fixed them, and checked in a new revision.

So sorry about that :( It's easy to get versions mixed up because I switch between working on different branches all the time. I still don't understand why Xcode keeps wanting to upgrade the Swift syntax, but it should be harmless now that the build errors are gone. Crossing my fingers that it works for you now!

@sweber6106
Copy link
Author

Thanks for your continued interest in this. I hope that the work we're
doing makes the project better and is not limited to getting my one
prototype up and going.

Here's what I did:

Closed Xcode and cloned a fresh version of the code.
Switched to the Swift branch.
Copied in the framework.
Started Xcode by double-clicking the project file (GrocerySync.xcodeproj)
Cancelled the code conversion request
Clicked on the "update settings" stuff and took the recommendations
Had a build error that required that I turn off "bitcode" in the build
settings
Build now successful.
Clicked the "Clean" text in the app and got a crash (attached). This could
simply be user error. Maybe you can't click "Clean" before the app has
been running for a while. Anyway, it may happen to others so I am letting
you know.

On Tue, Dec 29, 2015 at 5:39 PM, Jens Alfke [email protected]
wrote:

I just looked at the errors you get, and realized that we must have
different versions of the CBL headers. That led me to discover that the CBL
framework in my Grocery Sync checkout's Frameworks folder was not 1.1.1 but
some older build — yikes! There were some changes in the API headers to
produce a cleaner binding to Swift, and my source tree didn't have those.

So I downloaded 1.1.1 and copied it into my GrocerySync folder, reproduced
your build errors, fixed them, and checked in a new revision.

So sorry about that :( It's easy to get versions mixed up because I switch
between working on different branches all the time. I still don't
understand why Xcode keeps wanting to upgrade the Swift syntax, but it
should be harmless now that the build errors are gone. Crossing my fingers
that it works for you now!


Reply to this email directly or view it on GitHub
#16 (comment)
.

@snej
Copy link
Contributor

snej commented Dec 30, 2015

Weird, I don't get the update-settings suggestion either. But don't accept the changes unless you know what you're doing.

Attachment didn't make it through. To capture a crash, click in the Xcode debugger console pane (the one with the (lldb) prompt) and enter the command bt. That will log a stack backtrace that you can copy and paste.

@sweber6106
Copy link
Author

2015-12-29 18:26:45.707 GrocerySync[2872:2179917] SYNC progress: 0 / 0

2015-12-29 18:26:45.711 GrocerySync[2872:2179917] SYNC progress: 0 / 0

2015-12-29 18:26:46.335 GrocerySync[2872:2179917] SYNC progress: 0 / 0

2015-12-29 18:27:11.301 GrocerySync[2872:2179917] SYNC progress: 0 / 0

2015-12-29 18:27:11.676 GrocerySync[2872:2179917] SYNC progress: 0 / 1

2015-12-29 18:27:22.578 GrocerySync[2872:2179917]
-[GrocerySync.RootViewController deleteCheckedItems:]: unrecognized
selector sent to instance 0x1755b050

2015-12-29 18:27:22.579 GrocerySync[2872:2179917] ** Terminating app due
to uncaught exception 'NSInvalidArgumentException', reason:
'-[GrocerySync.RootViewController deleteCheckedItems:]: unrecognized
selector sent to instance 0x1755b050'*

*** First throw call stack:

(0x23c1e2eb 0x233eadff 0x23c23ab5 0x23c2170f 0x23b50c88 0x27ded771
0x27f6ec71 0x27ded771 0x27ded701 0x27dd561f 0x27dd574b 0x27ded051
0x27deccbf 0x27de55d7 0x27db6119 0x27db4757 0x23be1257 0x23be0e47
0x23bdf1af 0x23b31bb9 0x23b319ad 0x24dabaf9 0x27e1dfb5 0x40a34 0x237e4873)

libc++abi.dylib: terminating with uncaught exception of type NSException

_(lldb) _bt

*(lldb) *

On Tue, Dec 29, 2015 at 6:35 PM, Jens Alfke [email protected]
wrote:

Weird, I don't get the update-settings suggestion either. But don't accept
the changes unless you know what you're doing.

Attachment didn't make it through. To capture a crash, click in the Xcode
debugger console pane (the one with the (lldb) prompt) and enter the
command bt. That will log a stack backtrace that you can copy and paste.


Reply to this email directly or view it on GitHub
#16 (comment)
.

@snej
Copy link
Contributor

snej commented Dec 30, 2015

The exception in there is: -[GrocerySync.RootViewController deleteCheckedItems:]: unrecognized selector sent to instance 0x1755b050.

…OK, the button is wired up with an action string deleteCheckedItems: where the trailing colon implies a parameter, but the Swift method doesn't take a parameter. I removed the colon and now it works. I guess no one tried the Clean button after the Swift conversion. You can check out the fix.

@sweber6106
Copy link
Author

Thanks for all the help. On to getting a Couchbase Server and Sync Server
installed.

On Tue, Dec 29, 2015 at 7:15 PM, Jens Alfke [email protected]
wrote:

The exception in there is: -[GrocerySync.RootViewController
deleteCheckedItems:]: unrecognized
selector sent to instance 0x1755b050.

…OK, the button is wired up with an action string deleteCheckedItems:
where the trailing colon implies a parameter, but the Swift method doesn't
take a parameter. I removed the colon and now it works. I guess no one
tried the Clean button after the Swift conversion. You can check out the
fix.


Reply to this email directly or view it on GitHub
#16 (comment)
.

@sweber6106
Copy link
Author

New set of problems. I have Couchbase server and Sync Gateway installed in an Ubuntu 14.04 VM.

The IP address of the VM running the server and gateway is 192.168.1.12. I think I have followed all the directions. I modified the DemoAppDelegate.swift file as follows:
private let kServerDbURL = NSURL(string: "https://192.168.1.12:4984/grocery-sync/")!

(I originally had "http" instead of "https", but the application output an error about requiring a secure channel. That error cleared when I went to https.)

The current error is as follows:

The request timed out. (error=Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=https://192.168.1.12:4984/grocery-sync/_local/212cf102b9472e09ec096c744c6a205e4542f03e, _kCFStreamErrorCodeKey=-2102, NSErrorFailingURLKey=https://192.168.1.12:4984/grocery-sync/_local/212cf102b9472e09ec096c744c6a205e4542f03e, NSLocalizedDescription=The request timed out., _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x18974840 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSErrorFailingURLStringKey=https://192.168.1.12:4984/grocery-sync/_local/212cf102b9472e09ec096c744c6a205e4542f03e, NSErrorFailingURLKey=https://192.168.1.12:4984/grocery-sync/_local/212cf102b9472e09ec096c744c6a205e4542f03e, NSLocalizedDescription=The request timed out., _kCFStreamErrorDomainKey=4}}})

@sweber6106
Copy link
Author

I get the same timeout behavior with the Objective-C version of the app. One difference is that the Objective-C version does not require me to use https.

@snej
Copy link
Contributor

snej commented Jan 4, 2016

On Jan 3, 2016, at 11:31 AM, Sam Weber [email protected] wrote:

(I originally had "http" instead of "https", but the application output an error about requiring a secure channel. That error cleared when I went to https.)

But do you actually have SSL enabled on the Sync Gateway? If not, trying to make an SSL connection is definitely going to fail.

You can override iOS App Transport Security and use regular HTTP by adding a key to your Info.plist. Check Apple's dev docs or google App Transport Security.

--Jens

@sweber6106
Copy link
Author

Changed the code back to "http" and modified the GrocerySync-Info.plist as follows:
screen shot 2016-01-04 at 8 21 15 pm
Everything seems to be working now.

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

No branches or pull requests

2 participants