Using Command line to add files to xcode project - xcode

I am trying to write a bash script that downloads a bunch of classes from the internet, inserts them into an existing (or maybe not?) xcode project and compiles them using xcodebuild into a static library.
However, I could not find a way to add classes to the project via command line, but only by gui.
Is there any way to do so?
In addition, is there any way to create an xcode project via the command line?

You should read about cocoapods.
Regarding your second question about creating a project via the command line, check this link: cmake
If I remember correctly the terminal command should be something like cmake -G Xcode .....

An old problem and I haven't found a valid solution, but actually, with a bit knowledge from the community, it wasn't that hard to solve. I published my results in the github project XCodeControl.
You need a basic xcode project created by xcode though. It should be possible to create an empty xcode project pattern and copy+modify that to create a new project.

Related

Xcode 13 and Linux Makefile

I searched and it seems all the answers are from are from many years ago. I'm working on a command line tool for linux/Mac that currently uses a Makefile. I wanted to use the Xcode debugger, so I tried to build an Xcode project, but I'm having some final difficulties.
I created a new project of type command line tool with external build target in the project directory. The default was to use /usr/bin/make. It ended up in a subdirectory, and based on several older web resources, I moved the project file up to the folder with the makefile. I added the source files in the folder to the project and right now I can edit and build from Xcode without difficulty.
The issue is that the final executable ends up in a subfolder called bin, and I can't seem to discover how to tell Xcode that that is the final executable. All of the resources I've found talk about adding a custom executable to the target from the project menu, but that menu no longer exists. Searching project help doesn't seem to point to any setting for the executable produced by an external build process. The closest build setting I could find was PROJECT_NAME, but changing that didn't seem to help.
Thanks.
Found an answer on another site. Edit the info tab in the scheme to identify the binary.

How can I change my BB10 project to use a makefile?

I recently created a new Blackberry project Momentics, and it runs fine from the IDE, but I need to be able to build it from the command line using a Makefile. I ran make in Terminal, but received an error because the makefile does not exist.
I checked the sample apps that I've been looking at, and they all have makefiles. I found some sources that say you can pick whether you use a managed build or a makefile when you create the project, but I found no such option in the latest version of Momentics (2.1). I tried changing this setting in the project properties, but the Builder Settings under C/C++ Build are all greyed out.
How can I change my BB10 project to use a makefile? If that isn't possible, how can I require a new project to use a makefile instead of a managed build?
It turns out that the option to use a makefile is unintentionally hidden in OSX. When you create a Blackberry Core Native project, the Build Settings screen will look like this:
I viewed the same screen on Windows, and the option that I wanted was right below language. I then tried again in OSX, and found out that you can scroll this screen to show the "Build" option.
I also discovered that creating the project as a Blackberry Cascades project doesn't give you this option at all, but will always use a makefile to build.
I also tried converting my original project from using managed build to using makefile. This appeared to be possible from the File > Import option. I tried importing my project as BlackBerry > Existing Code as BlackBerry C/C++ Makefile Project and as C/C++ > Existing Code as Makefile Project, but neither option actually converted my project to a makefile project. Unfortunately, because of this, the best solution to convert the project seems to be starting a new project with the desired setting and copying the files and settings from the old project.

Create new xcode project from command line

I want to create iPhone application with native apple frameworks. But I want to create it from command line. Please help. Thanks
pod lib create ProjectName
This will create XCode project library, sample and UnitTests.
there is no ready-made tool to do this but you can use another project as a template, copy it, rename it and its targets/settings (it's all XML so you can parse and modify it, but for simplicity I would try to use a project template in which you only have to exchange some names :))

creating an XCode project with existing code

I'm in the process of porting a Linux application to Mac. I have different files with the source code that can get compiled and linked using the standard Makefile.
I'm going to be porting that code to Mac and continue writing code in C (sorry, no obj-c). Is there a way to create a project on XCode, add the existing code so I can use XCode and the IDE, compile and debug the code and generate Mac Makefiles?
Thanks for the help
New Project -> Other -> External Build System
(in new project)
Expand "Targets"
select the target the template created
press return
edit the target settings:
by default, it uses /usr/bin/make for invocation. if you want to use some other build system, then you'll have more to configure.
for a Makefile, you will need to set the 'Directory' field of the build settings window to the directory which contains the appropriate makefile to build.
note that you'll lose some integration when using a makefile.
you can regain some of that by adding the sources to the project (drag and drop), and not associating them with a target.
to improve navigation and code completion, you may want to create a second (dummy) target (such as a static library) so the ide parses your programs. you would then add the sources to the dummy static library, and set the makefile as a 'dependency' of the static library (so it gets built, and so it gets built first).
The Apple Developer docs have a section on porting makefile based projects into XCode.
"Porting UNIX/Linux Applications to OS X"
This subsection is most relevant: "Building makefile projects with XCode"
https://developer.apple.com/library/content/documentation/Porting/Conceptual/PortingUnix/preparing/preparing.html#//apple_ref/doc/uid/TP40002849-BBCJABGC
You can build using your existing makefiles and create a wrapper project with a custom target with a 'Run Script' build phase that just calls down to your makefile. This means that you'll also be able to use the debugger, but you probably won't get the full benefit of the editor with autocompletion etc.
To import C code into Xcode:
start xcode
new project
pick something like Standard Tool. Should read c command line tool.
drag you file or files onto main project window. This is the first window that comes up when you create a new project. My project name is xaBitHoist. I dropped the files on xaBitHoist > src.
just build. Seems to default to main.c
to change start program or add argues Project > New Project Executable.
the online help for xcode is good.
Good luck.
Robert

Generate an xcodeproj

I know this might sound a bit strange but I'd need to generate a xcodeproj automatically.
Basically scanning the filesystem and adding certain files to the project and to a specific target.
The main reason behind this, is that I work in an zero IDE environment. Thus, we have our own build system and source files are added and removed all the time.
I could use "create folder references for any added folders". However, xcode won't ever parse source files if they aren't part of any target. So, no symbols, no code completion...
To me, my only option would be to "auto-update" my xcodeproj with a script...
Thanks in advance for your inputs!
Cmake is one option (see this related question) and there's also Scons which I think can generate Xcode projects. There's also Qt's qmake which can generate the project files, but this is probably overkill unless you're using full Qt.
You can either user AppleScript (or anything OSA-compatible) to automate the process of creating the project in Xcode itself, or you could look at CMake, which is able to generate Xcode project files.

Resources