locked
Migrating from Classic to Unified API breaks my project RRS feed

  • Question

  • User99879 posted

    My company (MnetMobile) recently migrated an iOS app developed using Xamarin from Classic to Unified API using command “Migrate to Xamarin.iOS Unified API” in project menu. After migrating, we found the app no longer runs on both device and simulator. The app failed to start with the following error message in the console of Xamarin Studio (mac)

    Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Could not find a storyboard named 'MainStoryboard_iPad' in bundle NSBundle (loaded)

    We've checked the project files and we were sure the storyboards the app tried to load were there and were set correctly in the project configuration. We tried to create a new storyboard and start the app from it, but failed with the same error message.

    We were stuck by this problem and wish Xamarin could help us find this problem.

    Regards, Leilei Wu MnetMobile

    Wednesday, January 14, 2015 3:37 AM

Answers

  • User8955 posted

    This seems to be related to this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=25569

    To solve this you need to locate the following build target file:

    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/2.1/Xamarin.iOS.Common.targets

    In this file you need to find the following target declaration:

    <Target Name="_CopyContentToBundle"
            Inputs = "@(_BundleResourceWithLogicalName)"
            Outputs = "@(_BundleResourceWithLogicalName -> '$(_AppBundlePath)%(LogicalName)')" >
    

    And add the DependsOnTargets="_CollectBundleResources" attribute to it. Like this:

    <Target Name="_CopyContentToBundle"
            DependsOnTargets="_CollectBundleResources"
            Inputs = "@(_BundleResourceWithLogicalName)"
            Outputs = "@(_BundleResourceWithLogicalName -> '$(_AppBundlePath)%(LogicalName)')" >
    

    Save the file and reboot of Xamarin Studio (and maybe a clean+rebuild of your project).

    This is planned to be fixed in a future release of Xamarin.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, January 14, 2015 2:14 PM

All replies

  • User8955 posted

    This seems to be related to this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=25569

    To solve this you need to locate the following build target file:

    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/2.1/Xamarin.iOS.Common.targets

    In this file you need to find the following target declaration:

    <Target Name="_CopyContentToBundle"
            Inputs = "@(_BundleResourceWithLogicalName)"
            Outputs = "@(_BundleResourceWithLogicalName -> '$(_AppBundlePath)%(LogicalName)')" >
    

    And add the DependsOnTargets="_CollectBundleResources" attribute to it. Like this:

    <Target Name="_CopyContentToBundle"
            DependsOnTargets="_CollectBundleResources"
            Inputs = "@(_BundleResourceWithLogicalName)"
            Outputs = "@(_BundleResourceWithLogicalName -> '$(_AppBundlePath)%(LogicalName)')" >
    

    Save the file and reboot of Xamarin Studio (and maybe a clean+rebuild of your project).

    This is planned to be fixed in a future release of Xamarin.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, January 14, 2015 2:14 PM
  • User25625 posted

    I've just encountered this as well. Unfortunately using your solution doesn't make any difference and I still receive this error.

    Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Could not find a storyboard named 'MainStoryboard' in bundle NSBundle (loaded) at ObjCRuntime.Runtime.ThrowNSException (IntPtr nsexception) [0x00000] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:156 at ObjCRuntime.Runtime.thrownsexception (IntPtr exc) [0x00000] in /Developer/MonoTouch/Source/maccore/runtime/Delegates.generated.cs:100 at at (wrapper native-to-managed) ObjCRuntime.Runtime:throwns_exception (intptr) at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46 at Pinpoint.iPhone.Application.Main (System.String[] args) [0x00008] in /Users/james/Documents/GitHub/Game/iOS/Pinpoint.iPhone/Pinpoint.iPhone/Main.cs:17

    Tuesday, January 20, 2015 3:12 PM
  • User69453 posted

    Solution did work for me. @JamesMundy: folder and file are read-only. If you don't grant write access up front, the file will not be saved with the added property...

    Wednesday, February 4, 2015 12:06 PM
  • User53796 posted

    Yey! Solved my problem Thanks!

    Wednesday, February 4, 2015 2:51 PM
  • User71478 posted

    This solution did not work for me. I continue to receive the "Could not find a storyboard" error. I have also checked to make sure the Build Action is InterfaceDefinition on my Storyboard.

    Any other ideas? This certainly needs to be fixed within my application. Crashes on start-up every time.

    Thursday, February 5, 2015 9:37 PM
  • User99879 posted

    It works for me.

    But you may find you don't have permission to write to /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/2.1/Xamarin.iOS.Common.targets

    My solution for this is:

    1. rename Xamarin.iOS.Common.targets to a different file name
    2. make a copy of this file and name it as Xamarin.iOS.Common.targets.
    3. Change Xamarin.iOS.Common.targets
    4. Restart Xamarin
    Wednesday, February 11, 2015 6:40 AM
  • User121755 posted

    Not work For me!!!!

    I tried different solutions but nothing, I'm stuck with a job

    Friday, April 17, 2015 11:30 AM