How to fully automate from build to .ipa file in xcode 4 - ios

In xcode 3, using a bash script, I could run xcode from the command line, then take the files in the build directory and zip them up into a .ipa file, allowing for a fully automated build process for my adhoc iOS distribution. Anytime there is human intervention, there is the possibly for error.
Under xcode 4, this seem to be not possible anymore. The build directory has been replaced with a DerivedBuilds folder and it uses some obfuscation naming, so it's not possible to let an external script find the files.
In xcode 4, after the build, I need to run Produce->Archive, then selected the file in the organizer, then select save, then navigate to the final folder and name the file and hit save. This is a very error prone process better left to machines.
So, is there a way to go from a clean build all the way to a signed .ipa file? I've got to believe this is possible, there is no way people with automated build processes are having to do this step by hand.
Does anyone know how to do this?

Sure, the script I have been using in my continuous integration environment is available at https://gist.github.com/949831 That might do more than you need but should be able to serve as a base for whatever steps you want to include in your build process.
As you noted it would be hard to predict the derived data path Xcode will use but it is not too hard to located it in the build output as part of the build script.

Related

Force copy bundle resource of a file in Xcode's new build system

I'm using the Xcode new build system and within the build system, I have a script that creates a file.plist with it as the explicit output and another script that takes in file.plist as input and modifies the file.plist. Then I put file.plist into the Copy Bundle Resources Phase.
This way works generally for clean builds and in Xcode builds. But it doesn't work in fastlane because the script to modify file.plist runs but the changes do not get copied over into the build directory. Making it run in fastlane requires a clean to occur before building.
Does anyone have experience with this issue and how did you go about solving this problem?

In Xcode 9's new build system, how do I execute commands before the check dependencies phase?

I have an foo.xcconfig file that will have different values depending where in the world a developer is. Currently, we use a phase to create this file (which is imported by other config files). In the new build system, Xcode is now resolving the dependencies before I have a chance to create a dummy to satisfy the include.
This is easily solved for CI builds by doing the work before calling xcodebuild, but for local builds using the GUI, there does not seem to be a good solution.

Build iOS app using Terminal

Is there a way to create a iOS without the Xcode IDE, and instead using Terminal and a Text Editor (like Atom)?
With Linux, i can accomplish this to build an Android app using Maven to create the minimum directory structure, compile the files after add them (in the Atom editor), create the APK and upload the package to the device.
Is there any command-line utility to accomplish some of this tasks in MacOSX?
You can use the xcodebuild command line tool to build, but there is no apple-provided tool to generate the project files other than Xcode. Google does have a tool called gyp which can generate the project files, though I'm not certain your use case is what it was designed for.
Other than that you pretty much have to hold your nose and use Xcode to setup your project, add files, change build settings, etc, and use whatever editor you want to actually edit the code.

Unity3D/iOS: Running a shell script post-Xcode build

When clicking "Build and Run" for an iOS project, Unity generates an Xcode project, fires up Xcode, builds the project, and runs it on the device. I'd like to run a shell script after Xcode finishes building but before it runs. If this were a mere Xcode project, I could simply add a "Run Script" entry to the Build Phases tab, but since this project is auto-generated by Unity I'm not sure how to proceed.
(I'm running OS X Yosemite, if it matters.)
Depends on how much work you want to put into this.
Solution A: Using Unity's PostProcess
You could use Unity's PostProcess, to modify the Xcode project accordingly.
Just mark a static method with the [PostProcessBuild] annotation, and Unity will execute it after the Unity build.
Example:
[PostProcessBuild]
static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
// modify the Xcode project here, or run the shell script directly (if it is ok to do this already here)
}
Sources:
Source: http://docs.unity3d.com/412/Documentation/ScriptReference/PostProcessBuildAttribute.html
Python script to modify Xcode project (not sure if it can add a shell script in build phases): https://github.com/kronenthaler/mod-pbxproj
How to start a process in C#: How do I start a process from C#?
Solution B: Append the Xcode Project
You could modify your Xcode Project accordingly, and afterwards just use Append when starting the next build and Unity asks what to do, when detecting that the folder already exists.
Solution C: Do it manually
Use Build instead of Build And Run
Modify the Xcode project after Unity finished it's build
Manually Run on the Device using Xcode
Solution D: Run the build in batchmode / use CI like Jenkins
You can invoke the build from the command line (terminal), and do what ever you want during/between the different build steps. But as this is a lot of work, I'd recommend to take a look at a CI like Jenkins. It comes with an installer for Mac OS X and is not that hard to set up. I guess there is a lot of documentation and Q&As about it.
Jenkins: http://jenkins-ci.org
I hope there's something that fits your needs. Just let me know if you need some more help or information. Cheers.

Cordova project from .zip fails to build ios, tries to write to directory from other computer

After successfully creating, building, and emulating Cordova's Hello World project, I unzipped the project folder that I am taking over from another developer on a different machine and saved it locally. While I can run the iOS app from XCode with the built project from the previous developer, I can't run the $ cordova build ios command successfully to rebuild it on my machine.
It give the following output:
The following build commands failed:
Check dependencies
Write auxiliary files
When I run it in debug mode, I notice that both of these commands are trying to make a directory for the old dev's computer (/Users/hisName/whereHePutIt/CordovaProject/stuffItIsTryingToBuild) rather than one relative to my project folder (/Users/myName/whereIPutMine/CordovaProject/stuffItIsTryingToBuild).
There is a lot of text to comb through, but it looks as though it is always failing while attempting to make a directory in /Project/platforms/ios/CordovaLib/build/CordovaLib.build
I am really stumped by this because I can't find any sort of setting or file in the project that tries to write anywhere but a path relative to my project file, and Android builds and emulates fine.
I had a similar issue on Android actually. My home for sdk tools moved but the project still wanted to use the old sdk tools.
The solution I took was to remove the platform and then re-add it. I am sure there is a way of going through the existing files and patching this, but everything you should need is in the plugin/ and www/ and where ever you elected to keep your assets.
If you do try this, make sure to create a backup before removing the platform -- it would be awful to lose changes that someone might have jammed down in the platform/ios folder.
I just ran across this issue under similar circumstances - unzipped a zipped copy of a iOS Cordova app from a coworkers computer to continue developing it, and found I could not successfully run the cordova build command.
I managed to get this to work by deleting the old "Debug-iphonesimulator" folders that had been zipped up with the rest of the project from the other computer, and then re-running the build command.
There were two folders that I deleted:
"../ios/CordovaLib/build/CordovaLib.build/Debug-iphonesimulator"
and
"../ios/build/ProjectName.build/Debug-iphonesimulator"
Hope this helps someone!

Resources