iosmacosxcode12carthage

install package socket.io-client-swift xcode 12


I need to install with carthage the package https://github.com/socketio/socket.io-client-swift with a Xcode 12 project.

i have a CartFile :

github "socketio/socket.io-client-swift" ~> 15.0.0

I have tried this command :

carthage update --platform iOS --use-xcframeworks

I try :

but always i have the same error :

CompileSwift normal i386 (in target 'SocketIO' from project 'Socket.IO-Client-Swift')
    cd /Users/admin/Documents/test2/Carthage/Checkouts/socket.io-client-swift
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/admin/Documents/test2/Carthage/Checkouts/socket.io-client-swift/Source/SocketIO/Engine/SocketEngine.swi$
/Users/admin/Documents/test2/Carthage/Checkouts/socket.io-client-swift/Source/SocketIO/Engine/SocketEngine.swift:27:8: error: could not find module 'Starscream' for target 'i386-apple-ios-simulator'; found: arm64, armv7-$
import Starscream

Maybe i need to create a ${ARCHS_STANDARD} in some env or/and custom file ?


Solution

  • I found that Carthage doesn't set the FRAMEWORK_SEARCH_PATHS correctly in many cases, which for me caused Socket.IO to be unable to find Starscream when compiling.

    Here's a workaround script you can use to set the FRAMEWORK_SEARCH_PATHS:

    # carthage.sh
    # Usage example: ./carthage.sh build --use-xcframeworks --platform iOS
    
    set -euo pipefail
    
    xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
    trap 'rm -f "$xcconfig"' INT TERM HUP EXIT
    
    echo "FRAMEWORK_SEARCH_PATHS=\$(inherited) $(pwd)/Carthage/Build" >> $xcconfig
    # echo 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES' >> $xcconfig # You may or may not need this depending on your project setup
    
    export XCODE_XCCONFIG_FILE="$xcconfig"
    carthage "$@"