xamarin / binding-tools-for-swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

M1 mac helloswift sample make success but make runit failed

jingliancui opened this issue · comments

commented

Mac M1

Xcode
Version 12.5.1 (12E507)

make command log:

Last login: Thu Sep  9 20:05:23 on ttys001
ericcui@ericdeMacBook-Pro helloswift % make
/usr/bin/swiftc -sdk `xcrun --show-sdk-path` -emit-module -emit-library -enable-library-evolution -emit-module-interface -module-name HelloMod *.swift
../../binding-tools-for-swift --swift-bin-path /usr/bin --swift-lib-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift --retain-swift-wrappers -o . -C . -module-name HelloMod 
mcs -nowarn:CS0169 -lib:../lib -r:SwiftRuntimeLibrary.Mac -lib:. *.cs -out:HelloMod.exe
ericcui@ericdeMacBook-Pro helloswift % 

make runit command log:

ericcui@ericdeMacBook-Pro helloswift % make runit

Unhandled Exception:
System.DllNotFoundException: libXamWrapping.dylib assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) HelloMod.NativeMethodsForHello.PImethod_HelloXamarin_HelloddoHello()
  at HelloMod.Hello.DoHello () [0x00000] in <9cd04eb66cdc447189b263a0867ace33>:0 
  at Tester.MainClass.Main (System.String[] args) [0x00000] in <9cd04eb66cdc447189b263a0867ace33>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libXamWrapping.dylib assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) HelloMod.NativeMethodsForHello.PImethod_HelloXamarin_HelloddoHello()
  at HelloMod.Hello.DoHello () [0x00000] in <9cd04eb66cdc447189b263a0867ace33>:0 
  at Tester.MainClass.Main (System.String[] args) [0x00000] in <9cd04eb66cdc447189b263a0867ace33>:0 
make: *** [runit] Error 1
ericcui@ericdeMacBook-Pro helloswift % 

Can you check to see if there exists a libXamWrapping.dylib and if it contains the right architecture?
Thanks for the output log!

commented

@stephen-hawley The make command will generate the libXamWrapping.dylib and it's arch is arm64, please take a look to the picture.
2

Awesome! So the file is there! Next step is to see if mono is trying to load it or not.
If you set MONO_LOG_LEVEL=debug and try running the app, you should get a vast amount of debug spew that will show what's trying to load. I'm guessing that it's not finding the right version of libswiftCore.dylib.

commented

@stephen-hawley Could you teach me where to set MONO_LOG_LEVEL.
I try add it after runit: at the make file but no extra debug info while run the make runit command.

commented

Thanks for @rolfbjarne teach me use export MONO_LOG_LEVEL=debug
And here is the logfile

commented

I found one Snippets about this said libXamWrapping.dylib is not have the matching architecture.

Mono: DllImport error loading library '/Users/ericcui/Desktop/binding-tools-for-swift/samples/helloswift/libXamWrapping.dylib': 'dlopen(/Users/ericcui/Desktop/binding-tools-for-swift/samples/helloswift/libXamWrapping.dylib, 9): no suitable image found.  Did find:
	./libXamWrapping.dylib: no matching architecture in universal wrapper
	/Users/ericcui/Desktop/binding-tools-for-swift/samples/helloswift/libXamWrapping.dylib: no matching architecture in universal wrapper
	/Users/ericcui/Desktop/binding-tools-for-swift/samples/helloswift/libXamWrapping.dylib: no matching architecture in universal wrapper
	/Users/ericcui/Desktop/binding-tools-for-swift/samples/helloswift/libXamWrapping.dylib: no matching architecture in universal wrapper'.

Thanks for the info. So it looks like the code that either the code that compiles the wrappers isn't including the right architecture or that there's some information missing from it. It does have arm64, so I'm leaning towards the latter. Alternately, mono might be looking for a different architecture entirely. Interesting.

commented

Ok,thank so much.