How to get the Xcode project root directory?
Example: /Users/username/MyProjects/Project/. similar to ${SRCROOT}
I checked through FileManager urls and couldn't find the path.
Goal
I am running tests and would like to create a log.txt file in the project root directory.
AFAIK there is no direct way to access this, but what you can do is this for simulator builds:
Modify your xcode scheme to add an environment var SRCROOT with the value ${SRCROOT}
In your code, get the system environment using ProcessInfo:
let srcroot = ProcessInfo.processInfo.environment["SRCROOT"]
Related
Im trying to install a JSON formatter for Cucumber but am having trouble configuring it. The steps (listed here) go like this:
1. Download cucumber-json-formatter-darwin-amd64 and rename it to cucumber-json-formatter
2. Move it to a directory that's on your PATH
3. Make it executable with chmod +x cucumber-json-formatter
4. Verify that you can run it: cucumber-json-formatter --help
I have the file downloaded and renamed correctly. However, I am stuck on the second step of moving it to a directory thats on my PATH.
Doing some research, I know what the folder structure looks like but I'm not sure exactly what the step is instructing. How would I achieve this step? Can it be in ANY directory on my PATH? I am currently using a Mac if that makes any difference for the solution.
Move it to a directory that's on your PATH
PATH refers to the machine's environment variable named PATH. Any time the OS is asked to execute something PATH is searched.
On Windows open System Properties dialog, click Environment Variables button and Path is listed there. You can add a new entry for the location of cucumber-json-formatter or you can move it to an existing Path entry.
I've been trying to add additional functionality to the electron installer, where I copy some files that are packaged inside the installer, but I receive a non-descriptive error when I try to compile my electron project to create the installer i.e. I get:
* writing effective config
* packaging
* building
x [object Object]
Here is what my script looks like:
!macro customInstall
Rename "$APPDATA\myfolder\img" "$APPDATA\myfolder\img-old"
SetOutPath "$APPDATA\myfolder"
File /nonfatal /a /r "additional_files\*"
CreateShortcut "$SMSTARTUP\mylink.lnk" "$INSTDIR\mylink.exe"
!macroend
Basically everything works except the file copy part. When I remove that part the project builds and compiles into an installer with no problems.
I've also tried to use CopyFiles instead of SetOutPath and File and it works as expected when I place the additional_files folder into the same folder as the installation (dist folder), but I want the folder to be packaged inside the installer. However, I cannot get the additional_files to be packaged with the installation.
I believe it's a location issue, that is, that the NSIS script cannot locate the additional_files/ folder. I've tried modifying the package.json file by adding to the files section the additional_files/ folder and placing it in the root of the project.
I've even tried placing it in the build folder where my installer.nsh script resides, but with no luck.
File looks for files relative to the directory where the .nsi is by default. /NOCD can be used to prevent that but I'm not sure if electron uses that switch.
!cd can be used inside a script to change the directory but I'm not sure if that is going to help you much in this case unless you are willing to use a absolute path and in that case you could just use the absolute path with the File instruction instead.
If you only know where your .nsh file is I suppose you could try File /r "${__FILEDIR__}\additional_files\*"
if you are using electron-builder you have two options inside the settings
extraResources this will copy files into the $INST_DIR/resources folder in your app (this is where the app.asar file is too), and you can access via process.resourcesPath, ex:
extraResources: [
{ from: './dist/ThirdPartyNotices.txt', to: 'ThirdPartyNotices.txt' },
]
extraFiles this would do the same but place the files into the $INST_DIR root folder of your installation ex:
extraFiles: [
{ from: './distrib/mytool.exe', to: 'mytool.exe' },
],
to get the root folder you can use something like remote.app.getAppPath().replace('resources\\app.asar', '').replace('resources/app.asar', '');
all info on: https://www.electron.build/configuration/configuration#overridable-per-platform-options
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.
I have a Grails application in which I generate PDF/Excel files in a folder.
My problem is, everytime I need to change the directory path through code when I test or run the code on different machines like Windows, Linux, Mac.
So what is the generic path, which will be applicable for any/all platforms as the default temp directory, so that I won't need to manually set path for the directory while running code on different machines/platforms.
The temp directory is available via
String tempDir = System.getProperty('java.io.tmpdir')
To create temp files in the default location for the OS you can use File.createTempFile(prefix,suffix)
I'm currently building an app for jailbroken device, and I need root privileges for my app so that I can perform some tasks ask root. I found a related question : Gaining root permissions on iOS for NSFileManager (Jailbreak). But I am really new to iOS, I don't understand and unable to complete task from step 4. Can anyone make it more detail please?
What step 4 is telling you:
Open the original executable file and delete its contents (the contents are now stored in the previously copied and renamed binary).
is simply that you have moved the executable file for your app to a new filename, and you should replace it with a script with the name of the original executable.
Example
If you build an app named HelloWorld, Xcode will create a HelloWorld.app directory, with a file named HelloWorld inside it, which is executable.
The answer you link to suggests basically renaming the executable to something like MobileHelloWorld.
Once you've done that, create a new file in the HelloWorld.app directory called HelloWorld, and edit it with a text editor to give it this content:
#!/bin/bash
dir=$(dirname "$0")
exec "${dir}"/MobileHelloWorld "$#"
That script will then be run when you tap the app's icon, because in the app's Info.plist file, the name of the executable is
<key>CFBundleExecutable</key>
<string>HelloWorld</string>
and HelloWorld is now a shell script, which invokes MobileHelloWorld, the renamed binary executable file.