Realm-cocoa: Using RealmSwift.NotificationToken type when RealmSwift acts as a dependency fails CocoaPods lib lint validation

Created on 23 Sep 2020  路  13Comments  路  Source: realm/realm-cocoa

Goals

Use RealmSwift as a dependency for CocoaPod in Xcode 12. Not sure when this started happening, as this integration was working for couple of years without any issues.

Expected Results

When using RealmSwift as a dependency, pod lib validation should succeed.

Actual Results

Pod lib lint returns undefined symbols error:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RLMNotificationToken"

Steps for others to Reproduce

  1. Clone https://github.com/DenTelezhkin/DTModelStorage, branch cocoapods-enable-realm
  2. Run bundle exec pod lib lint --allow-warnings --no-clean --verbose
  3. Observe build failures.

Code Sample

Attaching CocoaPods-generated project that failed pod lib lint validation for easier debugging:

CocoaPods-Lint-20200923-61087-vg31ow-DTModelStorage.zip

Also build failure can be observed on CI:

https://github.com/DenTelezhkin/DTModelStorage/runs/1154609764?check_suite_focus=true

It seems, that the only issue is with RLMNotificationToken type, because if the code referencing this type is commented out, build succeeds.

Version of Realm and Tooling

Xcode 12
CocoaPods 1.10.0.beta.2
Realm 5.3.5
RealmCore 6.0.19

O-Community

Most helpful comment

Looks like we need to add Realm to podspec file:

s.dependency "Realm"

Otherwise your target will not depend on Realm despite RealmSwift has dependency on Realm:

Looks like coocapods bug.

For example:

Target dependencies in Pods project with implicit Realm dependency:

Screenshot 2020-11-25 at 14 30 47
Screenshot 2020-11-25 at 14 30 57

Target dependencies in Pods project with explicit Realm dependency:

Screenshot 2020-11-25 at 14 38 54
Screenshot 2020-11-25 at 14 39 19

All 13 comments

Having the same issue here.

Screenshot 2020-09-25 at 09 26 55

Xcode 12
Cocoapods 1.9.3
Realm 5.4.3

Seeing the exact same issue here as @mentrena, exact same specs he listed.

facing exact issue here as well... any fixes?

Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_RLMNotificationToken", referenced from:
objc-class-ref in RxRealm.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

+1

Hi,

We are facing the same issue as well.
Xcode 12
Cocoapods 1.9.3
Realm 5.5.0

Is there any kind of update?

Thanks,
Nilit

And still facing this issue on:
Xcode 12.0.1
Cocoapods 1.9.3
Realm 10.0.0

Hi,
I'm facing this issue as well. My environment is:
Xcode 12.1
Cocoapods 1.10.0
Realm 5.5.0

@andreadelfante pod lib lint --allow-warnings passes for me using Realm Cocoa 10.1.1 & Cocoapods 1.10

Xcode 12.1
Cocoapods 1.10.0
RealmSwift 10.1.2

Cocoapods still fails to validate.

Steps:

  • Clone pod repository: https://github.com/mentrena/SyncKit
  • Run pod lib lint SyncKit.podspec --subspec=RealmSwift --no-clean
  • Validation fails. The Cocoapods generated project can be inspected and these are the build errors:
Undefined symbols for architecture x86_64:
  "_RLMRealmPathForFile"
"_OBJC_CLASS_$_RLMNotificationToken"
"_OBJC_CLASS_$_RealmSwiftObject"
"_OBJC_METACLASS_$_RealmSwiftObject"

Same issue with Xcode 12.2 cocoa pods 1.10

What I discovered is that when building with the no-clean option and opening the generated App.xcworkspace First compilation will fail as well, it will however succeed when tried another time, this time with cleared derived data. Does not help because pod lib lint will still always fail but maybe it helps with debugging

I am also getting the same error for RealmSwiftObject

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RealmSwiftObject"

Looks like we need to add Realm to podspec file:

s.dependency "Realm"

Otherwise your target will not depend on Realm despite RealmSwift has dependency on Realm:

Looks like coocapods bug.

For example:

Target dependencies in Pods project with implicit Realm dependency:

Screenshot 2020-11-25 at 14 30 47
Screenshot 2020-11-25 at 14 30 57

Target dependencies in Pods project with explicit Realm dependency:

Screenshot 2020-11-25 at 14 38 54
Screenshot 2020-11-25 at 14 39 19

This totally fixed this issue for me, thanks @petropavel13! Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

menhui222 picture menhui222  路  3Comments

javierjulio picture javierjulio  路  3Comments

ishidakei picture ishidakei  路  3Comments

carvalho-oak picture carvalho-oak  路  3Comments

dennisgec picture dennisgec  路  3Comments