Missing example project and documentation for building for swift
Steps to Reproduce
- Follow along with weather example (https://github.com/jamesmontemagno/embeddinator-weather) until I realize I can't use delegates in obj-c (https://github.com/mono/Embeddinator-4000/issues/217)
- Attempt to look for a swift example in the embedding docs here (https://docs.microsoft.com/en-us/xamarin/tools/dotnet-embedding/get-started/objective-c/)
Expected Behavior
Expect to find an example or a walkthrough on how to build for swift
Actual Behavior
No walkthrough and attempting to reverse engineer the embeddinator code has gotten me so far to a
System.IO.FileNotFoundException: Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
error. Having a super simple swift example (and hopefully a "you can use delegates" confirmation) would be greatly appreciated!
(You can take the attached project, add back in the embeddinator project and do a build in Visual Studio for Mac to reproduce issues run into from my naive attempts)
Environment
mono '${SolutionDir}/packages/Embeddinator-4000.0.4.0/tools/Embeddinator-4000.exe' 'bin/Debug/test5.dll' --target=static --platform=iOS --outdir='${SolutionDir}/iosoutput' -c --debug --gen=swift
Build Logs
Parsing assemblies... Parsed 'test5.dll' Processing assemblies...
Unhandled Exception: System.IO.FileNotFoundException: Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, System.Boolean throwOnError) [0x000ec] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRefImpl (IKVM.Reflection.Metadata.AssemblyRefTable+Record& rec) [0x00084] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRef (System.Int32 index) [0x00036] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.ModuleReader.ResolveType (System.Int32 metadataToken, IKVM.Reflection.IGenericContext context) [0x000ff] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.TypeDefImpl.get_BaseType () [0x00035] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Type.get_IsEnum () [0x00001] in <90104beb381b4b808b5b21c02f12857c>:0 at Embeddinator.Generators.ASTGenerator.Visit (IKVM.Reflection.TypeInfo typeInfo) [0x00068] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.Generators.ASTGenerator.Visit (IKVM.Reflection.Assembly assembly) [0x00043] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.Driver.Process () [0x00039] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.Driver.Run () [0x0004e] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.CLI.Main (System.String[] args) [0x00092] in <27f4a5e1850e4beb9b867456b4a97cab>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, System.Boolean throwOnError) [0x000ec] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRefImpl (IKVM.Reflection.Metadata.AssemblyRefTable+Record& rec) [0x00084] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRef (System.Int32 index) [0x00036] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.ModuleReader.ResolveType (System.Int32 metadataToken, IKVM.Reflection.IGenericContext context) [0x000ff] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Reader.TypeDefImpl.get_BaseType () [0x00035] in <90104beb381b4b808b5b21c02f12857c>:0 at IKVM.Reflection.Type.get_IsEnum () [0x00001] in <90104beb381b4b808b5b21c02f12857c>:0 at Embeddinator.Generators.ASTGenerator.Visit (IKVM.Reflection.TypeInfo typeInfo) [0x00068] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.Generators.ASTGenerator.Visit (IKVM.Reflection.Assembly assembly) [0x00043] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.Driver.Process () [0x00039] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.Driver.Run () [0x0004e] in <27f4a5e1850e4beb9b867456b4a97cab>:0 at Embeddinator.CLI.Main (System.String[] args) [0x00092] in <27f4a5e1850e4beb9b867456b4a97cab>:0 logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.
Example Project (If Possible)
Attached is example project (minus embeddinator package because it makes the upload too big (0.4.0 version pulled in via Visual Studio for Mac)) test5.zip
So the Embeddinator-4000 project doesn't claim to support Swift right now.
In theory, you can consume Objc into swift, so that combination it possible, but it doesn't surprise me that we don't have documentation convering it.
I'm going going to leave this open as an enhancement request.
Ah, got it. I saw what looked like swift callback generators in the source and hoped it was just undocumented but seems not. It would be a great enhancement as we're currently blocked on needing a way to do callbacks to keep the code consistent with other platforms and it doesn't seem from other threads that objective c supports this. I suspect routing objc into swift wouldn't fix that. Thanks for the response!