Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building iOS on MacOS MS-hosted machine #247

Open
Stephan-DXRS opened this issue Dec 6, 2023 · 1 comment
Open

Building iOS on MacOS MS-hosted machine #247

Stephan-DXRS opened this issue Dec 6, 2023 · 1 comment

Comments

@Stephan-DXRS
Copy link

We're trying to build our Unity iOS app, but are running into an issue. We are using the UnitySetup task, which works great on a Windows MS-hosted machine. However, on MacOS it keeps complaining about not finding the Unity Hub executable.

After digging into the code, we found the following couple of lines:

// Setup and read inputs.
let unityHubExecutablePath = tl.getPathInput(customUnityHubPathInputVariableName);
if (!unityHubExecutablePath) {
    // TODO: Add default paths for macOS / Linux.
    unityHubExecutablePath = 'C:\\Program Files\\Unity Hub\\Unity Hub.exe';
}

We tried setting customUnityHubPath to /Applications/Unity Hub.app as this is the default location for Unity Hub on MacOS. But the pipeline fails: "Unable to locate executable file". If we understand correctly, the UnitySetup task expects Unity Hub to be installed on the machine and it's not installed on the MacOS images of Microsoft.

Is there a way (task) to download and install Unity Hub via a seperate task? We've looked into the unitysetup.powershell module, but this only lets you install the Unity Editor.

Thank you in advance.

@Risu-swift
Copy link

 - task: PowerShell@2
    displayName: 'Install Unity Hub'
    inputs:
      targetType: 'inline'
      script: |

        # Define the Unity Hub download URL for macOS
        $unityHubUrl = "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg"

        # Define the default Applications directory
        $applicationsDir = "/Applications"

        # Download Unity Hub
        Invoke-WebRequest -Uri $unityHubUrl -OutFile "$PSScriptRoot/UnityHubSetup.dmg"

        # Mount the DMG file using hdiutil
        hdiutil attach "$PSScriptRoot/UnityHubSetup.dmg" -nobrowse -mountpoint "$PSScriptRoot/MountedImage"

        # Copy Unity Hub to the default Applications directory
        Copy-Item -Path "$PSScriptRoot/MountedImage/Unity Hub.app" -Destination $applicationsDir -Recurse

        chmod +x "$applicationsDir/Unity Hub.app/Contents/MacOS/Unity Hub"

        # Unmount the DMG file
        hdiutil detach "$PSScriptRoot/MountedImage"

        # Print the installation directory
        Write-Host "Unity Hub installed to: $applicationsDir/Unity Hub.app"
  
  - task: UnitySetupTask@1
    inputs:
      versionSelectionMode: 'project'
      installIOSModule: true
      customUnityHubPath: /Applications/Unity Hub.app/Contents/MacOS/Unity Hub

I used this code snippet to download and setup Unity hub on a MacOS agent. I am not sure if there is any other better way to do this but this works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants