iOS - genstrings: couldn't connect to output directory en.lproj - ios

I searched for this error online and here. Online it shows me results in a different language then english nice Google. Here it has one post and a guy that never really answered the guys question.
I have my xcode project folder on my desktop. Inside the project folder I have an en.lproj folder that has both iPad and iPhone storyboards inside along with a localization.plist file. However when I launch the project in Xcode this en.lproj folder is nowhere to be found. So this might be the problem?
With the project folder on my desktop I launch terminal type in: cd
then drag my project folder into Terminal and it gives me the path. I then paste this line of code into the Terminal
find . -name *.m | xargs genstrings -o en.lproj
I get this error message in the Terminal:
genstrings: couldn't connect to output directory en.lproj
it prints this line multiple times and then says my project is a path to a directory?
No .strings file is made. Any thoughts on what I am doing wrong? I got UILabels that I dragged and dropped from inside Storyboards, but I also I strings that are coded with
NSLocalizedString(#"First Level Passed", #"This is a message displayed on screen to allow the user to know they have passed the first level!");
So the above Terminal code snippet should be finding those NSLocalizedStrings right? I think it isn't even getting to find the en.lproj folder in the first place but I don't know?
Any help would be great.

Better late then never,
you are creating a file (localizable.strings) in the folder projectroot/en.lproj.
If this folder doesn't exist you get this error message. Simply create the folder en.lproj in the root and the command should work.

I got the same error, while execute the following command as per the tutorials.
genstrings -o en.lproj *.swift
Above command gives me following error:
genstrings: couldn't connect to output directory en.lproj
My issue:
I try to implement above command on my own directory(i.e. subdirectory of root project directory) where all the ".lproj" directory is there. - that gives me above error.
Then i have removed old “Localizable.strings” on sub-folder "Localization". and created new “Localizable.strings” in root directory. - here i got no errors but nothing is happen as per "genstrings" command.
Solution:
On command line move to the Root directory of project where you can get the all the ".lproj" directories.
Add the path of file, where you listed all the "NSLocalizedString("TEXT", comment: "COMMENT")" - in my case i have listed everything on "Constants.swift" file.
So, i have execute the following command and its work like charm.
genstrings -o en.lproj/ #ProjectPath#/Constants/Constants.swift
Note:
File path will be easily get via just drag file from the Xcode and drop to the terminal.

Solution is to manually create the folder en.lproj, then run genstring command
cd {project folder}
mkdir Localization
cd Localization
mkdir en.lproj
genstrings -o en.lproj/ ../*.swift
repeat for every language (ie: fr.lproj ) for French etc..

Related

Swiftkotlin command line not found for converting Swift to kotlin

I am using Swift kotlin for converting swift code to kotlin which is working on Xcode project but when I am trying to execute from mac terminal it shows SwiftKotlin not found .
Github link: https://github.com/angelolloqui/SwiftKotlin
-bash: swiftkotlin: command not found
Vivek-Mac-mini:~ vivekrawat$
It looks like you need to install the package into
/usr/local/bin/
folder on your Mac, so the terminal can treat it like other command-line commands like cd, open, etc.
From Xcode, run the desired target and copy the generated executables (you can find it under the Products generated folder) in a directory with executable rights for later use. Typically, you could use:
swiftkotlin command line tool: /usr/local/bin/
To do so, you can try the following:
in the left pane of Xcode find the last folder called Products, open it. There should be a file with .app extension.
try to drag the file with .app extension from XCode to your desktop, holding alt key on the keyboard.
open Finder, click Shift+Cmd+G and paste /usr/local/bin/ into the prompt
drag the file from your desktop to that folder
restart the Terminal and try to use the command again

Universal Linking Validator (Branch) issue

So I am trying to use the Universal Linking Validator on Branch's website. I downloaded the script and opened the terminal and entered:
$ bash ulv_script.sh
Then I dragged and drop the project’s .xcodeproj file into the terminal window the result was:
ulv_script.sh: No such file or directory
How am I suppose to get the link I need?
Here are the directions I am following:
https://dev.branch.io/getting-started/universal-linking-validator/guide/
Jonas from Branch here.
The error you are seeing is because your terminal is in a different directory then the script. You can get around this by using the cd command to navigate to the location of the script.
Alternatively, you can enter bash into the terminal, drag and drop the downloaded script into the terminal window, and then drag and drop your .xcodeproj file into the window. Using this method, you should end up with a command that looks like bash /Users/jbauer/Downloads/ulv_script.sh /Users/jbauer/Desktop/BranchStuff/Branch-TestBed-Swift/TestBed-Swift.xcodeproj Note the space between the path to the script, and the path to the Xcode project.
Feel free to ping me if you run into any other issues, and I'd be happy to lend a hand.

Xcode 6 Cannot Find .pch File, Although it Exists

I am getting the error clang: error: no such file or directory: '/path/to/my/project/MyProject/Supporting\ Files/MyProject-Prefix.pch' from Xcode 6.3.1 when I try to build my application.
However, this file clearly exists, since when I type (or even copy & paste the path from the error message) $ cat /path/to/my/project/MyProject/Supporting\ Files/MyProject-Prefix.pch into the terminal the contents of the file are printed to Stdout. The file is also linked to my Xcode, and is visible in the document outline.
Does anyone know why Xcode is not finding this file that obviously exists?
My guess would be in the project build settings you have "Supporting\ Files" with the backslash escaping the space in the value for "Prefix Header". The backslash should be removed.
I tried this on a test project both with and without the backslash and when editing the filename in Xcode UI the compile only worked without the backslash.
When the compile worked the pbxproj file had this value:
GCC_PREFIX_HEADER = "foobar/Supporting Files/test.pch";
and the "Prefix Header" on the Xcode Build Settings showed:
foobar/Supporting Files/test.pch
The backslash is needed when typing the path in terminal to escape the space.
You should set the short path for Prefix Header in the project settings like the following:
"MyProject/Supporting Files/MyProject-Prefix.pch"
Also it is uncommon to have folder named Supporting Files in your project folder and that file supposed to be right under the root

How to use terminal for working with xCode Command Line Tools?

Context: I have installed the Command Line Tools separately as the conventional method of
"xCode->Preferences->Downloads->Components->Command Line Tools->Install" didn't work for me.
Purpose: I need to implement internationalization/localization on my application and want to use genstrings for creating the Localizable.Strings files.
Problem: When I try to use the Terminal and type command like
$ find . -name *.m | xargs genstrings -o en.lproj
I Get:
couldn't connect to output directory en.lproj
How should I specify the path for directory? Also, I might need to specify the path for some *.m files as well.
Note: I was suggested to read the genstrings manual but I am not sure how to work with a particular xCode project while using the Terminal.
Two things need to be taken care of:
1) After entering the Terminal, first go to the folder in which the targeted .m files are present. Use:
cd "path"
2) While using the genstrings code, specify the complete path of the output directory. e.g.:
genstrings -o /Users/kushalashok/Desktop/ProjectnName/en.lproj *.m
After running the code, a new file named "Localizable.strings" will be created in the specified output folder.

How can I get my project's folder structure to be mirrored in Finder?

I have an Xcode (4.2) project with a bunch of class files, and I have them neatly organized into folders. These folder aren't "real", however; in Finder, my classes are all just dumped into the one "Classes" folder. Is there any way to get the virtual folder structure I see in Xcode to be reflected in the real Finder folder structure? Or do I have to do this manually?
https://github.com/venmo/synx
A command-line tool that reorganizes your Xcode project folder to match your Xcode groups
Installation
$ gem install synx
Usage
Basic
:warning: WARNING: Make sure that your project is backed up through source control before doing anything :warning:
Execute the command on your project to have it reorganize the files on the file system:
$ synx path/to/my/project.xcodeproj
It may have confused CocoaPods. If you use them, execute this command:
$ pod install
You're good to go!
Advanced
Synx supports the following options:
--prune, -p remove source files and image resources that are not referenced by the the Xcode project
--no-color removes all color from the output
--no-default-exclusions doesn't use the default exclusions of /Libraries, /Frameworks, and /Products
--quiet, -q silence all output
--exclusion, -e EXCLUSION ignore an Xcode group while syncing
For example, OCMock could have been organized using this command:
$ synx -p -e "/OCMock/Core Mocks" -e /OCMockTests Source/OCMock.xcodeproj/
if they had wanted not to sync the /OCMock/Core Mocks and /OCMockTests groups, and also remove (-p) any image/source files found by synx that weren't referenced by any groups in Xcode.
I often want to do the same thing, but as far as I know there is no automatic way to do it, you have to do it manually unfortunately...
There is no 'automatic' way to make the XCode file pane structure automagically conform to the finder folder structure, although I agree there should be a setting for this.
I follow these steps when making a project:
Create the project.
Delete by reference any files I want to move.
Open finder and move the files, then drag them back into XCode.
When adding new files:
Create a folder in finder if needed.
Drag the folder into XCode.
Right-click and make a new file on the group that represents the folder just dragged in.
If you're using git, it's a little more work:
Commit your project before making a folder or file deletions/moves.
Delete them by reference from XCode.
Move them in finder.
Using terminal, type git mv sourcePath destPath to move files or git rm sourcePath to delete them.
Then drag back into XCode.
You can see more about my frustration with learning git here:
How can I move files & folders using git in Xcode 4?

Resources