Xcodebuild generates intermediate files and .o files with absolute paths - ios

I am running xcodebuild to build my project via command line and the strange thing is that the intermediate build files and the object files from the build folder contain hardcoded absolute paths from my machine. I think that xcodebuild does that automatically.
Is there a way to make them relative? I searched quite long for this but without success.
I need this because I want to transfer the entire project on another machine and to run some xcode unit tests via xcodebuild with the test parameter without rebuilding the project, so as a result I need to transfer the build files also on that machine. The problem is that the paths from the previous machine (on which the build was made) are present in the build files and .o files and it doesn't match the current machine path.
Example:
Build machine project path: /Users/MyBuildUser/BuildFolder/XcodeProject
Test machine project path (the transfer location): /Users/MyTestUser/TestFolder/XcodeProject
Paths such as: /Users/MyBuildUser/BuildFolder/XcodeProject/Sources/Source.h

The paths can be set in Xcode > Preferences > Locations via the Advanced... button:
From there select Custom > Relative to Derived Data or Relative to Workspace.

The problem was about the way I generated the project. The generation is done using CMake. By default, CMake uses absolute paths everywhere and this prohibits generated content to be moved from a workstation to another as described here:
How to tell CMake to use relative paths

Related

How do I get the path to SPM when I perform a archive?

I am now trying to use WireGuardKit, where it asks to create an "External Build System" and fill in the Directory with ${BUILD_DIR}/... /... /SourcePackages/checkouts/wireguard/Sources/WireGuardKitGo (this path has been modified and I guarantee that this path will allow me to pass the compilation).
However, when I execute archive, Xcode reports an error unable to spawn process '/usr/bin/make' (No such file or directory).
I suspect that $(BUILD_DIR) doesn't have a value when the compilation is executed, or I can't use this environment variable at this stage. Because when I don't use relative paths and use absolute paths to assign values to Directory, the project is able to archive successfully.
So my question is, when I execute the archive, how do I get the path of the package I inherited using SPM? Or can I use $(BUILD_DIR) environment variable when I execute archive? Why is it different from when compiling?
UPDATE:
I learned that $(BUILD_DIR) uses $() within it and when I try to use $() directly, it still reports an error, I also tried variables like $(BUILD_PATH), $(BUILD_ROOT), $(BUILT_PRODUCTS_DIR), but none of them work.
So could it be a problem with $(), an environment variable that has no value when the archive is executed?
How do I get the SPM directory when executing the archive?
I was able to solve this issue with an alternative configuration for External Build System
Here is a tutorial (see section "Manual Xcode steps")
The main idea is to use build_wireguard_go_bridge.sh script in your External Build System configuration:
Build Tool: $(PROJECT_DIR)/Scripts/build_wireguard_go_bridge.sh
Arguments: $(ACTION)
Directory: <empty>

Can I ignore some folder (containing bazel configuration) while building the project recursively?

For some reasons, practical or not, rxjs npm package stores BAZEL.build configuration in the package, so when I'm trying to build my project (which has node_modules folder) bazel tries automatically to build something that it's not supposed to build at all.
My question would be - what is canonical way of ignoring some specific folder while building bazel project recursively?
The only way to achieve what I'm looking for that I know of is to point to it explicitly in the command line
bazel build //... --deleted_packages=node_modules/rxjs/src (see user manual)
But I don't want to type this every time.
Bazel recently added a feature for ignoring folders (similar to gitignore).
Simply add node_modules to the .bazelignore file in the root of your project.
Yes, this is expressible as a bazel target pattern:
bazel build -- //... -//node_modules/rxjs/src/...
Full documentation is available at https://docs.bazel.build/versions/master/user-manual.html#target-patterns

how to change the path of source file which was referred gcda?

