Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Last active October 6, 2023 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleclarson/4da83cffa9d20c11013a99fc98615888 to your computer and use it in GitHub Desktop.
Save aleclarson/4da83cffa9d20c11013a99fc98615888 to your computer and use it in GitHub Desktop.
Socket SDK + VSCode

VSCode support for Socket native development

  1. Install https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
  2. Copy the relevant CMakeLists.txt file from this gist:
    # For macOS development:
    wget -O src/CMakeLists.txt https://gist.githubusercontent.com/aleclarson/4da83cffa9d20c11013a99fc98615888/raw/CMakeLists.macos.txt
    
    # For iOS development:
    wget -O src/CMakeLists.txt https://gist.githubusercontent.com/aleclarson/4da83cffa9d20c11013a99fc98615888/raw/CMakeLists.ios.txt
  3. Generate the src/compile_commands.json file needed by clangd:
    cd src && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

TODO

  • keep CMakeLists.txt aligned with this file by adding a command to the Socket CLI that generates CMakeLists.txt for you
  • add these files (generated by cmake) to src/.gitignore
    .cache/
    CMakeCache.txt
    CMakeFiles/
    CMakeLists.txt
    Makefile
    cmake_install.cmake
    compile_commands.json
    
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -ObjC++ -DIOS=1")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE STRING "C++ compiler" FORCE)
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk")
project(socket-ios)
add_executable(socket-ios app/app.hh core/apple.hh core/apple.mm core/common.hh core/core.cc core/core.hh core/fs.cc core/ipc.cc core/javascript.cc core/loop.cc core/peer.cc core/runtime-preload-sources.hh core/runtime-preload.hh core/timers.cc core/udp.cc mobile/ios.mm window/options.hh)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -ObjC++ -framework UniformTypeIdentifiers -framework CoreBluetooth -framework Network -framework UserNotifications -framework WebKit -framework Cocoa")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE STRING "C++ compiler" FORCE)
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
project(socket-macos)
add_executable(socket-macos app/mac.cc core/apple.mm core/core.cc core/fs.cc core/ipc.cc core/javascript.cc core/loop.cc core/peer.cc core/timers.cc core/udp.cc desktop/main.cc process/unix.cc window/mac.mm)
@aleclarson
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment