I have met a strange problem with the localized strings. I have only a 'Localizable.strings' in my 'en.lproj' folder and it works fine. all the strings are shown on device. but the next time i compile it and run, it shows only the ID of the strings. even if i change nothing and only click on build&debug. and the next time it works fine again and next time again shown with IDs.
so does anyone knows why this is happening? it's kind of annoying that i always need to build twice.
My SOLUTION is at bottom:
I've been running into the same problem: Alternating runs yield correct, then incorrect translations (only for English though).
Adding "-NSShowNonLocalizedStrings YES" as an argument to the app yielded:
Localizable string "MyKey" not found in strings table "Localizable" of bundle CFBundle
So, I tried loading the key file directly from the bundle as a string and dumping it. Well, the times it did NOT work correctly, it was displaying a bunch of built-in iOS messages. So, I went to the APP file that was built, opened the package contents, and viewed the en.lproj/Localizable.strings file...and voila!!! The file had been filled with Apple iOS key/value pairs. On the next build, it was filled as expected.
Of course, this has nothing to do with the encoding of the files (which should be UTF-16). I have not been able to locate anything with mention of this specific problem.
MY SOLUTION:
I copied the contents of the legitimate english Localizable.strings file FROM THE APP PACKAGE (not from my source) into an XML file (when compiled, the .strings file are converted into XML) and added to my project. I then loaded this file into a dictionary at startup, and if the call to NSLocalizedString returned the key instead of the value, I did a lookup on the dictionary I loaded. In theory, you could do this for all languages, but I was only having the problem with english.
Yes, it's not the answer to the problem, but it's a workaround.
Check if you have more than one Localizable.strings in your project. Merging them into one solved it for me. (Check any external code you use e.g. ShareKit)
Related
I am trying to add an info string and description for NSPhotoLibraryUsageDescription as the error describes below. However, I have never used Xcode before, and apparently how I adding the key and value are incorrect. The key is setting to default item 1 so I have to put NSPhotoLibraryUsageDescription in the value. so obviously its not working. What is the workaround in this case?
ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSPhotoLibraryUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data.
Same issue today for me.
It's not the first time that Apple send us that issue after uploading build.
It looks like their automated checks fails sometimes.
Last time we've waited few hours and submitted again a new build (same source code) and it worked.
[EDIT]
Following https://developer.apple.com/forums/thread/680170 it seems that Apple changed their checking rules. We have InfoPlist.strings file in our Watch extension and builds were processed in the past. Now it requires missing keys to be in the Info.plist alongside any localisation file to complete processing builds.
I am adding localization support in my project where I have added Localizable.strings file, and adding key value pair as below:
"not_found" = "device not found";
I am then adding a label to my viewcontroller file as below:
self.notificationTextLabel.text = [NSString stringWithFormat:NSLocalizedString(#"not_found", nil)];
When I run the app label shows not_found instead of "device not found". I have followed tutorials and still not able to figure out why the key is printed. What I could be doing wrong?
Here's what my Project navigator shows:
each contains single line as shown above. French version has translated string.
Also the storyboard also has localizations enabled and has .strings files:
Update:
There is a similar question with not very helpful answers.
Localization issue Xcode
This happens if the localization isn't found.
One problem is that if the compiler finds any problem in a localizable.strings file, that entry and all following entries are silently ignored. So look what's in the file, and see if other entries earlier in the file work.
BTW. [NSString stringWithFormat... ] expects a format string. What you are doing will get you into all kinds of trouble if you ever use a translation that contains a percent character. Just write
self.notificationTextLabel.text = NSLocalizedString(#"not_found", nil);
Found the solution! It was something unexpected. I had created a localizable.strings file earlier and It was conflicting with the newly created file. I deleted all new files and kept only Original file. Works like a charm now!
Something is really broken with my project or Xcode and I'm struggling since two days to figure out what is going on.
My application is running perfectly fine, it is an OS X application and it contains a Today Widget extension. I finalized the project recently and now I'm unable to publish the app due to validation errors.
It started with the validator complaining about my Application Group, which I use to share content between the main application and the Widget extension. The group was defined as $(TeamIdentifierPrefix)com.acme.GreatApp.
The validator was complaining that my Group name was in the wrong format and should rather start with my TEAMID. After 3 hours of running in circles I replaced the placeholder $(TeamIdentifierPrefix) with my team ID (e.g. S3F45A5S35.) – and that worked.
Then the validator complained about every kind of other placeholder in my info.plist and entitlements files, things like $(PRODUCT_NAME), com.acme.GreatApp.$(PRODUCT_NAME:rfc1034identifier) and $(EXECUTABLE_NAME). I replaced all those placeholders with their corresponding values, which then was accepted.
Then, for a while the validator complained about structural issues, which do not make too much sense to me:
iTunes Store operation failed.
Bad CFBundleExecutable. Cannot find executable file that matches the value of CFBundleExecutable in the nested bundle GreatAppWidget [com.acme.GreatApp.pkg/Payload/GreatApp.app/Contents] property list file
iTunes Store operation failed.
Bad bundle identifier. The bundle identifier 'com.acme.GreatApp.GreatAppWidget' of the application extension GreatApp.app/Contents/Plugins/GreatAppWidget.appex should extend the dotted path of the bundle identifier of its containing application (com.acme.GreatApp.GreatAppWidget)
Are you telling me my extension is contained in my extension?
iTunes Store operation failed.
Invalid bundle location. Bundle GreatApp.app/Contents/Plugins/GreatAppWidget.appex must be contained in parent bundle's Contents/Plugins directory.
Well, the error states that I should do what it claims is not correct. Obviously it IS in the parent apps folder Contents/Plugins. So what?
iTunes Store operation failed.
The CFBundleExecutable of two bundles may not point to the same file. The following shared bundle path have been found: GreatApp.app/Contents.
The thing is, my app and extension work perfectly fine. If there was anything broken like dependencies, paths or whatever, something most likely wouldn't work, no?
Furthermore, I did not modify any of the build settings or just anything which I do not understand. These are all the default settings. I created a new Cocoa application, added a new Today Widget Extension as target - and that is it. I did not mess around with any paths, locations, dependencies, anything.
Anyway, those errors were only visible for a while and I'm lucky I made a screenshot then. Because now, again it is showing raw placeholders in the error messages, even though I didn't change a thing that could cause that. The only thing I can recall I did was to delete/revoke all provisioning profiles and certificates locally on disk, in the Keychain, and in the Member Center and created everything from scratch through Xcode.
Now the errors look like this:
iTunes Store operation failed.
Bad CFBundleExecutable. Cannot find executable file that matches the value of CFBundleExecutable in the nested bundle ${bundleName} [${bundlePath}] property list file
iTunes Store operation failed.
Bad bundle identifier. The bundle identifier '${bundleIdentifier}' of the application extension ${bundlePath} should extend the dotted path of the bundle identifier of its containing application (${parentBundleIdentifier})
iTunes Store operation failed.
Invalid bundle location. Bundle ${bundlePath} must be contained in parent bundle's ${pluginsSubPath} directory.
iTunes Store operation failed.
The CFBundleExecutable of two bundles may not point to the same file. The following shared bundle path have been found: ${sharedBundlePath}.
So I thought maybe Apple just fuped it in the recent update and you just can't validate an app with extension. So I searched the web and found the really nice example Today-Scripts. I added app groups ($(TeamIdentifierPrefix)com.acme.Today-Scripts, the placeholder here perfectly works) to all targets, activated sandboxing, changed certs and provisioning profiles: And it perfectly validates!
So I compared all the build setting etc. And except that I had to replace the placeholders with their actual values, obviously the certs and profiles and the fact that in Today-Scripts there is an additional XPC target which is embedded into the Widget, they are atomically the same. Every single setting is the same.
I cleared all caches, really hard. Cleaned the project, cleared ~/Library/Developer/Xcode/DerivedData as well as ~/Library/Caches/com.apple.dt.Xcode, restarted several times, nothing helps.
I'm really desperate as I have no idea left what I can do. Please someone shed some light on what the heck Xcode is doing here and why.
What causes Xcode to fail to interpret all the placeholders in the info.plist and entitlements files?
How can these bundle errors above happen when I am working with
the exact settings XCode created by creating new cocoa app and adding an extension target?
the exact same settings/dependencies as the Today-Scripts example?
I finally found the culprit! The problem was, for some reason I can not explain, the info.plist of the extension was a member (Target Membership) of the main application. I just found that by analyzing the created archive file by file and found an additional info.plist inside the GreatApp.app/Contents/Resources folder. In that file the placeholders were not resolved. The archive validator then used this info.plist for validation.
That little checkbox cost me 3 days.
I was getting
"iTunes Store operation failed. Bad CFBundleExecutable. Cannot find executable file that matches the value of CFBundleExecutable in the nested bundle ${bundleName} [${bundlePath}] property list file"
error when I try to submit my adobe air app to mac app store.
The executable is located at "/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/AdobeCP15.plugin/Contents/MacOS/AdobeCP"
In info.plist file located at "/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/AdobeCP15.plugin/Contents/info.plist"
it is written as
CFBundleExecutable
adobecp
These files are generated automatically but it took time to discover the case-sensitivity. Therefore, I changed it into
CFBundleExecutable
AdobeCP
and error message disappeared.
I ended up at this post because I had a similar error, but a different cause. My issue was caused by having a WatchKit app and having the 'Embed Watch Content' Build Phase after my 'Run Script' Phase. Once I moved the 'Embed Watch Content' Build Phase in between 'Copy Bundle Resources' and 'Embed Frameworks', the validation of the WatchKit succeeded.
Users of my application keep running into issues related to other applications declaring a different UTI for the same file extension as my application. I think I can best describe this with an example:
My application supports importing and exporting OPML files. For this to work I import the org.opm.opml UTI in my info.plist. This mostly works fine, but fails if an other application declares a different UTI for the opml file extension. For example com.redlex.opml or com.xwavesoft.cloudoutliner.opml.
Is there something I can do to work around this problem? Can I somehow tell launch services that my application accepts all files with an .opml extension?
I solved this issue with the following work around:
I removed the entire LSItemContentTypes entry from the list of CFBundleDocumentTypes
In my NSDocument subclass I use NSString's rangeOfString:: method to look for the #"opml" keyword in the typeName parameter.
This work around was confirmed by a user.
Cloud Outliner updated on the MAS today, and looking at the UTI for .opml files now, the com.xwavesoft.cloudoutliner.opml is now gone and com.redlex.opml is now in its place. Which would be uninteresting, except for the fact that OPML files now open in MindNode without a problem.
I can't find any release notes for Cloud Outliner other than "various fixes and improvements." but it would seem that something changed for the better. So: in my case - the simple answer was "update Cloud Outliner" but I'm not sure this solves the larger problem. I also have Mellel on my system (obviously, right?!) but this doesn't seem to be causing the same issue.
For those watching this thread - the issue presented as MindNode showing greyed-out icons for OPML files in its open dialog. Dragging OPML to the MindNode icon in the dock also produced no results.
Rob
I've read all the tickets about this issue, but I still don't get it right. I have a non-document OSX app (for OSX Lion and MountainLion). I want this app to export and import custom data, associated with a custom file extension ".iobs". Internally, these files are just data archived with [NSKeyedArchiver archivedDataWithRootObject:], and saved onto the disk with the "iobs" extension.
So, my check list is this:
1) Export mechanism: checked. My app create correctly .iobs files. If I run "file <filename.iobs>" in the Terminal, I get "iObserve_exportedItems.iobs: Apple binary property list"
2) Declaration of an exported UTI, checked. As shown in the image below. I did NOT declared a custom Document type, since it I never use NSDocument inside my app, and there is no point. Anyway, I already tried and failed. I've tried also different combinations of "Conforms To" entries, but with no success.
3) Is there any 3rd point??? Do I need to start my app once to let the system know? I just ran it in Debug from Xcode so far, and this has no effect. So I guess my Info.plist is wrong, but I filled it from within Xcode4 interface, so???
Thanks for any help, hint, question, suggestion.
Ok, so apparently, I do have to declare a document type even if I don't specify a document class. See the attached screenshot. Note that leaving only the Document UTI doesn't work. I do need the two (exported UTI and document type). Note also that if I say it conforms to com.apple.binary-property-list, I don't have the right icon.
And for those who wonder, there is nothing to do to "register" a type (and its subsequent changes) apart from launching the app once.