Forum Xamarin Xamarin.iOS

Localization Issue on Xamarin.Mac with Multiple Storyboards

AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

I have a simple Cocoa project with a Main.storyboard, a Level1.storyboard under a Level1 folder, and a Level2.storyboard in a Level2 subfolder of the Level1 folder. If I Localize those storyboards via Xcode, it creates a structure as shown here.

However, it appears that Xamarin.Mac apps do not support this kind of structured setup of localization files, i.e. it does not pick up the localized strings in those subfolders. Apparently, Xamarin.mac expects all the localized storyboards and all .strings files for them to all exist together in a single set of .lproj folders under "Resources"

In my attached project, I've copied the Level1 storyboard and .strings files up, but not the Level2 ones. please build, run, and observe.

Please confirm if this is a Xamarin.Mac issue.



  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai
    edited March 2017

    So this project builds with 3.0 in Stable but not 3.2 in alpha:

    /Users/donblas/Downloads/Storyboards_test/Resources/Base.lproj/Level1.storyboard: Error: The file 'Resources/Base.lproj/Level1.storyboard' conflicts with 'Resources/Level1/Base.lproj/Level1.storyboard'. (Storyboards_test)

    Now I believe we support only flat in Resources because that is what Cocoa/objective-c does in Xcode.

    If you have an example showing that something like this works there, I'd consider it possibly a bug.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    Hey Chris - the error you're seeing is because I copied the Level1.storyboard up to show that the Level1 localized strings would work there. To start fresh, I've attached the barebones project just after localizing the 3 storyboards. As you can see, Xcode does not localize the resources in a "flat" way. And as it is, you still won't see the localized strings anywhere because of the previous localization issue I reported via bugzilla where it was determined that the storyboard at the root of the project needs to be removed. So it you just remove the Main.storyboard from the root of the project you should see the EN (and IT if you set the language in the OS) versions of the string appear on the Main view. But ONLY the Main view. So the issue here is how to get the Level1 and Level2 localized strings to show up as well. As is, they don't. But as a test, and as I attempted to demonstrate via my initial test project, Xamarin.Mac appears to only support a "flat" set of localized resources, which you also believe is the case.

    I suspect that this project will also build in 3.2 alpha as I have not copied any storyboard files anywhere.

    Here's my environment info.

    === Xamarin Studio Enterprise ===

    Version 6.2 (build 1821)
    Installation UUID: 6679460b-ef93-4286-bfaa-e1c265c1cd08
    Mono 4.8.0 (mono-4.8.0-branch/e4a3cf3) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 408000495

    === NuGet ===


    === Xamarin.Profiler ===

    Version: 1.2.0
    Location: /Applications/Xamarin Profiler

    === Apple Developer Tools ===

    Xcode 8.2.1 (11766.1)
    Build 8C1002

    === Xamarin.Mac ===

    Version: (Visual Studio Enterprise)

    === Xamarin.Android ===

    Version: (Visual Studio Enterprise)
    Android SDK: /Users/hpadmin/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
    6.0 (API level 23)

    SDK Tools Version: 25.2.3
    SDK Platform Tools Version: 25.0.1
    SDK Build Tools Version: 25.0.1

    Java SDK: /usr
    java version "1.8.0_101"
    Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

    Android Designer EPL code available here:

    === Xamarin Android Player ===

    Not Installed

    === Xamarin.iOS ===

    Version: (Visual Studio Enterprise)
    Hash: 35d1ccd
    Branch: cycle9
    Build date: 2017-02-16 17:40:00-0500

    === Xamarin Inspector ===

    Hash: cdc01b9
    Branch: 1.1-release
    Build date: Wed, 22 Feb 2017 23:24:11 GMT

    === Build Information ===

    Release ID: 602001821
    Git revision: d41b6e51f3fa46a1943f2e31a778d28a7c73d069
    Build date: 2017-02-17 15:18:19-05
    Xamarin addins: 1363a8d943bab7700c93a97474060b6734aa7f94
    Build lane: monodevelop-lion-cycle9

    === Operating System ===

    Mac OS X 10.12.3
    Darwin hpadmins-Mac-mini.local 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    So, I think you missed what I was asking.

    Much of Xamarin.Mac's macOS functionality is based upon exposing functionality from Xcode / clang / ibtool (Apple's tools) in a C# world.

    Thus, if you could make a Xcode project, with multiple different "physical" folder levels localize in the way you expect, and have that work, it'd clearly be a Xamarin.Mac bug. If you can't, then we're just exposing a limitation of the underlying tool. When you use Apple's localization tools, you get to play by their rules / limitations.

    I created this project:

    and created a similar project structure, with multiple nested folders:

    and on disk I get:

    which appears to be flat.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    I see, Chris. So in a pure XCode project, the "Localize..." button in IB localizes to a set of flat folders. But in a Xamarin.Mac app, the "Localize..." button in IB localizes to a hierarchical set of folders which appears to be wrong. So where's the disconnect and which component is responsible for it?


  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    It sounds to me like Xcode is creating "logical" folders for the levels, which don't translate to physical folders on disk. Xamarin is taking those logical folders and creating physical folders, which causes things to break. Just my theory based on what has been posted.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    Logical. But what's the bottom-line for us Xamarin.Mac developers?

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    @DaveHunt pretty much nailed it down.

    • XS by default creates physical folders when you create then in the IDE
    • Xcode creates logical folders but uses a flat file structure
    • It appears the localization tooling expects a flat file structure

    Thus, if you want to use the built in localization tooling, you need to have a flat file structure.

    If you really want folders though, there is a "work around" I can think of.

    • Add/move files in the root of your project.
    • Select them and "Remove from project" not delete.
    • Create folders to match your desired structure
    • Right click then, add files, browse, add as link.

    That should give you a flat file structure and logical project tree.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    All I really want to do is structure the projects in my solution hierarchically (multiple storyboards at different levels), "Localize..." each storyboard, and have it work. Preferably with no additional manual steps.


  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    There's still a disconnect somewhere between pure Xcode and Xamarin.Mac that is preventing Xamarin.Mac to just work off-the-shelf, right? Isn't that a ball that should be in somebody's court?

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Then adding the file to the root and doing my manual "add as virtual somewhere else" is likely your best bet.

    If there is a bug, it would be that creating logical folders in Xamarin Studio is too difficult.

    Feel free to file one here:

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    Too difficult for who, Xamarin Studio itself?

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    I was noting that if you believe the work around was too difficult, you were welcome to file a bug (which you did).

    I've forwarded it on to the correct team, but the request of changing (or adding) a new folder type to be virtual like Xcode is large and if completed may not be in a timetable that works for you.

    I would strongly suggest fixing your projects for now by moving the storyboards to root and using project links as I described.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    So it turns out that this is a instance of a number of items that are only processed when in the top level root of a project.

    The following stack overflow post applies, which the one change of IPhoneResourcePrefix to MonoMacResourcePrefix

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    Thanks Chris. I was not trying to say implementing the work-around is too difficult for me. I was just reiterating the point that I don't believe it's a good developer experience to have to do this manually every time, especially when it's not required in a pure Xcode project. I also think that in the interest of Microsoft/Xamarin, fixing it in XS would help make it a better product.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai
    edited March 2017

    I totally agree it is not the best user experience. Unfortunately when interacting with the limitations placed on us by needing to format things as Apple's tooling expect, while keeping expected .NET behavior things can get complicated (VS/XS use physical folders while Xcode uses logical, etc).

    I think adding LogicalName's (as noted here is likely your best bet, and shouldn't be too hard (though it is another manual step).

    We could have XS by default set them for storyboards / xib / strings files created in subfolders but I am unsure of the repercussions of doing that "magically".

Sign In or Register to comment.