realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

Xcode 14 beta fails when archive watchOS Target with Realm v10.28.2

Open jordimele opened this issue 2 years ago • 17 comments

How frequently does the bug occur?

All the time

Description

Hello,

I have a simple test application, in which I have created an iOS target and a watchOS target. There is no implementation, just Realm dependency injection with cocoapods (podfile).

The two targets compile without problems, but when I'm about to make Archive, with the watchOS target it always fails.

Realm_Error

Stacktrace & log output

ld: library not found for -lrealm-monorepo
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Can you reproduce the bug?

Yes, always

Reproduction Steps

Podfile app sample that archive watch crash:

Realm_error_podfile
  • Build iOS Target -> OK
  • Build watchOS Target -> OK
  • Archive watchOS target -> KO

Version

10.28.2

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

watchOS

Build environment

Xcode 14 beta 3 Cocoapods 1.11.3 RealmSwift 10.28.2 macOS Monterey 12.4

jordimele avatar Jul 08 '22 12:07 jordimele

Hi @jordimele It seems like you can reproduce this on your side, can you please create a repo so we are able to diagnose the issue.

dianaafanador3 avatar Jul 08 '22 14:07 dianaafanador3

Hello @dianaafanador3, here I leave the example repo; It would only be necessary to perform a pod update, because the Pods folder is not uploaded.

jordimele avatar Jul 11 '22 07:07 jordimele

@tgoyne is this related to the recent changes in core for been able to build target watchOS?, or could be something different. The issue seems to be that it cannot find librealm-monorepo for architecture armv7k even though it exist on the xcframewok.

dianaafanador3 avatar Jul 11 '22 08:07 dianaafanador3

I believe there is a new arm64 arch for Apple Watch since Xcode 14. The librealm-monorepo is pre-built so it does not contains that arch, which causes the link error.

image

gongzhang avatar Jul 20 '22 04:07 gongzhang

Hello,

Is there a solution to the problem in the Archive with watchOS (library not found for -lrealm-monorepo), Realm 10.28.2 and Xcode 14 beta 3?

Thank you

jordimele avatar Jul 26 '22 06:07 jordimele

After performing the same test with the new version of RealmSwift 10.28.3 and Xcode 14 beta 4, when performing an Archive with watchOS, the error persists:

Captura de pantalla 2022-07-28 a les 7 31 08

ld: library not found for -lrealm-monorepo clang: error: linker command failed with exit code 1 (use -v to see invocation)

The Build works correctly, but the Archive process is the one that fails.

jordimele avatar Jul 28 '22 10:07 jordimele

Me too. This version does not upgraded the realm-core. I tried to build the latest core by myself, but I failed. Still waiting for the next version. 🥲

gongzhang avatar Jul 29 '22 02:07 gongzhang

Hello,

the issue in the Archive with watchOS (library not found for -lrealm-monorepo), with RealmSwift version 10.28.6 and Xcode 14 beta 6 (14A5294g) is resolved.

The problem is that in RealmSwift version 10.28.6, https://github.com/realm/realm-swift/releases/tag/v10.28.6, when downloading the realm-swift-10.28.6.zip file , there is no folder for Xcode 14 with the .xcframeworks (it is only found for 13.1, 13.2.1, 13.3.1 and 13.4.1), so it is decided to use the source code of the realm Source code version (zip) and create the xcframeworks for each platform with Xcode 14 beta 6 (14A5294g).

Realm's own source script (build.sh) is used, but when trying to build the xcframework for watchOS, the script fails:

  • ./build.sh xcframework ios --> OK
  • ./build.sh xcframework tvos --> OK
  • ./build.sh xcframework watchos --> KO

