Hi there, I'm trying to run `moko-socket-io` proje...
# moko
a
Hi there, I'm trying to run
moko-socket-io
project I'm able to run the sample android app after changing target sdk, jdk and installing pod dependencies but the ios sample app build is failing with following outputs. I'm trying to implement changes for this issue. Please help me setup iOS project. Thanks in advance! 1.
./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
Copy code
> Task :sample:mpp-library:linkMultiPlatformLibraryDebugFrameworkIosArm64 FAILED
w: Following libraries are specified to be exported with -Xexport-library, but not included to the build:
/Users/whoknows/Developement/OSS/moko-socket-io/socket-io/build/libs/iosArm64/main/socket-io-cinterop-cocoapodMokoSocketIo.klib
2.
cd sample/ios-app && set -o pipefail && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug -sdk iphonesimulator -arch x86_64 build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
Copy code
** BUILD FAILED **
The following build commands failed:
        PhaseScriptExecution [CP-User]\ Compile\ Kotlin/Native /Users/whoknows/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/MultiPlatformLibrary.build/Script-BA95BCD441577347D0C821C3908AFD77.sh (in target 'MultiPlatformLibrary' from project 'Pods')
(1 failure)
a
> Task samplempp-library:linkMultiPlatformLibraryDebugFrameworkIosArm64 FAILED
w: Following libraries are specified to be exported with -Xexport-library, but not included to the build:
/Users/whoknows/Developement/OSS/moko-socket-io/socket-io/build/libs/iosArm64/main/socket-io-cinterop-cocoapodMokoSocketIo.klib
here you not show error. this warning not related to FAILED state. please give more log. i think you just not do
pod install
before run
./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
and cinterop can't find native lib. next step issue just same - you should show full log with error, not just "task failed"
a
Sorry for late reply I'd executed pod install before running the gradle task and this was the output:
Copy code
Analyzing dependencies
Downloading dependencies
Installing MultiPlatformLibrary (0.2.0)
Installing Socket.IO-Client-Swift (15.2.0)
Installing Starscream (3.1.1)
Installing mokoSocketIo (0.4.0)
Generating Pods project
Integrating client project
Pod installation complete! There are 2 dependencies from the Podfile and 4 total pods installed.
here's the full log for the gradle task: https://scans.gradle.com/s/5xdp7aj76ikvy Let me know you need anything else. Thanks!
I've updated agp, kotlin version in my fork and tried running the same gradle task and xcode command, both gradle task and xcodebuild command are executing successfully (both on local and ci/cd job) here's the gradle task scan log. output of xcodebuild command:
Copy code
GenerateDSYMFile /Users/whoknows/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/mokoSampleResources.app.dSYM /Users/whoknows/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/mokoSampleResources.app/mokoSampleResources (in target 'TestProj' from project 'TestProj')
    cd /Users/whoknows/Developement/OSS/moko-socket-io/sample/ios-app
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/whoknows/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/mokoSampleResources.app/mokoSampleResources -o /Users/whoknows/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/mokoSampleResources.app.dSYM

** BUILD SUCCEEDED **
but if I run the sample ios app from xcode/androidstudio the build is throwing error so not able to see any output on simulator :
Copy code
Ld /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/mokoSampleResources.app/mokoSampleResources normal (in target 'TestProj' from project 'TestProj')
    cd /Users/whoknows/Developement/OSS/moko-socket-io/sample/ios-app
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios12.0-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk -Os -L/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/usr/lib/swift -F/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator -F/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/Socket.IO-Client-Swift -F/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/Starscream -F/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/mokoSocketIo -F/Users/whoknows/Developement/OSS/moko-socket-io/sample/ios-app/Pods/../../mpp-library/build/cocoapods/framework -filelist /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/TestProj.build/Debug-iphonesimulator/TestProj.build/Objects-normal/arm64/mokoSampleResources.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/TestProj.build/Debug-iphonesimulator/TestProj.build/Objects-normal/arm64/mokoSampleResources_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/TestProj.build/Debug-iphonesimulator/TestProj.build/Objects-normal/arm64/mokoSampleResources.swiftmodule -lc++ -framework MultiPlatformLibrary -framework SocketIO -framework Starscream -framework mokoSocketIo -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/TestProj.build/Debug-iphonesimulator/TestProj.build/mokoSampleResources.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/TestProj.build/Debug-iphonesimulator/TestProj.build/mokoSampleResources.app-Simulated.xcent.der -framework Pods_TestProj -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/TestProj.build/Debug-iphonesimulator/TestProj.build/Objects-normal/arm64/mokoSampleResources_dependency_info.dat -o /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/mokoSampleResources.app/mokoSampleResources
ld: warning: ignoring file '/Users/whoknows/Developement/OSS/moko-socket-io/sample/mpp-library/build/cocoapods/framework/MultiPlatformLibrary.framework/MultiPlatformLibrary': found architecture 'x86_64', required architecture 'arm64'
ld: Undefined symbols:
  _OBJC_CLASS_$_MPLTesting, referenced from:
       in TestViewController.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'TestProj' from project 'TestProj')
