Xcodebuild'ing a workspace and setting a custom build path - workspace

I'm trying to use xcodebuild to build a multi-project project in a workspace. When XCode builds a workspace it automatically places all build artifacts in a common directory in DerivedData so that each project can access it dependencies.
If I use this command:
xcodebuild -workspace myWorkspace.xcworkspace -schema builtIt -configuration Release
Eveything works, but the artifacts are placed in usual derived data directory. I want then to appear in a specific directory which I can access from CI builds. So I tried this
xcodebuild -workspace myWorkspace.xcworkspace -schema builtIt -configuration Release SYMROOT=build/products OBJROOT=build/intermediates
However xcodebuild fails with this saying
Details: Failed to load dependencies output contents from ``/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d''.
Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “DNRootSelector.d” couldn’t be opened because there is no such file."
UserInfo=0x4012fea40 {NSFilePath=/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d, NSUnderlyingError=0x4012fc240 "The operation couldn’t be completed. No such file or directory"}.
User info: {
NSFilePath = "/Users/d4rkf1br3/projects/dNodi/build/intermediates/dNodi.build/Debug-iphoneos/dNodi.build/StaticAnalyzer/normal/armv7/DNRootSelector.d";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\"";
}
The problem appears to be that xcodebuild is no longer using a central directory for all projects in the workspace and is storing the artifacts in each project instead. Hence it cannot locate the dependencies between code being compiled and artifacts produced in other projects.
Does anyone know the correct parameter to set on the command line?
Xcode's Build Setting Reference has not been updated for two years so I don't know if there are new build settings I can apply.

I'm not sure if this is a new option but the 5.0 release of xcodebuild has an option -derivedDataPath which allows you to specify the directory you'd like all the build products to sit in.
For instance, passing -derivedDataPath build creates the folder build relative to where you ran xcodebuild from, and you can find your app predictably in a subfolder like build/Build/Products/Release-iphoneos.
Documentation: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

The best solution i have found so far is to use the CONFIGURATION_BUILD_DIR parameter with an ABSOLUTE path (e.g. /tmp/$PROJECT/build). Like this:
xcodebuild -scheme "scheme" -configuration Debug -sdk iphoneos clean build CONFIGURATION_BUILD_DIR=$ABSOLUTE_BUILD_PATH
I use Jenkins and there I have an variable named $WORKSPACE. With $WORKSPACE/build as my CONFIGURATION_BUILD_DIR I have a solution I'm happy with.
The relative paths don't seem to work as expected. We should file a bug report.

I also met this problem when I build my project from Jenkins CI tool. My main project depends a sub-project. I have tried building follow #Chilloutman's solution like this:
xcodebuild -target TravelGuideMdd -sdk iphoneos -configuration DailyBuild clean build CONFIGURATION_BUILD_DIR=/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build BUILD_DIR =/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build
or
xcodebuild -target TravelGuideMdd -sdk iphoneos -configuration DailyBuild clean build CONFIGURATION_BUILD_DIR=/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build
Both of them occur errors Could not find iphoneos in /Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build
But I get success finally using this:
xcodebuild -target TravelGuideMdd -sdk iphoneos6.1 -configuration DailyBuild clean build SYMROOT=/Users/mobileserver/jenkins_home/jobs/TravelGuide-Buid-For-Me/workspace/build
That is: Setting the SYMROOT with a absolute paths.

Related

How I can turn off warnings in Gitlab-ci?

How can I skip these warnings in Gitlab-CI?
It spams all logs in pipeline.
WARNING: /opt/react/b57e2b5b781b5438a08ac93a288c49a0c6113e8c/node_modules/#mui/icons-material/esm/CenterFocusWeakOutlined.js: not supported: outside build directory
Perhaps you should fix the warning and not sweep under the carpet.
I refer to this answer: Gitlab CI - not supported: outside build directory
Summary:
GitLab only can package artifacts found in the $CI_PROJECT_DIR directory (/home/gitlab-runner/builds/Gso-uWvA/0/www/your_project).
Therefore, make sure your project and it's dependencies can be found in this path. Don't use absolute paths.
Gitlab-Documentary: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html
Gitlab-Forum: https://forum.gitlab.com/t/warning-not-supported-outside-build-directory/3680/5