Ld /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/Realm.build/Release-watchos/Realm.build/Objects-normal/arm64/Binary/Realm normal arm64 (in target 'Realm' from project 'Realm') cd /Users/jmele/Downloads/realm-swift-10.28.6-source /Applications/Xcode-beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-watchos4.0 -dynamiclib -isysroot /Applications/Xcode-beta6.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS9.0.sdk -L/Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/EagerLinkingTBDs -L/Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Products/Release-watchos -F/Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/EagerLinkingTBDs -F/Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Products/Release-watchos -filelist /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/Realm.build/Release-watchos/Realm.build/Objects-normal/arm64/Realm.LinkFileList -install_name @rpath/Realm.framework/Realm -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/Realm.build/Release-watchos/Realm.build/Objects-normal/arm64/Realm_lto.o -fembed-bitcode -Xlinker -bitcode_verify -Xlinker -bitcode_hide_symbols -Xlinker -bitcode_symbol_map -Xlinker /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Products/Release-watchos -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -fapplication-extension -lcompression -lz -lrealm-monorepo -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/Realm.build/Release-watchos/Realm.build/Objects-normal/arm64/Realm_dependency_info.dat -o /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/Realm.build/Release-watchos/Realm.build/Objects-normal/arm64/Binary/Realm ld: '/Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Products/Release-watchos/librealm-monorepo.a(array_mixed.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed: Ld /Users/jmele/Downloads/realm-swift-10.28.6-source/build/DerivedData/Realm/Build/Intermediates.noindex/Realm.build/Release-watchos/Realm.build/Objects-normal/arm64/Binary/Realm normal arm64 (in target 'Realm' from project 'Realm') (1 failure)

Is it known when the problem will be solved or when the official Realm source code (.xcframeworks) for xcode14 will exist?

Thank you

jordimele avatar Aug 31 '22 07:08 jordimele

@jordimele from version 10.28.7, we now package the .xcframeworks for Xcode 14. I'm closing this issue as everything seems to be fixed now

dianaafanador3 avatar Sep 07 '22 10:09 dianaafanador3

@dianaafanador3 This appears to be an issue still when using SPM and building for iOS, I just tried with v10.28.7

theolampert avatar Sep 09 '22 09:09 theolampert

Xcode 14 RC (Build 14A309) Cocoapods 1.11.3 macOS Monterey 12.5.1 Realm 10.28.7

Hello,

When using the xcframeworks of version 10.28.7, downloaded from the source, the compilation of a project fails:

/Users/jmele/Downloads/PEPE_TEST/PEPE_TEST/ViewController.swift:10:8: error: compiled module was created by an older version of the compiler; rebuild 'RealmSwift' and try again: /Users/jmele/Library/Developer/Xcode/DerivedData/PEPE_TEST-adeupbewgctcgzbnhbergeinsjck/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/RealmBinary/RealmSwift.framework/Modules/RealmSwift.swiftmodule/arm64-apple -ios.swiftmodule
import RealmSwift

Realm's own source script (build.sh) is used to build new xcframework with Xcode 14 RV:

./build.sh xcframework ios --> OK ./build.sh xcframework tvos --> OK ./build.sh xcframework watchos --> OK

But when trying to make a file, it fails:

ld: library not found for -lrealm-monorepo

Captura de pantalla 2022-09-09 a les 15 14 23

@dianaafanador3 any idea about the problem? Is it known if a new version will be released, correcting the problem with the xcframeworks or if the current version (10.28.7) will be modified?

Thank you

jordimele avatar Sep 09 '22 13:09 jordimele

Seems like this is not solved in 10.28.7, a new release will be released shortly which includes the xcframework build with Xcode 14 RC

dianaafanador3 avatar Sep 09 '22 13:09 dianaafanador3

Thanks for quick answer. We are waiting for your news or a new release.

jordimele avatar Sep 09 '22 13:09 jordimele

@jordimele we just released a few days ago a new release, can you check if you are still getting the error when archiving.

dianaafanador3 avatar Sep 13 '22 10:09 dianaafanador3

@dianaafanador3 same issue unfortunately

Realm.o' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.

theolampert avatar Sep 13 '22 11:09 theolampert

Hi @theolampert which version of Xcode are you using?, From Xcode 14, bitcode is been deprecated and the App Store no longer accepts bitcode submissions from Xcode 14. Do you have a project with bitcode enabled?, Please update your project settings to disable bitcode.

dianaafanador3 avatar Sep 13 '22 15:09 dianaafanador3

@dianaafanador3 Sorry I missed the deprecation and didn't notice this was a different issue! Feel free to close, project builds fine now.

theolampert avatar Sep 13 '22 19:09 theolampert