I deleted the Localizations in Xcode, then I cannot add any Localizations back

后端 未结 6 1504
陌清茗
陌清茗 2021-01-30 13:54

I deleted the Localizations of the project from the project\'s info by mistake. Both the storyboard and the related language were removed.

I got back the storyboard from

6条回答
  •  既然无缘
    2021-01-30 14:56

    I had to solve same problem, and found one solution:

    You need to find in finder your *.xcodeproj file and open it as container (ctrl+click on it and you will see it in context menu)

    Here you can see project.pbxproj file, open it in Xcode. Its large (but still readable file). (it will be better to make some copy on save spot, before you start)

    Now its the task to add the missing language to this file, and its done.(U can try it on other project with localizations).

    There is paragraph you need to add. Search in this file for this /* End PBXSourcesBuildPhase section */(its paragraph right before localization paragraph which is missing) and add something like this after:

    /* Begin PBXVariantGroup section */
            27548D921611B0BE008EA1CD /* Localizable.strings */ = {
                isa = PBXVariantGroup;
                children = (
                    27548D941611B0BE008EA1CD /* en */,
                );
                name = Localizable.strings;
                path = ../Code;
                sourceTree = "";
            };
    /* End PBXVariantGroup section */
    

    You have to do some changes first. Look at the long number 27548D921611B0BE008EA1CD, its ID of the localization file (or some xib file, or other localizable file...), if you dont have any in the procject, just add some Localizable.string file to the project, reopen(or refresh) this project.pbxpro, and find this Localizable.string you should find something like this:

    275490591611B0BE008EA1CD /* Localizable.strings in Resources */

    and this is it what you need to replace in localization paragraph

    also you need to do right settings on path parametr and sourceTree. This twos are readable in fileinspector in xcode.

    The "sourceTree" param is Location - mostly its relative to group so sourceTree = "";

    The path is path relative from the group to the file (if you dont know, try to make some localization files in different project and look at project.pbxpro, what all this works)

    After this you can save project.pbxpro, and you should see in xcode info section "en" localization and you can add more localizations and all other localization stuff.

提交回复
热议问题