Socket.io-client-swift: Any plans to upgrade the code to Swift 3?

Created on 14 Jun 2016  路  19Comments  路  Source: socketio/socket.io-client-swift

I've upgraded to Swift 3 but i'm getting errors all over the place with the socket.io pod. Any plans to have a release compatible with Swift 3 / Xcode 8?

question

Most helpful comment

All 19 comments

@nuclearace Thanks for the link but it still doesn't build on my end. Doest it build for you?

@nuclearace actually the swift3 branch isn't really swift3 compatible. Even when you try to convert it to swift3 when you load the xcode project it still doesn't build. Have you actually got it to build on Xcode 8 Beta?

Working on it. I was just using the latest trunk releases

Okay you can try now.

@nuclearace Hey, the project does build by itself but when I use it in my project I get alot of Swift Compiler Errors. Have you tried to build it within another project?

How are you adding it to the other project? I don't officially support betas, so you're probably better off adding the source files directly to your project

@nuclearace I actually added the whole content of the source files to my project instead of adding it with a pod file and it is not building due to errors in socketio code. I find it weird that it builds by itself yet has errors when you add it to a project. I just want to confirm you're getting the same errors when you add it to a project?

It could be that that project is still using Swift 2 that's what's happening to one of mine. I had to do convert to latest syntax.

@nuclearace I did upgrade my project and it builds / runs with no error. When I add the source files for socketIO i get error related to NSData and the new Data replacement function. Maybe it's an Xcode 8 bug but for some reason it's not converting NSData to Data and I get a cascade of errors. I'll try to figure out how to solve it or hopefully it goes away with the next XCode 8 beta release. Thanks for the help

Yeah, that converter is far from perfect. I noticed it was doing some crazy stuff.

Hi guys. Did you manage to get it up and running with swift 3?

Yes it works fine with Swift 3 except if you dont use SSL. Works fine as it should if used it with SSL connection.

Hi. Thanks for your reply. It's working well for me also and I am using SSL. Just wondering though why I have to select allow arbitrary loads to YES in my info.plist for it to work. Selecting NO which is my preferred option prevents the connection.

Your cert might not meet Apple's requirements

i think cert is okay because my app runs fine with allow arbitrary loads set to NO and I'm able to access SSL services. It's just socketIO that doesn't work when switch to allow arbitrary loads to NO. I'm pretty new to .js. This is the top of my index.js file:

var app = require('express')();
var https = require('https');
var fs = require('fs');

var options = {
key: fs.readFileSync('/example.com.key'),
cert: fs.readFileSync('/example.com.crt'),
ca: fs.readFileSync('/example_intermediate.crt')
};

var server = https.createServer(options, app);

Sorry for the thread drift...

Again if I switch allow arbitrary loads to YES everything works fine. If it's selected to NO everything except socketIO works fine. I have not altered socketIO code in any way.

The JS code you have supplied doesn't say anything about sockets. You are just creating https server in that code. Can you post your code that creates a socket server ?

hi again. thanks for your patience. i'm very new to this. i have imported the source code untouched. created my socket class and using the following to connect:

var socket: SocketIOClient = SocketIOClient(socketURL: URL(string: "https://www.mySite.com:3000")!)

my index file includes what i have above and then:

var io = require('socket.io')(server);
server.listen(3000, function(){
console.log('Listening on *:3000');
});
io.on('connection', function(socket){
console.log('a user connected');
....

hi,
I need this for swift 3!
when it possible???

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaetanm picture gaetanm  路  4Comments

MD04-TanTan picture MD04-TanTan  路  5Comments

elitelokesh picture elitelokesh  路  6Comments

astrike30 picture astrike30  路  6Comments

Yelles picture Yelles  路  5Comments