game-ci / unity-builder

Build Unity projects for different platforms
https://github.com/marketplace/actions/unity-builder
MIT License
858 stars 253 forks source link

How to build for il2cpp #610

Closed edqx closed 11 months ago

edqx commented 1 year ago

I feel like this should be a trivial question for unity-builder, but I'm struggling to build my game with il2cpp.

First I got this: image

Then I tried to use a docker image that ended in -il2cpp, one of the ones here: https://hub.docker.com/r/unityci/editor/tags?page=1&name=windows-il2cpp

That got an issue to do with not being able to be ran on linux architecture: image

... So I moved to use Windows Server for my GitHub actions, where now I get this: image

But I think this is a lost cause, since UNITY_EMAIL, UNITY_PASSWORD and UNITY_LICENSE are all set fine in the repository's secrets tab.

I think I'm completely on the wrong track here and missing something really obvious, like a bit of xy problem going on.

Thanks.

webbertakken commented 1 year ago

You can only build IL2CPP for that platform that you're on.

On windows, licensing works differently. If you pass the documented parameters correctly, you should be able to build a Windows IL2CPP build.

Sound like there's just a small misconfiguration issue that occurred because you switched to a Windows runner and Windows activation works differently. Recommend testing that your variables are indeed passed into the workflow step. If nothing else works, please consult our troubleshooting section.

edqx commented 1 year ago

So I should run the manual activation step with a windows runner?

MrGadget1024 commented 1 year ago

You can only build IL2CPP for that platform that you're on.

From that I gather that the example given here in the docs can't actually work at all.

davidmfinol commented 1 year ago

@MrGadget1024 That example works only if you are using Mono backend for the desktop platforms.

MrGadget1024 commented 1 year ago

@MrGadget1024 That example works only if you are using Mono backend for the desktop platforms.

How would I specify to use Mono instead of IL2CPP? I couldn't find that option in unity-builder. The project in Unity is set to Mono.

davidmfinol commented 1 year ago

Scripting backend can be set as shown in the Unity docs: https://docs.unity3d.com/Manual/Mono.html

MrGadget1024 commented 1 year ago

Scripting backend can be set as shown in the Unity docs: https://docs.unity3d.com/Manual/Mono.html

As I said - it's already set to that in Unity, but I got the same error as the OP about IL2CPP not installed.

MrGadget1024 commented 1 year ago

Scripting backend can be set as shown in the Unity docs: https://docs.unity3d.com/Manual/Mono.html

Which project file is unity-builder looking in and what's it looking for to determine which scripting backend to use?

davidmfinol commented 1 year ago

Which project file is unity-builder looking in and what's it looking for to determine which scripting backend to use?

Unity should automatically update the ProjectSettings/ProjectSettings.asset file when you edit it in the UI, but you should also be able to manually edit that file and set scriptingBackend.Standalone to 0.

MrGadget1024 commented 1 year ago

... manually edit that file and set scriptingBackend.Standalone to 0.

This is what I needed: upstream repo had 1 and fork didn't have project settings saved (thanks Unity) so didn't push.

Now, with that working, WebGL build shows this and it works:

image

So that begs the question, why can't that work for other platforms on ubuntu-latest, or is there a ubuntu container we need to use that has IL2CPP installed, or is there a command we can invoke to install IL2CPP?

MrGadget1024 commented 1 year ago

Ok so I switched back to IL2CPP for scripting backend and pushed, and applied a customImage to the workflow, and this failed for all except StandaloneLinux64.

Error building player because build target was unsupported

name: Unity Builder

on:
  push:
    paths:
      - .github/workflows/UnityBuilder.yml

jobs:
  buildForAllSupportedPlatforms:
    name: Build for ${{ matrix.targetPlatform }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        targetPlatform:
          - StandaloneOSX         # Build a macOS standalone (Intel 64-bit).
          - StandaloneWindows     # Build a Windows standalone.
          - StandaloneWindows64   # Build a Windows 64-bit standalone.
          - StandaloneLinux64     # Build a Linux 64-bit standalone.
          - iOS                   # Build an iOS player.
          - Android               # Build an Android .apk standalone app.
          - WebGL                 # WebGL.
        unityVersion:
          - 2019.4.40f1
          #- 2020.3.43f1
          #- 2021.3.16f1
          #- 2022.2.1f1
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Unity Builder
        uses: game-ci/unity-builder@v2
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
        with:
          customImage: unityci/editor:ubuntu-2020.3.43f1-linux-il2cpp-1.0.1
          targetPlatform: ${{ matrix.targetPlatform }}
          unityVersion: ${{ matrix.unityVersion }}

      - name: Archive Build
        uses: actions/upload-artifact@v3
        with:
          name: Build-${{ matrix.targetPlatform }}
          path: build/${{ matrix.targetPlatform }}
davidmfinol commented 1 year ago

If you want IL2CPP for macOS, you need runs-on: macos-latest, and if you want IL2CPP for Windows, you need runs-on: windows-2019.

See the example: https://game.ci/docs/github/getting-started#advanced-il2cpp-example

Maybe we need to make this example easier to find?

SethCram commented 1 year ago

You can only build IL2CPP for that platform that you're on.

* linux-il2cpp image can build Linux builds in IL2CPP mode. This image can be run from any runner that supports docker.

* windows-il2cpp image can build Windows in IL2CPP mode. This image can only be run from a Windows runner.

On windows, licensing works differently. If you pass the documented parameters correctly, you should be able to build a Windows IL2CPP build.

Sound like there's just a small misconfiguration issue that occurred because you switched to a Windows runner and Windows activation works differently. Recommend testing that your variables are indeed passed into the workflow step. If nothing else works, please consult our troubleshooting section.

As I understand it, the IL2CPP scripting backend is popular for mobile platforms like Android and iOS. If you can only build IL2CPP for that platform that you're on, then is it impossible to create a mobile build with Game-CI using IL2CPP?

davidmfinol commented 1 year ago

As I understand it, the IL2CPP scripting backend is popular for mobile platforms like Android and iOS. If you can only build IL2CPP for that platform that you're on, then is it impossible to create a mobile build with Game-CI using IL2CPP?

You can only build Desktop IL2CPP for that platform that you're on.

You can build mobile IL2CPP as long as the modules are installed.

asbjornu commented 1 year ago

You can build mobile IL2CPP as long as the modules are installed.

@davidmfinol, does this mean we can build on ubuntu-latest without any problems? Will building on macos-latest yield any performance improvements or other benefits, or is it better to use ubuntu-latest when just building for iOS (and Android)?

davidmfinol commented 1 year ago

Yep, recommend using ubuntu-latest when just building for iOS and Android

AndrewKahr commented 11 months ago

@asbjornu Note if you want to leverage Burst, you will need to build Android using Windows (now windows-2022 as we updated the images) and build iOS using macos (any version works, generally macos-latest works well). Closing this as the issue appears to be solved.