6

In iOS, you can add frameworks when you go to "Your Project" =>"Targets" => "Build Phases" and then press the add button to add frameworks.

So, lets say I wanted to add CoreVideo framework, CoreMedia framework, and CoreGraphics.framework. How can I add these frameworks to my Xamarin iOS project?

I am new to Xamarin iOS. thanks for reading, I appreciate any comments or suggestions.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
xiaowoo
  • 2,248
  • 7
  • 34
  • 45

1 Answers1

9

In most cases this is done automagically for you.

E.g. when you use a type from MonoTouch.CoreGraphics, like CGColor, then the tooling will add a reference to the CoreGraphics framework. No further action is required from you.

The only time when you need to manually specify frameworks is when you link with a native library that has dependencies on some framework(s) that your application itself might now have.

In general, when you create bindings to an Objective-C library, you add such requirements inside the [LinkWith] attribute. E.g.

[assembly: LinkWith ("libX.a", LinkTarget.Simulator, Frameworks="CoreGraphics")]

You can add several frameworks by separating them with a space.

You can also use the Additional mtouch arguments (from your Project Options) to specify options to the native linker if you do not use a binding project, e.g.

-gcc_flags="-framework CoreGraphics"
poupou
  • 43,413
  • 6
  • 77
  • 174
  • I have one more question. If my project depends on a xyz.framework(a third party library) and this xyz.framework needs CoreGraphics.framework to run, How can I link this xyz.framework into my Xamarin project. According to the documentation, I think it saids I need to generate some sort of xyz.a file from the xyz.framework. And then link it. I am a little confused here, what exactly is this xyz.a file? Why do I need to link the xyz.a file instead of the xyz.framework file. thanks again. – xiaowoo Jul 05 '13 at 22:53
  • 1
    the `.a` file is the static library that will be linked with your application (because 3rd parties dynamic libraries are not allowed in iOS). The framework will contains it. Look at this answer http://stackoverflow.com/q/10586342/220643 and the links from it to learn more about binding frameworks. – poupou Jul 06 '13 at 14:44