You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
I'm currently working on iOS bindings for cobrowse.io library and I have found quite interesting behavior that I'd like to share with you.
The CobrowseIO is actually an ObjC library but it depends on two Swift libs: SocketIO and Starscream. So, I have created three separate bindings projects, and the dependency hierarchy looks like:
The app worked fine on iPhone with iOS 12.2 and I was surprised when my app crashed on simulator with the following message:
Dyld Error Message:
Library not loaded: @rpath/SocketIO.framework/SocketIO
Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/CBD647EE-9558-45C3-9715-E7511F5662C7/data/Containers/Bundle/Application/FE14C4FA-E404-43E8-984B-5289FC7B24B8/MyiOSApplication.app/Frameworks/CobrowseIO.framework/CobrowseIO
Reason: image not found
Build log:
Target "_SwiftFrameworksMac" in file "/Users/user/.nuget/packages/xamarin.swift/1.0.2/build/xamarinios/Xamarin.Swift.targets":
Using "CheckSwiftVersionsTask" task from assembly "/Users/user/.nuget/packages/xamarin.swift/1.0.2/build/xamarinios/../../SwiftSupport.dll".
Task "CheckSwiftVersionsTask"
Looking for Swift version on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/CobrowseIO
Expected Swift header on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/Headers/CobrowseIO-Swift.h
bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/Headers/CobrowseIO-Swift.h do not exist.
Installed: 5.0
Done executing task "CheckSwiftVersionsTask".
Task "ScanSwiftTask" skipped, due to false condition; ($(_ShouldIncludeSwiftDylibs)) was evaluated as (False).
Task "IncludeSwiftTask" skipped, due to false condition; ($(_ShouldIncludeSwiftDylibs)) was evaluated as (False).
As you can see, Xamarin.Swift didn't check if SocketIO.iOS and Starscream.iOS were actually Swift bindings.
The workaround is pretty simple: I just added the following lines to the LinkerPleaseInclude file:
public void Include(Starscream.FoundationStream _)
{
_ = new Starscream.FoundationStream();
}
public void Include(SocketIO.SocketManager _)
{
_ = new SocketIO.SocketManager(new NSUrl("https://example.com"), null);
}
The app now no longer crashes and the build log contains this:
Target "_SwiftFrameworksMac" in file "/Users/user/.nuget/packages/xamarin.swift/1.0.2/build/xamarinios/Xamarin.Swift.targets":
Using "CheckSwiftVersionsTask" task from assembly "/Users/user/.nuget/packages/xamarin.swift/1.0.2/build/xamarinios/../../SwiftSupport.dll".
Task "CheckSwiftVersionsTask"
Looking for Swift version on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/CobrowseIO
Looking for Swift version on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/Starscream.framework/Starscream
Looking for Swift version on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/SocketIO.framework/SocketIO
Expected Swift header on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/Starscream.framework/Headers/Starscream-Swift.h
bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/Starscream.framework/Headers/Starscream-Swift.h exists.
Expected Swift header on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/Headers/CobrowseIO-Swift.h
Expected Swift header on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/SocketIO.framework/Headers/SocketIO-Swift.h
bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/Headers/CobrowseIO-Swift.h do not exist.
bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/SocketIO.framework/Headers/SocketIO-Swift.h exists.
Including Swift dylibs because you are targeting an OS version that doesnt include it.
Installed: 5.0
SocketIO Framework: 5.0
Starscream Framework: 5.0
Done executing task "CheckSwiftVersionsTask".
Using "ScanSwiftTask" task from assembly "/Users/user/.nuget/packages/xamarin.swift/1.0.2/build/xamarinios/../../SwiftSupport.dll".
Task "ScanSwiftTask"
Frameworks: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/CobrowseIO, bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/SocketIO.framework/SocketIO, bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/Starscream.framework/Starscream
Looking for Swift Dependency on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/CobrowseIO
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/CobrowseIO.framework/CobrowseIO'
Looking for Swift Dependency on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/SocketIO.framework/SocketIO
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/SocketIO.framework/SocketIO'
Looking for Swift Dependency on: bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/Starscream.framework/Starscream
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/Starscream.framework/Starscream'
Swift Dependency Found: libswiftCore.dylib
Swift Dependency Found: libswiftCoreFoundation.dylib
Swift Dependency Found: libswiftCoreGraphics.dylib
Swift Dependency Found: libswiftCoreImage.dylib
Swift Dependency Found: libswiftDarwin.dylib
Swift Dependency Found: libswiftDispatch.dylib
Swift Dependency Found: libswiftFoundation.dylib
Swift Dependency Found: libswiftMetal.dylib
Swift Dependency Found: libswiftObjectiveC.dylib
Swift Dependency Found: libswiftQuartzCore.dylib
Swift Dependency Found: libswiftUIKit.dylib
Looking for Swift Dependency on: libswiftCore.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib'
Looking for Swift Dependency on: libswiftCoreGraphics.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCoreGraphics.dylib'
Looking for Swift Dependency on: libswiftObjectiveC.dylib
Looking for Swift Dependency on: libswiftDarwin.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftDarwin.dylib'
Looking for Swift Dependency on: libswiftCoreImage.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCoreImage.dylib'
Looking for Swift Dependency on: libswiftDispatch.dylib
Looking for Swift Dependency on: libswiftMetal.dylib
Looking for Swift Dependency on: libswiftUIKit.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftUIKit.dylib'
Looking for Swift Dependency on: libswiftCoreFoundation.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCoreFoundation.dylib'
Looking for Swift Dependency on: libswiftQuartzCore.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftQuartzCore.dylib'
Looking for Swift Dependency on: libswiftFoundation.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftMetal.dylib'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftObjectiveC.dylib'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftFoundation.dylib'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftDispatch.dylib'
Swift Dependency Found: libswiftos.dylib
Looking for Swift Dependency on: libswiftos.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -l '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftos.dylib'
Done executing task "ScanSwiftTask".
Using "IncludeSwiftTask" task from assembly "/Users/user/.nuget/packages/xamarin.swift/1.0.2/build/xamarinios/../../SwiftSupport.dll".
Task "IncludeSwiftTask"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib' -archs
Copying: libswiftCore.dylib, libswiftCoreFoundation.dylib, libswiftCoreGraphics.dylib, libswiftCoreImage.dylib, libswiftDarwin.dylib, libswiftDispatch.dylib, libswiftFoundation.dylib, libswiftMetal.dylib, libswiftObjectiveC.dylib, libswiftQuartzCore.dylib, libswiftUIKit.dylib, libswiftos.dylib
Swift Arcs Needed: i386, x86_64
Swift Arcs Available: i386, x86_64
Copying: libswiftCore.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftCore.dylib'
Copying: libswiftCoreFoundation.dylib
Copying: libswiftCoreImage.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCoreFoundation.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftCoreFoundation.dylib'
Copying: libswiftCoreGraphics.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCoreGraphics.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftCoreGraphics.dylib'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCoreImage.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftCoreImage.dylib'
Copying: libswiftDarwin.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftDarwin.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftDarwin.dylib'
Copying: libswiftDispatch.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftDispatch.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftDispatch.dylib'
Copying: libswiftFoundation.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftFoundation.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftFoundation.dylib'
Copying: libswiftMetal.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftMetal.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftMetal.dylib'
Copying: libswiftQuartzCore.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftQuartzCore.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftQuartzCore.dylib'
Copying: libswiftUIKit.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftUIKit.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftUIKit.dylib'
Copying: libswiftos.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftos.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftos.dylib'
Copying: libswiftObjectiveC.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftObjectiveC.dylib' -create -output 'bin/iPhoneSimulator/Debug/MyiOSApplication.app/Frameworks/libswiftObjectiveC.dylib'
Done executing task "IncludeSwiftTask".
Done building target "_SwiftFrameworksMac" in project "MyiOSApplication.csproj".
Apparently, _Frameworks MSBuild item does not include frameworks that aren't used in the app's code directly.
The text was updated successfully, but these errors were encountered:
Thanks for sharing that @lassana . That is very interesting. I had no idea this was an issue.
On one hand this is a feature on C# world as the app won't include things it doesn't need, but as this is a reference to the native world (either Swift or Objective-C) it can't rely only on C# references. I wonder if the behaviour is different for Swift and Objective-C bindings.
I know that when doing a binding you can include a list of dependencies for frames on the link with.cs file. Something like Frameworks = "SocketIO" have you tried that to see if it changes anything?
@Flash3001 I ended up with a LinkerPleaseInclude file added to the ObjC binding project, which references C# code from Swift binding projects. Something like this.
Hi there,
I'm currently working on iOS bindings for cobrowse.io library and I have found quite interesting behavior that I'd like to share with you.
The
CobrowseIO
is actually an ObjC library but it depends on two Swift libs:SocketIO
andStarscream
. So, I have created three separate bindings projects, and the dependency hierarchy looks like:The app worked fine on iPhone with iOS 12.2 and I was surprised when my app crashed on simulator with the following message:
Build log:
As you can see,
Xamarin.Swift
didn't check ifSocketIO.iOS
andStarscream.iOS
were actually Swift bindings.The workaround is pretty simple: I just added the following lines to the LinkerPleaseInclude file:
The app now no longer crashes and the build log contains this:
Apparently,
_Frameworks
MSBuild item does not include frameworks that aren't used in the app's code directly.The text was updated successfully, but these errors were encountered: