Hi everyone,
I want to make a dynamically loadable library (which is not known at compile time) which includes storyboards, images and other resources. I want to discover and load everything during run-time. According to what I've already figured out, I should use bundles, but I can't find how to create one in Xamarin Studio.
Any help would be appreciated,
Gergely
@bgergo said:
I have a solution with multiple applications. I just wanted to prevent the common assemblies from copying to every application's bundle.
I don't think that's avoidable, but @ChrisHamons would be the subject matter expert there.
Assembly.Load() is not enough for me regarding plugins, because my plugins need to contain some UI (images, storyboards) and I can't embed them (especially not storyboards) in a simple .NET assembly.
That may require that you change your plugin architecture somewhat to maybe accommodate unzipping a zip file containing your plugin dll and associated images/storyboards into a directory structure for loading.
Is there a tutorial on how to make custom control libraries?
https://developer.xamarin.com/guides/mac/user-interface/custom-controls/
I was able to get your example working with two changes:
Answers
Are you talking about frameworks (https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html)?
We currently don't have built in support for generating them, if this is what you are looking for.
However, they really are just specially named directories with things in the right locations. You could generate one doing something like this:
https://developer.xamarin.com/samples/mac/UseMSBuildToCopyFilesToBundleExample/
Hi Chris,
thank you for your fast response. I'm porting a middle-sized Windows app to Mac OS X, so it's possible that I will have a few questions at the beginning, for which I haven't found tutorials...
Regarding Bundles:
I think I'm talking about bundles. These would function as plugins in my application. I hope I'll manage to get on with this now.
Regarding Frameworks:
I also want to share code between applications, for which - if I'm right - the solution is frameworks. Regarding this, I couldn't prevent a .dll from copying to the application's bundle. I tried to move the appropriate .dll manually to /Library/Frameworks/MyFramework.framework but after this the app crashed. So I'd need a little help in connection with this as well.
Regarding Custom Control Libraries:
I also want to make a custom control library. I don't know if it should be a bundle, a library with module output, or what?
I tried to enter a custom class name in Xcode for a View/ViewController and the name of a referenced library in which the class resides, but it didn't work.
When sharing code between applications with C#/.NET/Xamarin, you use assemblies, not frameworks. Your dll is already an assembly, so there's nothing special to do. Just reference the assembly from your application and you're good to go. It's supposed to get copied to the application bundle, because it's needed by the application.
Plugins would essentially work the same way. You implement them as assemblies (dlls) but load them dynamically via Assembly.Load().
I have a solution with multiple applications. I just wanted to prevent the common assemblies from copying to every application's bundle.
Assembly.Load() is not enough for me regarding plugins, because my plugins need to contain some UI (images, storyboards) and I can't embed them (especially not storyboards) in a simple .NET assembly.
Is there a tutorial on how to make custom control libraries?
I don't think that's avoidable, but @ChrisHamons would be the subject matter expert there.
That may require that you change your plugin architecture somewhat to maybe accommodate unzipping a zip file containing your plugin dll and associated images/storyboards into a directory structure for loading.
https://developer.xamarin.com/guides/mac/user-interface/custom-controls/
Thank you very much, first two questions answered.
I read the custom control tutorial you posted. But I'm curious about how to put the controls in a separate library (and use them in Xcode)?
Create the custom control in a class library project. Then you can reference that project or dll in any project that wants to use it.
As long as you've included the proper Register and Export attributes, Interface Builder should be able to use it. It shouldn't matter that it's in a referenced dll instead of a source file in your project.
I don't know what's the problem. This feature seems to be broken on my system. Could you maybe send me a very simple working example, so I can test if I have installation problems, or there is something else.
I've attached my very simple not working project.
I thought you were creating a custom control. That project only contains a "custom" view controller.
At any rate, what do you mean by "broken on your system"? What isn't working?
I'm not running a current version of Xamarin, so I can't very easily provide you with a working project.
I was able to get your example working with two changes: