Denis Matafonov Denis Matafonov - 3 years ago 258
Swift Question

Cant import module to xcode

I have the same problem as described here: I cant add socket.io module to my project.

I've tried all ways of dragging and dropping as described in answer, I've tried adding files to project from File menu. No matter what I do I get compile error "SocketIO module not found" on string

import SocketIO


Is there a regular way of adding modules? Command line? Sorry if question sounds dummy - Im new not only to swift but to mac also (bought it to learn swift).

Answer Source

If that´s an issue (which it seems to be for not only you) I would go with CocoaPods instead.

Start by:

  1. Do this in your terminal: sudo gem install cocoapods
  2. Go to your project folder and open the terminal in that folder (cd ...)
  3. Do this in your terminal: pod init
  4. Remove all content in your newly created pod file and add this instead:


use_frameworks!

target 'YourApp' do
    pod 'Socket.IO-Client-Swift', '~> 12.0.0' # Or latest version
end
  1. Do this in your terminal: pod install
  2. Open your project, note that you need to open the .xcworkspace file to be able to access your pods

  3. Import the module import SocketIO

I created a sample project for you with CocoaPods installed and I have added SocketIO for you. Remember to run the .xcworkspace file. You can download the project here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download