# Error loading a library for Mac universal build: "logic needs to be updated"

**URL:** <https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400>\
**Category:** Platform & Builds\
**Tags:** uat, MAC, unreal-engine, build-failed, question\
**Created:** [May 14, 2024, 11:03pm UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400 "2024-05-14T23:03:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Travis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Travis](https://forums.unrealengine.com/u/Travis)\
**Post date:** [May 14, 2024, 11:03pm UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400/1 "2024-05-14T23:03:40Z")

</div>

I’m building a UE5.3 application using UAT BuildCookRun. For Mac, when I try to build a universal binary per the documentation: `-specifiedarchitecture=arm64+x86_6` I get the following build error when a module loads a precompiled library:

`Unable to instantiate module 'CSpice_Library': Asking CppCompileEnvironment for a single Architecture, but it has multiple Architectures (arm64, x64). This indicates logic needs to be updated`

I see what it’s getting at but I can’t find any reference to this error or how I would configure the build for this. I have both x86\_64 and arm64 versions of the library at `lib/Mac/cspice.a` and `lib/Mac/arm/cspice.a` respectively. Here is how the library is selected in its Build.cs:

```auto
public class CSpice_Library : ModuleRules
{
    public CSpice_Library(ReadOnlyTargetRules Target) : base(Target)
    {
        string libFile = CSpiceLibPath(Target);
        ...
    }
    static public string CSpiceLibPath(ReadOnlyTargetRules targetRules)
    {
        string relativePathToCSpiceLib = RelativePathToCSpiceLibraries + targetRules.Platform.ToString();
        string libName = "/cspice.lib";
        
        if (targetRules.Platform == UnrealTargetPlatform.Mac)
        {
            libName = "/cspice.a";
            if (targetRules.Architecture == UnrealArch.Arm64)
            {
                relativePathToCSpiceLib += "/arm";
            }
        }
        ...
        relativePathToCSpiceLib += libName;

        return Path.Combine(targetRules.ProjectFile.Directory.FullName, relativePathToCSpiceLib);
    }

```

This all checks out, but I don’t know how this relates to “asking CppCompileEnvironment for a single architecture”. Is this the logic in question, and how do you configure multiple versions of a library for a universal build?

---

<div class="post-metadata">

**Author:** ![MARUI-PlugIn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marui-plugin/32/88707_2.png) [@MARUI-PlugIn](https://forums.unrealengine.com/u/MARUI-PlugIn)\
**Post date:** [May 27, 2024, 8:54pm UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400/2 "2024-05-27T20:54:13Z")

</div>

Could you find a solution? I’m having the exact same issue when trying to submit a plugin to the Unreal Marketplace: they tell me I need to fix the plugin because it generates the error "Unable to instantiate module ‘YourPlugin’: Asking CppCompileEnvironment for a single Architecture, but it has multiple Architectures (arm64, x64). This indicates logic needs to be updated.  
The strange thing is that they only complain about this for UE 5.4, all previous versions of the Engine apparently work just fine with the exact same .uplugin and .build.cs files.

---

<div class="post-metadata">

**Author:** ![Amneri](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Amneri](https://forums.unrealengine.com/u/Amneri)\
**Post date:** [June 1, 2024, 6:46pm UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400/3 "2024-06-01T18:46:08Z")

</div>

It happens when you call `Target.Architecture` when building for multiple architectures. An exception is thrown when calling the `Architecture` getter in your `Build.cs`.

To check for a single architecture, use `Target.Architectures` (notice the `s`) instead.

```cs
if (Target.Architectures.Contains(UnrealArch.Arm64))
{
    // ARM64, but it can also be x64!
}

```

The reason it happens from 5.4 is because the Marketplace now builds code plugins for Android `arm64+x64` instead of only `arm64`.

---

<div class="post-metadata">

**Author:** ![MARUI-PlugIn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marui-plugin/32/88707_2.png) [@MARUI-PlugIn](https://forums.unrealengine.com/u/MARUI-PlugIn)\
**Post date:** [June 3, 2024, 12:24am UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400/4 "2024-06-03T00:24:42Z")

</div>

Thank you so much! After weeks of trying, this finally solved the issue for me.

---

<div class="post-metadata">

**Author:** ![Travis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Travis](https://forums.unrealengine.com/u/Travis)\
**Post date:** [June 10, 2024, 5:57pm UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400/5 "2024-06-10T17:57:28Z")

</div>

Thank you @Amneri I ultimately had to rewrite the whole function to allow it to add multiple paths, but this was the missing piece.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 10, 2024, 5:58pm UTC](https://forums.unrealengine.com/t/error-loading-a-library-for-mac-universal-build-logic-needs-to-be-updated/1856400/6 "2024-07-10T17:58:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
