Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class libraries for MonoTouch projects, getting "not built using active configuration", how to fix?

I am trying to build up a set of class libraries to share code between applications that we're going to make.

However, I am unable to create the projects correctly and I can't see what I'm doing wrong.

Let me go through the steps I use to reproduce this, maybe someone here can see what I'm doing wrong:

  1. In a fresh MonoDevelop instance, I go to File->New Solution
  2. I pick the MonoTouch Library Project template, and give it an appropriate name
  3. I then add a new application project to the solution (to simulate using the library in an app), of type "iPhone Single View Application"
  4. I make the application project the startup project
  5. I add a reference to the library project in the application project
  6. I then build

This works, and if I pick the Run->Debug menu item, I can see the application opening up in the simulator.

Let's assume I want to test it on the iPhone now, so I visit the dropdown in the toolbar, pick "Debug|iPhone" build target, and immediately the class library project is grayed out with:

(not built in active configuration)

If I right-click the solution, check the Configuration mappings, when picking anything related to the simulator or the iPhone, the class library disappears from view altogether and is unable to select for build.

The build target dropdown also has 6 items now, Debug, Release, Debug/release for iPhone and Debug/release for the simulator. Apparently only the Debug and Release that is not for either iPhone or the simulator ends up building the class library.

What am I doing wrong here?

In a different project where I did not have the luxury of being able to look around for a solution, I ended up creating an empty universal project, is that the "correct" way to mitigate this?

like image 433
Lasse V. Karlsen Avatar asked Feb 16 '12 13:02

Lasse V. Karlsen


1 Answers

Interestingly, this doesn't happen if you add the Lib project after the App project.

I created the Lib project as you described, then added a Single-View iPhone App, then added another Lib (Lib2). I then compared the text in the .sln and found that Lib was missing the following lines (compared to Lib2):

{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Debug|iPhone.Build.0 = Debug|Any CPU
{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU

{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Release|iPhone.ActiveCfg = Release|Any CPU
{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Release|iPhone.Build.0 = Release|Any CPU
{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU

Use your own GUID instead of mine. The GUID will be near the top of the file. For example, mine looks like (scroll to the end):

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib", "Lib.csproj", "{A9A8640A-C650-46AB-A21C-DF3B5D22BAA3}"

I then re-opened the solution and Lib is now available in both the Debug|iPhone and Debug|iPhoneSimulator configurations.


As a side note, even though the Lib wouldn't build in Debug|iPhone or Debug|iPhoneSimulator, the binary from Debug was compatible. I could build and run the App just fine.

like image 123
cod3monk3y Avatar answered Oct 22 '22 03:10

cod3monk3y