warning: Run script build phase '[CP] Embed Pods Frameworks' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'TestProj' from project 'TestProj')
warning: Run script build phase '[CP-User] Compile Kotlin/Native' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'MultiPlatformLibrary' from project 'Pods')
warning: Run script build phase '[CP] Copy dSYMs' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'MultiPlatformLibrary' from project 'Pods')
** BUILD FAILED **


The following build commands failed:
	Ld /Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/mokoSampleResources.app/mokoSampleResources normal (in target 'TestProj' from project 'TestProj')
(1 failure)
I'm not sure if any issue with my env/sdk versions.
a
in gradle scan you can see:
Copy code
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.	
output:	
-iphoneos_version_min has been renamed to -ios_version_min	
ld: unknown options: -sdk_version
thats mean that you use xcode version newest than supported by kotlin gradle plugin in project. need to update kotlin gradle plugin
you already update in your fork as i see, its good. error:
Copy code
ld: warning: ignoring file '/Users/whoknows/Developement/OSS/moko-socket-io/sample/mpp-library/build/cocoapods/framework/MultiPlatformLibrary.framework/MultiPlatformLibrary': found architecture 'x86_64', required architecture 'arm64'
ld: Undefined symbols:
  _OBJC_CLASS_$_MPLTesting, referenced from:
       in TestViewController.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mean that
MultiPlatformLibrary
compiled for x86_64 but you now build ios app for arm64 architecture. i think you try to run on iOS simulator on m1 mac. need to update kotlin targets list and cocoapods integration
add please in gradle.properties this one option:
Copy code
mobile.multiplatform.withoutIosSimulatorArm64=false
and also update podspec file to:
Copy code
Pod::Spec.new do |spec|
    spec.name                     = 'MultiPlatformLibrary'
    spec.version                  = '0.1.0'
    spec.homepage                 = 'Link to a Kotlin/Native module homepage'
    spec.source                   = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
    spec.authors                  = 'IceRock Development'
    spec.license                  = ''
    spec.summary                  = 'Shared code between iOS and Android'

    spec.vendored_frameworks      = "build/cocoapods/framework/#{spec.name}.framework"
    spec.libraries                = "c++"
    spec.module_name              = "#{spec.name}_umbrella"

    spec.ios.deployment_target = '11.0'
    spec.osx.deployment_target = '10.6'

    spec.pod_target_xcconfig = {
        'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*ebug]' => 'debug',
        'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*elease]' => 'release',
        'CURENT_SDK[sdk=iphoneos*]' => 'iphoneos',
        'CURENT_SDK[sdk=iphonesimulator*]' => 'iphonesimulator',
        'CURENT_SDK[sdk=macosx*]' => 'macos'
    }

    spec.script_phases = [
        {
            :name => 'Compile Kotlin/Native',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
if [ "$KOTLIN_FRAMEWORK_BUILD_TYPE" == "debug" ]; then
  CONFIG="Debug"
else
  CONFIG="Release"
fi

if [ "$CURENT_SDK" == "iphoneos" ]; then
  TARGET="Ios"
  ARCH="Arm64"
elif [ "$CURENT_SDK" == "macos" ]; then
  TARGET="Macos"
  if [ "$NATIVE_ARCH" == "arm64" ]; then
    ARCH="Arm64"
  else
    ARCH="X64"
  fi
else
  if [ "$NATIVE_ARCH" == "arm64" ]; then
    TARGET="IosSimulator"
    ARCH="Arm64"
  else
    TARGET="Ios"
    ARCH="X64"
  fi
fi

MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library"
GRADLE_TASK="syncMultiPlatformLibrary${CONFIG}Framework${TARGET}${ARCH}"

"$MPP_PROJECT_ROOT/../gradlew" -p "$MPP_PROJECT_ROOT" "$GRADLE_TASK"
            SCRIPT
        }
    ]
end
a
Thanks for replying. I updated these and tried to run it (pod install and same steps) still getting error on AS/XCode run, gradle task and xcodebuild command is not an issue but getting error on AS/XCode run, here's the log file:
a
Copy code
ld: warning: search path '/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/Socket.IO-Client-Swift' not found
ld: warning: search path '/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/Starscream' not found
ld: warning: search path '/Users/whoknows/Developement/OSS/moko-socket-io/build/ios/Debug-iphonesimulator/mokoSocketIo' not found
ld: framework 'SocketIO' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
this mean that pods was not found/not compiled. check that you run
pod install
before gradle compilation. gradle should see pods and successfully compile them to link with binaries
a
pod install gave this output:
Copy code
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 2 dependencies from the Podfile and 4 total pods installed.
should I run after pod install?
Copy code
./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosArm64
or
Copy code
./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
a
Copy code
./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosSimulatorArm64
this one will be better. is this command run successful?
a
no this is giving task not found error:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Task 'syncMultiPlatformLibraryDebugFrameworkIosSimulatorArm64' not found in root project 'moko-socket-io' and its subprojects.
also tried with those 2 it gives same error on simulator run
a
Yes, after this change I re run the pod install command then the gradle task
@alex009 I was not able to fix this, is there any other way I should try? You can point me to some resources where I can learn more about these things?
a
hi. please push all current changes to your fork and give me link to actual branch, i will check it on this weekend
a
thanks @alex009, this (dev) is the branch were all these changes are pushed, Let me know anything else you need.
a
a
Thanks a lot! I'll merge and try to run it
Finally 🎉