tidev / titanium-socketio

Use the native Socket.io SDK's with Axway Titanium.
Apache License 2.0
25 stars 11 forks source link

iOS don't work #6

Closed DouglasHennrich closed 6 years ago

DouglasHennrich commented 6 years ago

I have downloaded the module, cloned this repo, use carthage bootstrap under iOS folder to donwload dependencies, move to module's platform folder, replacing any framework already there and tried to run the app. I got stuck under splash screen and nothing happens. I'm using TiSDK 7.1.1.GA

log:

[TRACE] Stripping frameworks
[TRACE] Stripped ./SocketIO.framework/SocketIO of architectures: armv7 arm64
[TRACE] Code Signing ./SocketIO.framework/SocketIO with Identity -
[TRACE] /usr/bin/codesign --force --sign - --preserve-metadata=identifier,entitlements ./SocketIO.framework/SocketIO
[TRACE] ./SocketIO.framework/SocketIO: replacing existing signature
[TRACE] Stripped ./Starscream.framework/Starscream of architectures: armv7 arm64
[TRACE] Code Signing ./Starscream.framework/Starscream with Identity -
[TRACE] /usr/bin/codesign --force --sign - --preserve-metadata=identifier,entitlements ./Starscream.framework/Starscream
[TRACE] ./Starscream.framework/Starscream: replacing existing signature
[TRACE]   
[TRACE] Touch build/Products/Debug-iphonesimulator/FleeterDev.app
[TRACE]     cd /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone
[TRACE]     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/douglashennrich/.gems/bin:/usr/local/share/android-sdk/platform-tools/:/Users/douglashennrich/.fastlane/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin:/Users/douglashennrich/.nvm/versions/node/v8.11.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
[TRACE]     /usr/bin/touch -c /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone/build/Products/Debug-iphonesimulator/FleeterDev.app
[TRACE]   
[TRACE] ProcessProductPackaging "" build/Intermediates/FleeterDev.build/Debug-iphonesimulator/FleeterDev.build/FleeterDev.app.xcent
[TRACE]     cd /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone
[TRACE]     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/douglashennrich/.gems/bin:/usr/local/share/android-sdk/platform-tools/:/Users/douglashennrich/.fastlane/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin:/Users/douglashennrich/.nvm/versions/node/v8.11.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
[TRACE]     
[TRACE] Entitlements:
[TRACE] { 
[TRACE]     "com.apple.security.get-task-allow" = 1;
[TRACE] } 
[TRACE]     builtin-productPackagingUtility -entitlements -format xml -o /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone/build/Intermediates/FleeterDev.build/Debug-iphonesimulator/FleeterDev.build/FleeterDev.app.xcent
[TRACE]   
[TRACE] CodeSign build/Products/Debug-iphonesimulator/FleeterDev.app
[TRACE]     cd /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone
[TRACE]     export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
[TRACE]     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/douglashennrich/.gems/bin:/usr/local/share/android-sdk/platform-tools/:/Users/douglashennrich/.fastlane/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin:/Users/douglashennrich/.nvm/versions/node/v8.11.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
[TRACE]     
[TRACE] Signing Identity:     "-"
[TRACE]     /usr/bin/codesign --force --sign - --entitlements /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone/build/Intermediates/FleeterDev.build/Debug-iphonesimulator/FleeterDev.build/FleeterDev.app.xcent --timestamp=none /Users/douglashennrich/Documents/Projects/Reset/Fleeter/Mobile/Main/build/iphone/build/Products/Debug-iphonesimulator/FleeterDev.app
[TRACE]   
[TRACE] ** BUILD SUCCEEDED **
[INFO]  Finished building the application in 43s 160ms
[INFO]  Launching iOS Simulator
[TRACE] [ioslib] Selected iOS Simulator: iPhone 6s
[TRACE] [ioslib]   UDID    = 1E24ED91-5F10-452E-89F2-E0B9C8BCC334
[TRACE] [ioslib]   iOS     = 11.4
[TRACE] [ioslib] Autoselected Xcode: 9.4
[TRACE] [ioslib] Checking if the simulator /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator is already running
[TRACE] [ioslib] Simulator is not running
[TRACE] [ioslib] Tailing iPhone 6s Simulator system log: /Users/douglashennrich/Library/Logs/CoreSimulator/1E24ED91-5F10-452E-89F2-E0B9C8BCC334/system.log
[TRACE] [ioslib] Running: /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID 1E24ED91-5F10-452E-89F2-E0B9C8BCC334
[TRACE] [ioslib] Simulator is booted
[TRACE] [ioslib] iPhone 6s Simulator started
[TRACE] [ioslib] Running: osascript "/Users/douglashennrich/Library/Application Support/Titanium/mobilesdk/osx/7.1.1.GA/node_modules/ioslib/lib/sim_focus.scpt" "Simulator"
[TRACE] [ioslib] iPhone 6s Simulator successfully focused
[TRACE] [ioslib] Installing the app
[TRACE] [ioslib] App launched
[TRACE] [ioslib] Trying to connect to log server port 16192...
[TRACE] updating tiapp metadata with Appcelerator Platform...
[TRACE] Uploaded tiapp metadata with Appcelerator Platform!
janvennemann commented 6 years ago