When i build my project for coverage testing with "--coverage -fprofile-arcs -ftest-coverage", and then move the build and source to the other user directory to execute testing. I will get so many problems such as "xxx/cc/cc/getopt_log.c:cannot open source file"
the details as the below:
Processing cs/CMakeFiles/cfa/__/src/base/fault_injection.c.gcda
/home/cov/build/xfcq/src/base/fault_injection.c:cannot open source file
the path of "/home/cov/build/xfcq/src/base/fault_injection.c" is the path of build environment, how to change it as the relative path or the path I specified.
I tried to use GCOV_PREFIX and GCOV_PREFIX_STRIP, these can't work well for me.
I also tried to add -b option for lcov, it does not also work well for me.
e.g., lcov --gcov-tool=/bin/gcov -d . -b xx/src -t "xfcq" -o test_cov.info
do you have idea to resolve it?
Well for using gcov coverage process you should never move the files after building your project, instead you should modify your automated build scripts to build everything to the desired location.
When you compile your project with the specified options it generates *.gcno files for each source file which are necessarily the flow chart like details of the relevant source file.
So, the object files are instrumented in such a way that they should trigger function(added by compiler to generate coverage info ) whenever any line of statement is executed to generate *.gcda files with all the execution information.
Note: I can see that you have specified three options in question (--coverage -fprofile-arcs -ftest-coverage) which is again wrong, as --coverage works as a replacement to the other two.
If you specify only --coverage then it will do for the compilation and the linking too.(remember to use it at both the places positively though)

Using the Robot Framework plugin, how to copy files outside the log folder into Jenkins?

I am running Robot Framework tests through Jenkins, and the tests use a custom Python library to take screenshots, save them into a specific folder (that is not the log folder), and embed them into the log. In the Jenkins job, I have a post-build action set to publish the Robot results, and I can get Jenkins to copy image files that are generated within the log folder, but I can't figure out how to copy image files that are generated outside the log folder.
The project's %WORKSPACE% is d:\git\product\registration
The directory of Robot output is \log\patient_search (the log directory is generated inside the registration directory)
The directory where the other images are generated is d:\git\product\registration\verify\images
If I put *.png into the "Other files to copy" box, Jenkins will copy any images within the log\patient_search directory and they embed correctly into the log. What I have in that box now is *.png,%WORKSPACE%\verify\images\**, and I have tried using backslashes instead, using a relative path (..\..\verify\images\**\*.png), and various combinations of asterisks and slashes. Those images always show as broken links in the log.
Are these paths wrong, or can this just not be done for files outside of the log folder?
I believe Robot Framework plugin "Other files to copy" works only inside "Directory of Robot output". A workaround would be to create a build step where you execute a shell and copy files to Robot output directory.

How does the build Agent Folder work on the Edit Build Workspace?

My build cannot pick up some of the projects in my application.
They are stored in their own projects in TFS source control.
I group them together in the Edit Build workspace;
These are the mappings:
The Build Agent folder does not let me simply put $(SourceDir). What is the impact of appending a folder name at the end as above?
How do I get the Build Agent to pick up the projects from the correct folder locations?
Currently I get these error messages;
8 error(s), 3 warning(s)
$/STAS/Timesheet/Timesheet/Timesheet.sln - 8 error(s), 3 warning(s), View Log File
C:\Builds\4\STAS\Timesheet\Sources\Timesheet\Timesheet.sln.metaproj: The project file "C:\Builds\4\STAS\Timesheet\Sources\Timesheet\..\..\..\..\StandardClassLibrary\StandardClassLibrary\StandardClassLibrary.csproj" was not found.
C:\Builds\4\STAS\Timesheet\Sources\Timesheet\Timesheet.sln.metaproj: The project file "C:\Builds\4\STAS\Timesheet\Sources\Timesheet\..\..\..\EmailMessageRecord\EmailMessageRecord\EmailMessageRecord.csproj" was not found.
This is exactly how the feature is meant to be used. The $(Sourcedir) macro is replaced by the Build Agent path (as configured on the Build Agent):
Whichever path is configured here is placed into $(Sourcedir) and whatever you additionally configure in the mapping is used to create the final destination.
So what happens is that these solutions will all be downloaded to their own sub directory under the build working directory. The only think you'll need to look out for is that relative paths between folders in source control or in your local mapping need to match up with the destination folder structure you choose int he build definition's workspace mapping.

Resources