Bootstrapping Anka macOS VM for your iOS Build/Test Job

What is Anka Build



Anka Build is a solution suite to configure a macOS cloud mac hardware, on which you can provision immutable docker like macOS VMs for iOS and macOS CI jobs. Anka hypervisor enables macOS VMs to run in a very resource efficient manner and fast boot feature makes them available on-demand instantly. Anka controller and registry modules provide a simple method to set up a scalable macOS cloud and integrate with third party CI systems.



Anka command-line interface enables you to bootstrap and prepare your macOS VMs in a dockerfile like fashion, for CI build and test jobs.



In this blog, we will look at how you can start to manage your macOS CI infrastructure as a code. Part 1 of this blog will focus on creation and bootstrap your macOS build/test environment that you can use a VM template to provision simple, fast, immutable elastic docker like slaves/agents.



Step 1 – Install AnkaBuild.



Install ankabuild.pkg on your mac and activate license (sudo anka license activate key). You can automate the installation and activation steps.



Step 2 – Create macOS VM.
Build a macOS VM running a specific version of macOS, hard drive allocation, CPU, and RAM. You can also modify CPU and ram settings later.



anka create --ram-size 4G --cpu-count 2 --disk-size 45G --app /Applications/Install\ macOS\ High\ Sierra.app myhisierravm



ankacreate



Step 3 – Install Toolkits in the macOS VM.



Use ‘anka run’ to work inside the newly created VM and install dependencies like Xcode etc to prepare your VM for iOS build/test. Anka run is similar to docker run. When you execute ‘anka run’ against an Anka VM, it executes in an isolated manner inside the VM, separate from the host.



Step 3.1 – Install brew, homebrew in Anka macOS VM.



Just execute command, provided on the brew.io site, but with ‘anka run’ to install brew inside the Anka VM.


anka run -n myhisierravm ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"



ankarun1



Step 3.2 – xcode-install in Anka macOS VM.



Execute xcode-select tool command with ‘anka run’ to install it inside the Anka macOS VM.


anka run -n myhisierravm sudo gem install xcode-install


ankarun2



Step 3.3 – Complete Xcode setup in Anka macOS VM.



FASTLANE_PASSWORD='passwd' FASTLANE_USER='usr' anka run -nE myhisierravm xcversion list


Note : -n option of anka run prevents implicit mounting of current folder inside the VM.


-E enables inheriting env variables (eg : FASTLANE variables) in the Anka macOS VM.


FASTLANE_PASSWORD='passwd' FASTLANE_USER='usr' anka run -nE myhisierravm xcversion install 9.2


ankarun4




In some scenarios, it might not be best to provide credentials directly in shell command line (saved history, etc). To secure FASTLANE_ variables, you could store them into a text file (fastlane_cred.txt) in the following form.


  • FASTLANE_USER=user
  • FASTLANE_PASSWORD=pwd
  • Then populate the Anka VM environment from the file (with -f | –env-file option).



    anka run -nf fastlane_cred.txt myhisierravm xcversion install 9.2



    Step 4 – Xcode setup is now complete inside Anka macOS VM.


    xcodesetupmacOSvm



    Step 5 – Mount provisioning profiles from host inside the VM.



    anka mount myhisierravm ~/Library/…/Provisioning\ Profiles /Users/anka/Library/…/Provisioning\ Profiles



    This will make provisioning profiles accessible inside the VM for Xcodebuild.



    Step 6 – Execute Xcodebuild for your project inside the Anka macOS VM.


    anka run myhisierravm xcodebuild test -scheme Kickstarter-Framework-iOS -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.2'




    Note : This command mounts the existing current folder from the host into the VM and executes Xcodebuild on it. Because we mounted provisioning profiles in the previous step to a specific default Xcodebuild location inside the VM, the above command will use those mounted provisioning profiles without the need for any configuration change inside the VM.



    Refer to anka run command line help for additional details.


    ankarun5



    In the next blog in this series, we will share how to setup and manage the Anka Build macOS CI cloud with command line/Infra as a code. Stay tuned.

    Share this post

    anka2024v1-1536x768
    A Year of Anka: Highlights from 2024
    We’re starting a new annual tradition here at Veertu with our A Year of Anka blog posts. We want our customers to know how the product has grown over the past year and think this is a great avenue to do so. Please enjoy and happy holidays from all...
    Read More
    anka-or-1
    Anka vs Orka in 2024
    It has been several years since we made our first side by side comparison between Anka and Orka. A lot has changed, and we believe it’s important to make sure the information out there is accurate. We’ll be specifically addressing a newer...
    Read More
    networking-performancev1
    Unlocking Superior macOS VM Network Performance: Introducing Anka's new networking mode for Apple Silicon
    Large and complex enterprises using Anka have many different demands, and we have worked to continue to develop innovative technology to meet these demands. Enterprise infrastructure hardware is often on the cutting edge, and they need advanced capabilities...
    Read More
    gitlab-with-anka
    Anka Cloud Gitlab Executor
    Veertu’s Anka and the new Anka Cloud Gitlab Executor Veertu’s Anka is a suite of software tools built on the macOS virtualization platform. It enables the execution of single or multi-use macOS virtual machines (VMs) in a manner similar to Docker....
    Read More
    mac-scan-v1
    Real-Time CVE Scanning of your macOS Build Systems
    It’s common that an organization’s macOS build system will download thousands, sometimes tens of thousands of third-party dependencies every hour. When building and testing iOS applications, it typically downloads and installs third-party...
    Read More
    anka-on-silicon-v1
    The ONLY Fully Automated Apple Silicon macOS VM Creation Solution
    Starting in Anka 3.1 we announced that Anka is now able to fully automate the macOS installation processes, disabling SIP, and enabling VNC — all previously manual steps users had to perform inside o the VM. At the time of writing this article,...
    Read More
    anka_click
    Scripting macOS UI User Actions With Anka Click
    Starting in Anka 3.2, we’ve introduced a solution for scripting macOS UI user actions. You may ask, “Why would I want to do that?”. Well, often macOS configuration and applications do not have a CLI allowing you to perform certain actions...
    Read More
    mac-scan-fullscan-shells-v3
    Real-time, continuous scan of file downloads on macOS for security vulnerabilities
    Today, we are announcing the Beta availability of the Mac Scan solution. Mac Scan software runs on macOS systems (bare metal, virtual, EC2 Mac) and scans downloads in real time for security vulnerabilities. There are multiple scenarios why you would...
    Read More
    Screen Shot 2022-10-17 at 10.13
    Anka 3.1- Fully automated VM macOS installation & The Behavior-Driven macOS UI Automation Framework
    We are very happy to announce the General Availability of Anka 3.1 for Apple Silicon / ARM macs. In this release, we are taking our approach to iOS CI automation one step further by introducing a Behavior-Driven macOS UI Automation Framework in Anka,...
    Read More
    ankam1v2
    Migrating from Anka on Intel to Anka on M1 Mac for iOS CI
    In this blog, we will cover the key topics for migrating from Anka on Intel to Anka on M1/M2 Macs. Anka is an IaaC solution from Veertu to set up an agile Container like CI for iOS CI using macOS VMs. Anka for Intel uses Apple’s Hypervisor.Framework virtualization...
    Read More