Installing RealmSwift on an Intel mac installs different librealm-monorepo.a binary than when installed on an M1 Mac

I tried to upgrade the version of RealmSwift in a project from 4.4.1 to 10.30.0 on my Intel mac.

It compiles locally on my machine, but on a CI machine that is also an M1 mac, I get this error:

⚠️  ld: ignoring file /Users/jenkins/builds/gvx3QBW3/0/gc.com/odyssey/DerivedData/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/Realm/librealm-monorepo.a, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x76 0x65 0x72 0x73 0x69 0x6F 0x6E 0x20 0x68 0x74 0x74 0x70 0x73 0x3A 0x2F 0x2F )
❌  Undefined symbols for architecture x86_64
> Symbol: realm::ArrayMixed::init_from_mem(realm::MemRef)
> Referenced from: realm::BPlusTree<realm::Mixed>::cache_leaf(realm::MemRef) in RLMQueryUtil.o
❌  ld: symbol(s) not found for architecture x86_64
❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)

However, doing the same upgrade on an M1 mac and pushing to CI makes it compile successfully in CI.

I did a git diff against two branches where the upgrades were done on separate machines, and I see this:

This seems to be telling me that the binaries are different. I’m curious why this is happening and/or if I’m misinterpreting what’s happening. Are the binaries actually different? Why? And if so, what is CocoaPods doing differently in the bundle exec pod install when it’s done on an Intel vs M1 mac?

@atecle Welcome to the forums…

Stretching my memory here a bit but I don’t think you can go from 4.x to 10.x directly. The underlying file format was changed after 5 (?) and you’ll need to let Realm Studio upgrade the file(s).

Yes, the compiled binaries are different - are you attempting to build for the same iPhone on both the Intel as M1 Macs? Do they both have the current version of cocoapods installed? 1.11.3 at the moment.

What does your podfile look like?

Hi @Jay - thanks for the reply and for the welcome :slight_smile:

Stretching my memory here a bit but I don’t think you can go from 4.x to 10.x directly. The underlying file format was changed after 5 (?) and you’ll need to let Realm Studio upgrade the file(s).

I actually didn’t have any apparent issue with my Realm file created in 4.4.1 and migrating to 10.31.0. If there was a file format related issue, should I expect a crash on start up? Or would there be other issues? Everything seemed peachy - so not sure if there’s some failure path I’m missing.

Yes, the compiled binaries are different - are you attempting to build for the same iPhone on both the Intel as M1 Macs? Do they both have the current version of cocoapods installed? 1.11.3 at the moment.

I can confirm the same Cocoapods version was used , 1.11.3, but I think I was targeting a different simulator. On the Intel mac it was an iPhone 13 Pro on iOS 16 I believe, and the on the M1 it was an iPhone 12 running iOS 15.2.

Could you help me understand why those compiled binaries are different? The Realm library ships with those compiled binaries, so I was curious how those differences come to be? I guess I might be operating on the wrong assumption that what you get from a pod install doesn’t depend on the architecture of your system/what iPhone you’re building to - but just the version of the library you’re installing?

Not sure how helpful this is, but here’s a sketch of what the Podfile looks like (not sharing in full since it’s an employer’s), let me know if there’s anything in particular I could share that would be helpful:

target 'main' do 
# realmswift and other pods
    target 'main_tests' do 
        inherit_search_paths!
        some_test_pods
    end

## not exactly the source, there are some conditions i'm not including
 post_install do |installer|
        installer.pods_project.targets.each do |target|
           target.build_configurations.each do |config|
                config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
                config.build_settings['ENABLE_BITCODE'] = 'NO'
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
            end
        end

        installer.generated_projects.each do |project|
            project.targets.each do |target|
                target.build_configurations.each do |config|
                    config.build_settings['DEVELOPMENT_TEAM'] = 'dev_team'
                end
            end
        end
    end
end

# a bunch of abstract targets

Hmm. I was expecting a podfile more close to the documentation - was looking for other dependencies and pods/versions

platform :ios, 'xx.0'
target 'MyRealmProject' do
  use_frameworks!
  pod 'RealmSwift', '~>10'
end

There were a LOT of changes going from 4.x to 10.x, with many depreciations and implementation differences. I am surprised it went smoothy, but that’s good to hear!

It seems like there’s some kind of version difference - are you using the same verisons of XCode? Also, that derived data looks wonky… did you try removing it?

rm -rf ~/Library/Developer/Xcode/DerivedData

Also, have you done any changes to the build-in Ruby? Probably not related but more data will help narrow the issue.