Hey, could you provide a little more detail? Did you integrate the module into your own app? If so, can you post a code excerpt? Or did you try to run the example app?

DouglasHennrich commented 6 years ago

I follow these steps:

  1. Place the downloaded module into app/modules/iphone

  2. Clone this repo

  3. use carthage bootstrap under ios folder

  4. move all files from carthage/builds/ios to app/modules/iphone/ti.socketio/1.0.0/platform

  5. appc ti clean on my root project

  6. appc run -p ios -T simulator

My app doesn't start, it get stuck under splash screen and shutdown after a while without any errors on terminal

hansemannn commented 6 years ago

Why not using one of the official prepackaged releases? It also looks like you might forgot an $.index.open() in your application. The module is used internally already (as part of automated Karma unit-testing), so there must be a env-issue on your end. Let us know if you can share a sample project, but we will close the issue for now.

Lukic commented 6 years ago

Hii All

I'm having the same issue. I've downloaded the iOS and Android package from https://github.com/appcelerator-modules/titanium-socketio/releases

When I run the app on the simulator, it just gets stock on the splash screen. When the app is installed on a device it just opens and closes right aways after the Splash screen gets visible.

If I remove the Modules from the tiapp.xml the my app work perfekt again.

DouglasHennrich commented 6 years ago

Same thing for me, if I remove the module, it works. It’s the same behavior that Lukic.

hansemannn commented 6 years ago

Reopening for further investigation! It looks like the Swift version may not be picked up correctly. Underlaying error:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /Users/hknoechel/Library/Developer/CoreSimulator/Devices/C02D33D2-92F2-490F-A2A8-D978B36B0626/data/Containers/Bundle/Application/A14A0BA3-106C-4EC0-9462-2EB95E3B39B7/test_socketio.app/Frameworks/SocketIO.framework/SocketIO
  Reason: image not found
(lldb) 
hansemannn commented 6 years ago

Please try out the 1.0.1 version added to the above PR.

Lukic commented 6 years ago

I just added ios 1.0.1 to my APP and there is no code beside the declaration of the module inside the tiapp.xml.

Simulator : Still stops at the splash screen. Device: Is now working.

The Simulator is not outputting any error at all.

hansemannn commented 6 years ago

@Lukic Make sure to reset the Sim to have a fresh version installed. Also make sure you have Swift 4.1 installed e.g. by using swift -v

Lukic commented 6 years ago

I'm running : Apple Swift version: 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2) Simulator : iPhone 8 (v11.3) Ti SDK: 7.1.1 GA

I've uninstalled the app from the simulator. Cleaned the App Project but the app still stops at the splash screen.

DouglasHennrich commented 6 years ago

@hansemannn I do a full clean up simulator and ti clean on my app and now it's working!

btw how can I use these events connect_error reconnect_failed reconnecting that it's listen into socket.io.on ?

const io = require ('ti.socketio');

const socket = io.connect(Alloy.CFG.socket.wss, Alloy.CFG.socket.opts);

socket.io.on // undefined is not an object (evaluating 'socket.io.on')
Lukic commented 6 years ago

@DouglasHennrich I belive you have to use :

socket.on('connect_error', function() {});

DouglasHennrich commented 6 years ago
socket.on('pong', (e) => {
    console.warn('============');
    console.warn(`socket.io - ping ${e}ms`);
  });

  //
  socket.on('connect_error', (e) => {
    App.Log('[Socket Manager] Connect error:', e);
  });

  socket.on('reconnect_failed', () => {
    console.warn('============');
    console.warn('socket.io - reconnect_failed');
  });

  socket.on('reconnecting', (n) => {
    console.warn('============');
    console.warn('socket.io - reconnecting:', n);
  });

I don't think so, since it's crashing the app now

Lukic commented 6 years ago

@DouglasHennrich is that on your Simulator or Device that the app is crashing?

DouglasHennrich commented 6 years ago

Simulator

Lukic commented 6 years ago

@DouglasHennrich wicked. I'm testing the same code on my device and it doesn't crash.

But I still cant make the app run on my simulator. Ohh what a happy joy !!

DouglasHennrich commented 6 years ago

try to erase all contents from simulator

Lukic commented 6 years ago

