Automated Unity iOS build on Mac - ios

I am doing the iOS builds for a group of Unity (Unity3d) game developers.
After pulling the latest git updates, I start up the Unity editor on my Mac and choose "Build Settings", select the iOS target platform, press Build, specify a destination folder and that is it.
Can this exact process be done automatically via the terminal prompt?

What you would need to do is create an editor method in Unity that does the iOS building:
http://docs.unity3d.com/Documentation/ScriptReference/BuildPipeline.BuildPlayer.html
And then call that method via the Unity command line arguments.
http://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod MyEditorScript.MyMethod

As Calvin said, you can use the executeMethod switch of Unity's command line to call your own C# command and have some build logic executed. I have written a small article about how to do this. There is also a cheat sheet showing the Unity API to use for specific tasks.

Related

How debug Kotlin on iOS with Xcode

Currently I am working on one KMM project. It would be really useful to be able to debug the shared code which is in kotlin in xcode project.
I am aware of this solution but I have problem to tell Xcode that *.kt files are source files
to be more specific in the above github link it is written :
You need to tell Xcode that *.kt files are source files, and run an lldb formatter script when debugging starts. Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the setup script.
Unless you're using Xcode 11 (in which case look here for help), the following script will install both debugging and formatting support:
./setup.sh
I do not know where and how I should run the ./setup.sh or if there is another way to do it?
The setup script is included in the github repository: https://github.com/touchlab/xcode-kotlin/blob/main/setup.sh
The above plugin is great if you want to debug on Xcode and I highly recommend it.
Just an FYI, in case you didn't notice, there is also a plugin for debugging shared code on iOS for Android Studio: https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile

Build flutter app for desktops

I saw a few peoples managed to build flutter apps for other OS than the usual Android/IOS
My question here is simple : How ? What is the current process to build a flutter app for mac/windows ? There's no need for it to be production ready. Something experimental is enough
For those wondering how to :
https://github.com/google/flutter-desktop-embedding
There's an example using openGL to render a flutter app
Run a Flutter project in Desktop
Step 1:
For Flutter to run on Desktop, we must be on the master channel, with the latest release. So run from cmd,
flutter channel master
and
flutter upgrade
Step 2:
Then we have to enable flutter desktop support.
set ENABLE_FLUTTER_DESKTOP=true
Step 3:
Then clone this repo and cd example directory.
Step 4:
Then replace the lib folder inside the example directory with our existing code, and replace the pubspec.yaml file, with our existing one.
Step 5:
Then run from terminal
flutter packages get
and
flutter run
You can find more info here.
You can check this link out
https://github.com/google/flutter-desktop-embedding
Still not stable but does a good job of rendering flutter apps on desktop
Here's something I found useful, it is currently in alpha version but does the job by enabling us to develop Mac and Windows apps in Flutter :
https://feather-apps.com/
For those who want to know the current state(2021), here is the startup project to help you test It for MacOS, Linux, Windows. The project heavily modified from official ci to build cross-platform easily. You might want to check the ci.yml If you want to build on certain platform without github-action.
In additional, go-flutter is also a valid option, that used go-lang and openGL to achieve cross-platform features.
If you want to know the difference between official and go-flutter, here is the issue about the details.

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.

Retrieving a library at build time in Xcode

My project uses a dynamic library, and I wish to retrieve that library at build time in my iOS build, via a Run Script phase.
Unfortunately it appears Xcode takes a snapshot of your project before my Run Script phase is reached.
If the library was already present, the previous version is used, not the latest.
I could run the script separately before beginning the build, however I would like to minimise the number of steps required to include a new version of my library.
Is it possible to run a script before Xcode makes its copy of the project for building?
Yes I am aware this is an odd thing to do, thanks.

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.

Resources