Implementing Workaround to Export Marker Based XCode Project from Windows

Hi all,
I’m having trouble implementing the method below to avoid relying on xcrun for exporting AR reference images. This is because I am developing on Windows and building an Xcode project to run on a Mac later. As I’m very new to the platform, I’d appreciate some advice on how to get this working in my project. Note that I am following the tutorial below:
Spawn an Object on AR Marker

  protected void InitLibraryManager()
    {
        if (!libraryInitialized)
        {
            libraryInitialized = true;

            if (imageManager.referenceLibrary == null)
            {
                imageManager.referenceLibrary = imageManager.CreateRuntimeLibrary();
                if (imageManager.referenceLibrary == null)
                {
                    Debug.LogError("AR: Unable to dynamically create ReferenceLibrary.")
                    return;
                }
            }

            //The number of images can be 0 if we just created the Library above, or if
            //this binary was built on Windows thus failing to copy the images correctly
            //into the build for a referenceLibrary set in the editor.  In either
            //case, we'll dynamically add the image here...
            if (imageManager.referenceLibrary.count == 0)
            {
                Debug.Log("AR: Detected no library images, adding our image dynamically as a workaround...");
                if (imageManager.referenceLibrary is MutableRuntimeReferenceImageLibrary mutableLibrary)
                {
                    Debug.Log("AR: Dynamically adding image.");
                    //imageToTrack must be read/write, RGB24.
                    mutableLibrary.ScheduleAddImageWithValidationJob(imageToTrack, "QRCode", 0.104775f);
                }
                else
                {
                    Debug.LogError("AR: Workaround failed - ImageManager ReferenceLibrary cannot be dynamically added to.");
                }
            }
        }
    }
%

AR Foundation doesn’t support building Xcode projects from Windows. You must build from Unity on a Mac for image tracking to work correctly on iOS.

To build for iOS, you need a Mac.
This is more a legal restriction than a software one.

There is an asset called “Build for iOS/macOS on Windows” and it has a legal section that states:

In the license that comes with the iOS SDK, Apple Inc. states that the iOS SDK shall only be deployed on Apple-branded computers. So, for the rest of this document, I will assume that your Windows computer is an Apple-branded computer running Windows through Boot Camp. I do not condone the use of this program outside this scope, and cannot be held responsible for any misuse you make of it.

@makaka-org I believe you are mistaking Unity for Xcode. Note that Unity fully supports building for iOS on Windows (that is, exporting an Xcode project, which itself can only be interpreted on a Mac).

However, our ARKit plug-in was built with native dependencies that require you to build your project from Unity on a Mac if you are using image tracking.

It’s interesting. Can you describe the working pipeline for that?

Example

I have a PC, and this is the main working machine, but sometimes I need to test on macOS/iOS, so I create an Xcode project on Windows and send it to the Mac.

Then I build on the Mac, I get errors that I’ve never seen on Windows, and ultimately, I need to pull my project from VCS on Mac and open it in Unity trying to fix macOS/iOS-specific errors.

I just wanted to know what the point of that feature?

Unity as a Game Engine supports creating Xcode projects from Windows. This works in most cases.

The 2019 AR Foundation team (all of these people have since left Unity) made a decision to break this assumption when it comes to building ARKit apps. I know for sure that image tracking and object tracking are affected by this. I’m not sure the full extents of this issue, which is why we recommend just building from Unity on Mac in all cases.

So it’s an AR Foundation issue, not a Unity issue, that prevents certain things from working if you build your ARKit app from Unity on a Windows machine. Ultimately it’s never been prioritized since then for us to see if we can fix this. I don’t know whether it’s possible to fix this or not without introducing breaking changes to the ARKit package and/or AR Foundation, but hopefully that explains what the problem is and how we got here.