@DouglasHennrich did you try

socket.on('connect_error', function(error) { Ti.API.log(error); });

DouglasHennrich commented 6 years ago

I just add these events listeners and the app crashs. pong, connect_error, reconnect_failed, reconnecting, disconnect, error, reconnect, connect

DouglasHennrich commented 6 years ago
const io = require('ti.socketio');
const socket = io.connect('wss://devnode.fleeterapp.com', {
            "transports" : [ "websocket" ]
            , "secure": true
            , "reconnection": true
            , "reconnectionDelay": 7000
            , "reconnectionDelayMax": 15000
          });

socket.on('connect', () => {
   console.log('connected');
});

and the app crashs

Lukic commented 6 years ago

@DouglasHennrich I just tryed to connect to your server with this code. And there was no isses. I get connected.

var io = require('ti.socketio'); var socket = io.connect("wss://devnode.fleeterapp.com");

socket.on('connect', function() { Ti.API.log("Socket connected"); });

socket.on('connect_error', function(error) {

Ti.API.log("connect_error");

});

DouglasHennrich commented 6 years ago

maybe there's a problem with secure: true flag; that ensures SSL protocol

DouglasHennrich commented 6 years ago

seems like it's because transports : [ 'websocket' ] and secure: true options

hansemannn commented 6 years ago

@DouglasHennrich That works fine for me. Although "reconnectionDelayMax" is not supported on iOS (per native library limitation). Also note that you really need Swift 4.1 in order to get the Swift binary to work. Closing this issue again as the initial issue is fixed now.

DouglasHennrich commented 6 years ago

@hansemannn I'm using Apple Swift version: 4.1.2 and the apps crash when I set up the transports and secure flags =/

janvennemann commented 6 years ago

@DouglasHennrich That's because the iOS client has slightly different options. For now you have to use forceWebsockets: true and secure: true on iOS (see https://nuclearace.github.io/Socket.IO-Client-Swift/Enums/SocketIOClientOption.html#/s:8SocketIO0A14IOClientOptionO15forceWebsocketsACSbcACmF). Android should be fine with transports and secure since that is supported on the native client.

If you still experience issues can you please open a new one here on GitHub so we can track it in a dedicated thread. Thank you!

adriendillens commented 6 years ago

Hi @janvennemann , @hansemannn, @Lukic and other people

First of all, thanks for this module ;-)

I have installed 1.0.1 module version for both android & iphone. On Android, it works fine.

But on iphone (simulator & iPhone SE device), same problem as @DouglasHennrich ! It builds successfully, but when i open the app, i see a black screen, and the app closes. Absolutely nothing to see in logs when i launch the app.

I have installed Swift 4.1.0 : Apple Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-apple-darwin16.7.0

The controller that uses socket.io module functions is completely commented right now (to be sure that it's not a code issue).

I tried to delete / download new simulator, and build on it -> same problem.

When i build without the socket.io module, everything works fine.

These logs appears at the end of the compilation (and i think this is the issue) :

[TRACE] Requested Swift ABI version based on scanned binaries: 6 [TRACE] Found library with mismatched Swift ABI version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib 5 (requested 6) [TRACE] Found library with mismatched Swift ABI version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCoreFoundation.dylib 5 (requested 6) [TRACE] Found library with mismatched Swift ABI version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftDarwin.dylib 5 (requested 6) [TRACE] Found library with mismatched Swift ABI version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftDispatch.dylib 5 (requested 6) [TRACE] Found library with mismatched Swift ABI version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftFoundation.dylib 5 (requested 6) [TRACE] Found library with mismatched Swift ABI version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftObjectiveC.dylib 5 (requested 6)

Something interesting : i follow this tutorial to install Swift 4.1 version (which worked) : https://medium.com/xcblog/switching-swift-versions-inside-xcode-using-toolchains-755b28831c43

But when i close the terminal, and opens a new, my previous swift version has been reset : Swift 4.0.0. I search for titanium documentation to force build for Swift specific version, but nothing ...

Please help :-)

adriendillens commented 6 years ago

All right guys, i found the solution ! Maybe this will help for next developers.

The problem was xcode. I used xcode v9.0.1, and i installed Swift 4.1 toolchain then, switch on it (because default Swift version was 4.0 for xcode 9.0.1).

In terminal, swift --version outputs "4.1" -> but the problem is that xcode use its default swift 4.0 for build my titanium app through.

So, i decided to ununistall current xcode, then install the corresponding xcode version for defaut swift 4.1 -> It is xcode 9.3

PS : I also update titanium SDK from 7.1.1.GA to 7.2.0.GA (i don't know if it changes something)

And it works fine now.

Hope this helps !

Thanks again for this module :-)