1

I am upgrading my project's old framework dependencies to be xcframework files so that I can run on the simulator on my M1 Mac. I'm using Xcode 13.3.1 and the new build system.

When I build my project with a target of a Simulator, I get this build error:

ld: in ../CommonKit/External/AppCenter/AppCenter.xcframework/ios-arm64_arm64e_armv7_armv7s/AppCenter.framework/AppCenter(MSACAppCenter.o), 
building for iOS Simulator, but linking in object file built for iOS, file 
'../CommonKit/External/AppCenter/AppCenter.xcframework/ios-arm64_arm64e_armv7_armv7s/AppCenter.framework/AppCenter'

enter image description here

My understanding of that error is that we are building for the Simulator, so Xcode can't link with a framework built for iOS (non-simulator).

OK fine, so why does Xcode choose the incorrect framework ios-arm64_arm64e_armv7_armv7s in the xcframework? It should choose the correct framework ios-arm64_i386_x86_64-simulator as shown in the folder structure below. How can I make Xcode choose the correct framework for the simulator?

dyoung@Davids-MacBook-Pro AppCenter.xcframework % ls -l
total 8
-rw-r--r--@ 1 dyoung  staff  1917 Jul 14 12:19 Info.plist
drwxr-xr-x@ 3 dyoung  staff    96 Jul 12 17:01 ios-arm64_arm64e_armv7_armv7s
drwxr-xr-x@ 4 dyoung  staff   128 Jul 14 09:52 ios-arm64_i386_x86_64-simulator
drwxr-xr-x@ 3 dyoung  staff    96 Jul 12 17:01 ios-arm64_x86_64-maccatalyst
drwxr-xr-x@ 3 dyoung  staff    96 Jul 12 17:01 macos-arm64_x86_64

The xcframework Info.plist looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>AvailableLibraries</key>
    <array>
        <dict>
            <key>LibraryIdentifier</key>
            <string>macos-arm64_x86_64</string>
            <key>LibraryPath</key>
            <string>AppCenter.framework</string>
            <key>SupportedArchitectures</key>
            <array>
                <string>arm64</string>
                <string>x86_64</string>
            </array>
            <key>SupportedPlatform</key>
            <string>macos</string>
        </dict>
        <dict>
            <key>LibraryIdentifier</key>
            <string>ios-arm64_x86_64-maccatalyst</string>
            <key>LibraryPath</key>
            <string>AppCenter.framework</string>
            <key>SupportedArchitectures</key>
            <array>
                <string>arm64</string>
                <string>x86_64</string>
            </array>
            <key>SupportedPlatform</key>
            <string>ios</string>
            <key>SupportedPlatformVariant</key>
            <string>maccatalyst</string>
        </dict>
        <dict>
            <key>LibraryIdentifier</key>
            <string>ios-arm64_i386_x86_64-simulator</string>
            <key>LibraryPath</key>
            <string>AppCenter.framework</string>
            <key>SupportedArchitectures</key>
            <array>
                <string>arm64</string>
                <string>i386</string>
                <string>x86_64</string>
            </array>
            <key>SupportedPlatform</key>
            <string>ios</string>
            <key>SupportedPlatformVariant</key>
            <string>simulator</string>
        </dict>
        <dict>
            <key>LibraryIdentifier</key>
            <string>ios-arm64_arm64e_armv7_armv7s</string>
            <key>LibraryPath</key>
            <string>AppCenter.framework</string>
            <key>SupportedArchitectures</key>
            <array>
                <string>arm64</string>
                <string>arm64e</string>
                <string>armv7</string>
                <string>armv7s</string>
            </array>
            <key>SupportedPlatform</key>
            <string>ios</string>
        </dict>
    </array>
    <key>CFBundlePackageType</key>
    <string>XFWK</string>
    <key>XCFrameworkFormatVersion</key>
    <string>1.0</string>
</dict>
</plist>
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Have you managed to solve this issue? I have almost similar case, and from this post https://developer.apple.com/forums/thread/673387 I assume that `.a` libraries provided for the xcframework has wrong platform set. – AlKir Nov 11 '22 at 16:57
  • 1
    I got around the problem by excluding architectures for build variants as described here: https://stackoverflow.com/a/65307593/1461050 I consider this a workaround not a real solution, because I don't think Xcode is supposed to work this way. Why should I have to make that exclusion rule? XCFrameworks are supposed to solve this problem. BTW, I used `lipo` to check the architectures of each of the .a files and they all looked correct to me. – davidgyoung Nov 11 '22 at 17:57
  • In my case I'm building library from command line using `clang` and providing additional parameter `-target arm64-apple-ios13.0-simulator` solved my issue. – AlKir Nov 14 '22 at 11:39

0 Answers0