Nothing will be added to build artifact 'drop'

I am trying to host a jave project. I have build the pipeline by setting up the parameters as shown in the images but the i am encountering the error saying ##[warning]Directory '/home/azureuser/myagent/.\run.cmd/5/a' is empty. Nothing will be added to build artifact 'drop'. How do I fix this?
It seems you want to publish your jar package to build artifact 'drop'. Jar package should be in the $(System.DefaultWorkingDirectory)\target folder. Thus, you need to use the copy file task to copy jar package from target folder, then publish the package to drop.
You could also check the log of Maven task to see the specific location of jar package.

Unable to pass user.dir parameter to code using pom.xml and mvn cmdline

Im a newbie to azure and maven. I have created a build pipeline and it is dropping artifacts to Build.ArtifactDirectory. In CD pipeline, there is a java class which uses System.getProperty("user.dir"). But this path is taking wrongly and it throws ClassNotFoundException.
Reason for this:
Actual artifacts in cd after drop is present in path: C:/agent1/1/a/buildpipeline/drop/s/TestCode/src/main/read.java
user.dir : is searching in path: C:/agent1/1/a/ in which the code is not available.
Fix the issue:
To fix this, i need to manually pass the user.dir value through maven commandline that is -Duser.dir="pathname". But this is not working
I can change the artifact drop path from build pipeline and include a task of download artifact in release pipeline - Is not working because, I need to add a maven task to integrate pom.xml and it is automatically showing the path C:/agent1/1/a/buildpipeline/drop/s/TestCode/pom.xml.
Please help me with a solution

Compile directory in Azure DevOps Repos and save the results somewhere

Let’s say I have a directory structure like this in an Azure DevOps repo:
Main/
- A/
- *.csproj
- B/
- *.csproj
- C/
- *.csproj
Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild#1 task, or do I need to use some other Azure task?
How do I tell Azure to build that precise Main/A/*.csproj file and do
I need to use /p:OutputPath inside the VSBuild#1 task
If you're using classic UI, you need to unlink the default solution:
And then choose the A project by the browse option:
If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.
Note:
Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.
If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.
In addition:
1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:
Copy Files Task.
Publish Build Artifacts
Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.
Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.
Hope all above helps :)

How set up rapidjson without git

I need to use rapidjson as a third party library to replace libjson. I'm trying to figure out how to build it so I can use it's build files in my project (dependency list).
I downloaded rapidjson from github, and I'm trying to get a buildable project. I'm looking at the instructions at rapidjson website, and it's showing that I need to do the following, below (Installation).
We don't use git, so what would I need to do instead of the git submodule update --init step?
Why would I need a build dir in the include/rapidjson directory with nothing in it?
When I cd to build and type cmake, it seems to be missing parameters. What is the full cmake command? Thanks!
Installation
RapidJSON is a header-only C++ library. Just copy the include/rapidjson folder to system or project's include path.
RapidJSON uses following software as its dependencies:
•CMake as a general build tool
•(optional)Doxygen to build documentation
•(optional)googletest for unit and performance testing
To generate user documentation and run tests please proceed with the steps below:
1.Execute git submodule update --init to get the files of thirdparty submodules (google test).
2.Create directory called build in rapidjson source directory.
3.Change to build directory and run cmake .. command to configure your build. Windows users can do the same with cmake-gui application.
4.On Windows, build the solution found in the build directory. On Linux, run make from the build directory.
On successfull build you will find compiled test and example binaries in bin directory. The generated documentation will be available in doc/html directory of the build tree. To run tests after finished build please run make test or ctest from your build tree. You can get detailed output using ctest -V command.
It is possible to install library system-wide by running make install command from the build tree with administrative privileges. This will install all files according to system preferences. Once RapidJSON is installed, it is possible to use it from other CMake projects by adding find_package(RapidJSON) line to your CMakeLists.txt.
It is header-only library. So if you just want to integrate it into your project, just copy the /include folder to your project, and it should works.
All other instructions are for building unit tests, performance tests and documentation.

Resources