Create archive without Xcode - xcode

I am building an Xcode project from console over ssh (I can use only xcodebuild command), but there are no schemes in the project (user forgot to make schemes shared). xcodebuild allows to pass "archive" parameter only if building scheme (-scheme), but that is not an option for me.
So the question is: is it possible to create archive using only target?
I investigated .xcarchive directory, it contains Info.plist file (which contains information about application), dSYMs directory (containing myapp.dSYM) and Products/Applications (containing myapp.app) directory. I also noted that the file size of binary in .xcarchive's .app is 2 times smaller than in .app that is in Release directory. I guess it is because of code signage.
Can I simply copy files from Release directory (.app and .dSYM) to .xcarchive and create Info.plist there to create archive? Or are there any other steps that I must take?

yes, archives are only folders you can make yourself.
look at ANY archive and try to replicate the folder structure. (changing the appname as required)

Related

Xcode build phase to copy app file to the Applications directory?

I'm using Xcode 6 to create Mac OS X applications, and I'd like to create a final build phase that copies the App file to the Applications directory. What's the best way to do this?
Just figured it out - I had to add a Copy Files phase to the end of the Build Phases.
In this phase, I specify Absolute Path: /Applications, and I dragged the product (.app) file to the files list.

Adding distinct Xcode resources for multiple executables using CMake

Background: I'm using CMake to configure a project that builds a combination of libraries and applications. Each application uses resource files such as images and text files that are unique to that application. Xcode understands the concept of resource files and can correctly copy them into the application bundle. If I were creating a project with exactly one application, there would be no problem: I can use CMake's set_source_files_properties(... PROPERTIES MACOSX_PACKAGE_LOCATION Resources) to tell Xcode to put the files into the bundle's Resources directory, such that a later call to [[NSBundle mainBundle] pathForResource:...] will correctly find them. (The pathForResource method searches the "Resources" directory by default.) The files also appear in the Resources group within the Xcode project.
Question: The problem appears when I include multiple applications in the CMake project. Each project needs to copy its own, distinct resource files into its own bundle's Resources directory. Therefore each application needs a distinct Resource group in Xcode in which to hold these files and from which to copy them. Yet these distinct directories must all be named "Resources." Ideally, each application-specific folder within Xcode would have its own unique "Resources" subdirectory with all of its needed resources. What actually happens is that the project has a single, shared Resources directory into which all the resource files are collected, and the project-specific "Resources" subdirectory contains only that application's info.plist file. Because all applications' resources are tossed into the same group, and because name collisions can occur (two projects with distinct files that have the same name), project bundles don't get the correct resource files.
Has anyone found a way to use CMake to setup an Xcode project that supports multiple applications with distinct resources? Or some other workaround?
My solution works for me but maybe this is not satisfying for you.
What I do is a simple copy files post build step where I copy my resources directly into the built Target.app.
The problem with my approach is that the files don't show up in the Xcode project.
Here is how I do it :
I override the ADD_EXECUTABLE macro. Inside, it evaluates the resource variable ${target}_RESOURCES.
So in my CMakeLists.txt for my target I collect some directories and resource files and store them as list in my target depending resource variable.
The following custom command is in my macro (could be anywhere, actually):
ADD_CUSTOM_COMMAND( TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -DFILES_LIST="${${target}_RESOURCES}" -DDESTINATION="\${TARGET_BUILD_DIR}/\${FULL_PRODUCT_NAME}" -DEXCLUDE_EXT=".svn .git CVS .DS_Store" -P ${ROOT_DIR}/cmake/scripts/copyFiles.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMENT "Copying resource files and directories to iOS App Bundle..." )
It calls my copy files script (Maybe there is a better way to add that custom build step):
SEPARATE_ARGUMENTS( FILES_LIST )
FOREACH( ENTRY ${FILES_LIST} )
MESSAGE( "copying: ${ENTRY} to ${DESTINATION}" )
FILE( COPY ${ENTRY} DESTINATION ${DESTINATION} PATTERN "${EXCLUDE_EXT}" EXCLUDE )
ENDFOREACH( ENTRY )
It works for me. I don't really care if the resources show up in the XCode project.
But I still would like to know.
Are there are any problems or issues when not having the files in Xcode?

How to Specify Active Folder for ExternalBuildToolExecution on Xcode 4?

When using a make for an external build system on Xcode 4x, how to specify the active folder?
The active folder appears on the first line cd/
ExternalBuildToolExecution Action
cd /Users/myName/Documents/Xcode/myProject
setenv ACTION
By default, it is the folder of the project, i.e. /Users/myName/Documents/Xcode/myProject.
However, when the project is created by a template, the Xcode project adds a layer:
/Users/myName/Documents/Xcode/myProjec contains myProject.xcodeproject and another folder named
/Users/myName/Documents/Xcode/myProject/myProject with all the source code inside.
So I need to specify /Users/myName/Documents/Xcode/myProject/myProject
An alternative solution would consist on defining the Directory in a Target, but the question What is the key in Xcode template to define Directory in a Target? remains unanswered.

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?

Xcode - build phase or script for copying only modified files to App Bundle

Mac OS X 10.5 compatibility required. Xcode 3.2.5.
My app looks in the bundle's Resources folder, for a "data" folder.
"data" contains a hierarchy of subfolders and data. The contents are constantly being modified.
I don't need to navigate or modify this data within Xcode.
Q. When building, how can I copy "data" (say, from the Xcode project's folder) to the Resources folder, but only copying those files within "data" that have been modified since the last build?
(Simply copying all files every time I build is not feasible; the file sizes are too large, slowing build times.)
Thanks for any help.
Shouldn't be a problem to use rsync in a shell script build phase. Something like this:
rsync -a "${SRCROOT}/data" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
That does a bit more than date comparison but it should still be quite a bit faster than what you're doing now.
The above doesn't delete any files you removed from the source directory; to do so, you can add --delete but I'd only suggest doing that after you're sure it's working properly.

Resources