Setting the Build Directory of an Xcode Project - xcode

So far, no matter what I try, Xcode dumps my project's products in a subfolder of the project directory. I've tried each setting under Build Locations, but it doesn't seem to work. If I try Users/MyName/svn/trunk, it'll end up in the project folder .../MyProject/Users/MyName....
What am I doing incorrectly?

Try going to:
Project -> Edit Project Settings -> General -> Place Build Products In: Custom Location.

Would adding a preceding / before your build path fix it? (eg: /Users/... instead of Users/... ?

Related

Unable to create a new module (module already exists) Intellij

I am trying to create a new module in my project. As soon as I specify the name of the module, Intellij throws "That this module already exists". After I exit the wizard it creates a directory with same module name but doesn't make it a module. I delete the directory and I perform "Invalidate Caches and Restart" but still the error persists.
I had this issue and went to .idea/modules.xml, found the path with the name I wanted, and deleted that line (just did ctrl+f with the name). After deleting that line and saving the file, I was able to create the module with that name.
You can try to perform the following actions:
Close the IDE and manually remove the module.
Remove .idea folder.
Open IDE and reimport the project.
Try adding the module once again according to official guide.
If the problem remains contact JetBrains support and attach a compressed log folder along with the project structure tree.
I had the same problem when I moved the code to a different directory. Detaching the workspaces, removing .idea, invalidating caches and so on did not help then.
For me what helped was this: Go to File -> Settings -> Project: workspace -> Project Structure. There you will see the all the projects you ever opened. And you will also see a button Add Content Root. There you can specify the new location of the (old) project.
It is a caching issue .
So try something on those lines
Invalidate cache and restart worked for me
But in case it doesn't you can try manually deleting .idea files or re-importing the project .
If you are using Gradle and this is a multi-project layout, which is looks like it is, you shouldn't create modules directly in IntelliJ.
Rather, create the directory manually if it doesn't already exists, create a gradle.build[.kts] file in it if needed, and then add an import statement for it in settings.gradle[.kts]. Then just refresh the Gradle configuration in IntelliJ ("Reimport All Gradle Projects").
I've started the project on Linux with root account and then this problem appeared when I've switched to user account.
For me changing the ownership of files in project directory worked.
sudo chown -R your_username:your_user_group project_directory
When this issue happens during import of existing project, then
--close intellij ide
--delete the project in explorer
--clone it again
--open intellij ide
--and try to reimport

Change Xcode Project's build path without breaking modules search path

I need to change the build path of my project to be folder in my project (without changing the global Xcode preferences), and I used this configuration I found in Stackoverflow:
//Intermediate build files go here
PROJECT_TEMP_DIR = $(SRCROOT)/build/$(PROJECT_NAME).build
// Build-related files for the active build configuration go here
CONFIGURATION_BUILD_DIR = $(SRCROOT)/build/$CONFIGURATION
// The final product executables and other build products go here
BUILT_PRODUCTS_DIR = $(SRCROOT)/build/$CONFIGURATION
But now the build is failing because he cannot find the frameworks...
Thanks.
You can try this way, work for me:
1. Go to File -> Project settings (or Workspace Setting)
2. Click the Advanced button
3. Click "Custom" and select "Relative to Workspace" in the pull down
4. Done
If your test target is failing to build, then you need to add the same build rules to your test target.

xcode distributing application with 2 project

i have a problem to distributing application with 2 project (one project with sub-project include inside). When i try to make as usual "archive", i'm not able to send application.
Could someone help me?
Regards
I'm guessing the sub-project is a library? And when you do Build > Archive you get an .xcarchive file instead of a .ipa? If so, you need to set the Skip Install flag to No on your library (see this answer), then Build > Archive will generate a .ipa file.
The reason this is happening is because you have two projects.
For the sub-project you need to edit the Target > Build Settings and set the Skip Install setting to Yes.
Afterwards the "Archive" action will work as usual.

How to bundle an openframeworks application in xcode (relative resource linking?)

An trying to get openframeworks to build me my application so that i can open it from anywhere and it will load the needed images from within the apps Resources folder.
I believe this is relative linking?
I have done it before, on an older xcode and oF 61.
To do this i dragged the needed images into the project file on the left and added it to the executable target, with in a 'build phase' -> 'copy files'.
Been trying all sorts of methods, ofSetDataPathRoot() which solved the problem last time isnt working for me this time.
Any ideas/help would be appreciated!
Thanks
First you need to tell xCode to copy your /bin/data directory into your application bundle by adding a build phase:
1. Click on your project in the Project Navigator
2. Select "Build Phases"
3. Toggle open the "Run Script" section and paste in the following:
cp -r bin/data "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources";
Then tell your app where to find the data folder relative to itself within the bundle.
Inside the setup method of your oF app:
ofSetDataPathRoot("../Resources/data/");
ofSetDataPathRoot() should solve this problem. Perhaps you are setting the replacement root path incorrectly?
Try calling ofToDataPath() yourself on a string path and print out the result, then use Terminal and cd inside the .app bundle to check if the path sounds correct. Paths are expressed relative to the location of the actual executable inside the .app bundle, so if the executable is at myApp.app/Contents/MacOS/myApp and the data files are at myApp.app/Contents/Resources then ofToDataPath( "texture.png" ) should return something like ../Resources/texture.png.
You can double-check the current working directory (myApp.app/Contents/MacOS in my example) by calling getcwd(), open up a terminal and type man getcwd for more info on that.
oF now sets data path root and does internal calls to ofToDataPath() by default. What version are you using?
Have you looked inside the product's package contents to make sure your resources are getting copies in the proper build phase?

How do I use a relative path in Xcode project settings?

How do I use a relative path in Xcode project settings?
All paths in Build Settings are assumed relative to the directory that contains the .xcodeproj file. Use the standard Unix path tokens
. project directory
.. parent directory
So if your project file is trunk/Mac/proj.xcodeproj, and your headers are in trunk/Headers/foo.h, you would add ../Headers to your Header Search Paths.
Also there are two paths: $SRCROOT and $SDKROOT.
In the upper left corner next to the build/stop buttons, click on the name of your project and Edit Scheme...
In the left column, click on Run
Click on Options
Put a check next to Working Directory: Use custom working directory.
You can then change the relative path to anywhere you want.
EDIT: This is for Xcode 4.1
For Xcode 5:
Click on Product -> Scheme -> Edit Scheme.
Then follow ulu5's instructions: Click "Run", Click on "Options", and check the box "Use custom working directory."
The various answers currently here which recommend setting the working directory when executing a project by editing the scheme and then choosing whatever directory you want are missing what seems like a key part of the question: Relative Path. If you just use the file navigator in the UI you'll get an absolute path, likely with your own home directory in it, which isn't so good if the project you're working on is shared with other people.
To specify a working directory relative to the project folder in there, find the "Working Directory" field in the scheme (In XCode 10.1, that's Product | Scheme | Edit Scheme, then Options, then check "Use Custom Working Directory"), and use $PROJECT_DIR to get the path relative to the project.
Using Xcode 9:
It may be intended for Xcode to always use relative file paths based on the directory that contains the xcodeproj, but sometimes this does not seem to be true, and in my case this may have been due to the fact that the project (directory and all) was copied from an earlier version. I had to do:
Target(top left)->Edit Scheme->Use Custom Working Directory
and then specify to use the directory containing my project file.

Resources