I must to include *.jar files in my Xcode project so I decided to use j2objc to translate them into Objective C. I tried to configure my project with no success so I just downloaded a sample project from here and here. All of them cannot compile becouse of the same error
J2OBJC_HOME not correctly defined in Settings.xcconfig, currently set to '../j2objc-dist'
Command /bin/sh failed with exit code 1
looks like I am using the wrong path, this is my Settings.xcconfig
J2OBJC_HOME = ${HOME}/j2objc;
HEADER_SEARCH_PATHS = "${J2OBJC_HOME}/frameworks/JRE.framework/Headers";
FRAMEWORK_SEARCH_PATHS = "${J2OBJC_HOME}/frameworks";
I tried many different paths but no success
My j2objc folder path at this point is :/Users/username/j2objc
Thanks for any advice
J2ObjC is distributed as a zip file, which you download and unzip into a local directory of your choosing. That local directory plus the release name ("j2objc-" + version) is the J2OBJC_HOME. For example, on my system I have a "/usr/local/tools" directory where I unzipped j2objc-1.3.zip, so my current J2OBJC_HOME is "/usr/local/tools/j2objc-1.3".
In each of the sample projects, J2OBJC_HOME is defined in an xcconfig file. To update the project to work on your system, edit that file and change the J2OBJC_HOME environment variable to wherever it is for your system.
There's nothing special about "J2OBJC_HOME", it's just an environment variable name both sample projects use.
Related
So, I have a shell script which generates two JSON files. The script is run as a 'build Phase' in Xcode. I'm expecting to have programmatic access to these generated files, but in code they cannot be found.
Here is the code which generates the files (I don't specify any paths - the Script is located in the root of my project):
echo $booksJSON >> defaultBooks.json
echo $dateJSON >> defaultBooksDate.json`
I'm then trying to access these files from code like this:
NSString *bookFilePath = [[NSBundle mainBundle] pathForResource:#"defaultBooks" ofType:#"json"];
NSString *dateFilePath = [[NSBundle mainBundle] pathForResource:#"defaultBooksDate" ofType:#"json"];
Obviously, I cannot see these two files listed in the 'Copy Bundle Resources' build phase step, because they are generated at compile-time, so I presume that the files are simply not copied to the .ipa file.
Is there a step I'm missing? How can I tell Xcode to include the JSON files in the 'copy bundle resources' step?
Many thanks
You need to start using the environment variables provided by Xcode. You may as well just write the JSON directly into the output app bundle (unless you have a special reason to generate them as "source" and use Xcode to copy them, that is? If so, see below.).
So I put such scripts into a sub-directory called tools, and if this script was called generate_json.sh then it's absolute path would be $(PROJECT_DIR)/tools/generate_json.sh.
Within this sctipt file you can reference the Xcode output directory (where Xcode is building the app bundle) as $TARGET_BUILD_DIR.
Therefore, something like this:
#!/bin/sh
cat << EOF > "$TARGET_BUILD_DIR/MyApp.app/somefile.json"
your json goes here.
EOF
The alternative to this approach is to generate the .json file into the source tree and add it to Xcode as a proper source file and arrange for it to be copied into the app bundle in the normal manner. This is generally only useful if it's generated from another source file (think yacc and lex source file). If it changes for every build then use the approach I give here. If it never changes then you shouldn't be doing any of this stuff anyway as you can just manually run the script outside of Xcode.
I have a script which converts wav files to caf files, and I'd like to get them copied to my iOS app automatically. The script looks like this:
Xcode doesn't copy it automatically, and i can't find a way to add it to my Copy Build Phase section. It appears that I need to add a line in the script to copy it directly to the app bundle, or to make the destination the app bundle itself.
What would that script/change be? I'm not sure what shell vars to use for the cp command.
Thanks - Henry
The environment variable you're looking for is "BUILT_PRODUCTS_DIR" and you can find the definition of this, and plenty of other useful Xcode-specific environment variables on this handy Apple documentation page.
And what you'd probably want to do is test for the existence of successfully converted files, and if they exist, then copy those files into the "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}" directory.
Xcode includes a flexible build rules system. The documentation is all but non-existant however.
A project I am working on for iOS 5 and iOS 6 includes an rtf help file. For iOS 6, I can convert the rtf file into an archived NSAttributedString object, then load that at runtimeand display it directly to a UITextView. For iOS 5, I can't (without a lot of work in Core Text...) so I want just the text without the style info.
I wrote a command line tool, RTFToData that takes an RTF file as input and generates a .txt file and a .data file (where the .data file contains a version of the styled text that my project knows how to use.)
Here is the syntax of my command line tool:
RTFToData [-o] source_path [destination_path]
-o (optional) overwite existing files
source_path (required) path to source RTF file (must have extension "rtf" or "RTF"
destination_directory (optional.) writes output files to source file directory if no destination specified
destination_directory must exist if specified.
I want to set up my project so that I can add .rtf files as sources (with the "add to target" checkbox NOT checked.) I want Xcode to run my RTFToData command on each file specifying that the output files should be copied into a directory and then added to the target.
Ideally, I'd like the build process to know about the dependencies between my source .rtf files and the processed .data and .txt files. If I touch a .rtf file, I'd like the build process to re-run the rtftodata command.
I am a makefile and unix scripting neophyte. I THINK I can use a run script build rule that will do this, but I am unclear on how. I guess I need to write a script that finds all files of type ".rtf", pipes that list of files into an invocation of my RTFToData.
Can somebody outline the steps I need to take in the Xcode IDE to make my project handle this smoothly?
As a side-note, is there some directory where you can put command line tools so they are available to the current version of Xcode? So far I've been installing the RTFToData command in /Library/usr/bin, but I'd really like the build tool to be included in the project, or at the very least, not have to use sudo to set up every development machine that is used to build this project.
Create a custom build phase
Add the .rtf files to your project and make sure they are added to your target.
Go to your target settings and select the "Build Rules" tab:
Click the "Add Build Rule" button at the bottom.
You want to configure your rule based on something like this:
Enter a standard wildcard glob for the files you want to match (*.rtf).
Inside the script section you can make use of a number of environment variables. Assuming your glob has matched the input file Test.rtf you have access to these vars:
INPUT_FILE_PATH = /path/to/your/project/source/Test.rtf
INPUT_FILE_NAME = Test.rtf
INPUT_FILE_BASE = Test
INPUT_FILE_SUFFIX = .rtf
INPUT_FILE_DIR = /path/to/your/project/source/
You want to process your file and send it to the ${DERIVED_FILES_DIR} directory with whatever new filename or extension you need. In this case we take the base filename from the input and give it a new extension.
Fill out the "Output Files" section with the same output file you used in the script. This will ensure the dependency system works and that the file will be copied to your .app. The script will only be run if the input has changed or the output file is missing from the .app.
Note that the "Output Files" should not have double quotes. The paths will be quoted for you by Xcode.
If your script generates multiple output files, add extra entries for those as well.
Once this is all set up, .rtf files added to your target will be converted to whatever output files your script generates. The original .rtf files will not exist in the final .app.
Where to put scripts/programs
As a side-note, is there some directory where you can put command line
tools so they are available to the current version of Xcode?
Put your tools somewhere below the directory that contains your .xcproject. Then from your build phase/rules use the ${SRCROOT} environment variable, which is the directory containing your project:
Assuming this file system layout:
/path/to/project/project.xcodeproj
/path/to/project/Tools/CommandLineTool
Use this in your build phase/rules:
"${SRCROOT}/Tools/CommandLineTool" "${INPUT_FILE_PATH}" ...
Remember to use double-quotes everywhere you can!
I have a project in directory A and files that I use in all my projects are in directory B.
When I moved a .sty file from A to B, the main .tex file does not compile anymore.
The error is that the .sty file was not found. I am puzzled because:
Directory B is included in the path of the project.
I cleaned (deleted manually) all the auxiliary files used in the previous compilations.
I refreshed the project folders .
Did anyone had similar problems? Suggestions?
The file LaTeX.sublime-build, within the Sublime Text folder . . . /Packages/LaTeXTools, contains a $PATH for different operating systems.
For example, Sublime Text 2 on an OSX operating system, has a file located at ~/Library/Application Support/Sublime Text 2/Packages/LaTeXTools/LaTeX.sublime-build. The relevant line of code for a MacTeX TexLive 2012 installation is "path": "$PATH:/usr/texbin:/usr/local/bin",. The plugin LaTeXTools looks in that path for *.sty files that are a part of the TexLive installation. While it may be possible (under some circumstances) to place the *.sty files within the working directory of the *.tex file, this particular plugin looks to the path mentioned hereinabove. So one option would be to add additional locations to the $PATH to suit the needs of the user, or simply place the *.sty files within the path that is pre-defined by the plugin developer.
I downloaded LuaEdit to use as an IDE and debug tool however I'm having trouble using it for even the simplest things. I've created a solution with 2 files in it, all of which are stored in the same folder. My files are as follows:
--startup.lua
require("foo")
test("Testing", "testing", "one, two, three")
--foo.lua
foo = {}
print("In foo.lua")
function test(a,b,c) print(a,b,c) end
This works fine when in my C++ compiler when accessed through some embed code, however when I attempt to use the same code in LuaEdit, it crashes on line 3 require("foo") with an error stating:
module 'foo' not found:
no field package.preload['foo']
no file 'C:\Program Files (x86)\LuaEdit 2010\lua\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\lua\foo\init.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo\init.lua'
no file '.\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo.dll'
no file 'C:\Program Files (x86)\LuaEdit 2010\loadall.dll'
no file '.\battle.dll'
I have also tried creating these files prior to adding them to a solution and still get the same error. Is there some setting I'm missing? It would be great to have an IDE/debugger but it's useless to me if it can't run linked functions.
The issue is probably that your Lua files are not on the path in package.path (for C files this is package.cpath).
My guess is that the LuaEdit program is not launched in the directory you have your files in, and hence does not have a match for eg .\foo.lua.
You have 3 simple solutions to this (from dumb to smarter):
Find out what path LuaEdit considers as ./ and put your files there.
Open up a terminal in the right directory (the one containing your files), and run LuaEdit from there.
Add the path the files are on to package.path and package.cpath before doing any require's
You may need to put:
lua
package.path = package.path..";c:/path/to/my/files/?.lua"
at the beginning of your files before any require (as jpjacobs indicated). I couldn't find any way to provide this from LuaEdit itself. It appears it runs the script using its full path, but keeps its current dir set to whatever it was when the IDE was started. If you run LuaEdit using full path from your application folder, it should work fine even without package.path changes.
While the IDE itself works fine with its own modules/libraries, it doesn't mean it makes them available to the application it runs.
(shameless plug) If you're still not happy with LuaEdit, I'd offer ZeroBrane Studio Lua IDE as an alternative, It's based on the same wxLua framework, but provides a bit more functionality and doesn't have this particular issue you're facing. It also supports remote debugging, so you should be able to debug your Lua scripts directly from your application.