Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealmSwift and Realm Problems #57

Closed
3 tasks done
savage7 opened this issue Jan 18, 2021 · 9 comments
Closed
3 tasks done

RealmSwift and Realm Problems #57

savage7 opened this issue Jan 18, 2021 · 9 comments

Comments

@savage7
Copy link

savage7 commented Jan 18, 2021

Checklist

Issue Description

"bundle exec pod binary prebuild" correctly build the frameworks for Realm and RealmSwift.
However when I open the app project and build it I get " nclude of non-modular header inside framework module" errors.
I've about 40 other pods, all of them work.

I've found these issues:
#51
--> I'm on the newest version already. 10.5.1

#24
I tried this:
config.build_settings["CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES"] = "YES"
Doesn't seam to have any impact.

Did anyone succeed in using Realm with this plugin? If yes could you please share your solution?

Showing All Messages
/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:21:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMArray.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:22:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMDecimal128.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:23:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMEmbeddedObject.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:24:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMMigration.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:25:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMObject.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:26:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMObjectId.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:27:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMObjectSchema.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:28:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMPlatform.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:29:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMProperty.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:30:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMProviderClient.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:31:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMRealm+Sync.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:32:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMRealm.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:33:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMRealmConfiguration+Sync.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:34:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMRealmConfiguration.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:35:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMResults.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:36:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMSchema.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:38:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMApp.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:39:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMCredentials.h'

/Users/dummy_user/Library/Developer/Xcode/DerivedData/app-bsailbcgwgmcjhaaxuaaycmoobwx/Build/Products/Production Debug-iphonesimulator/XCFrameworkIntermediates/Realm/Realm.framework/Headers/Realm.h:40:9: Include of non-modular header inside framework module 'Realm': 'dummy_path_ios/Pods/Headers/Public/Realm/RLMNetworkTransport.h'

Too many errors emitted, stopping now

Could not build Objective-C module 'Realm'

Environment

Plugin version

Plugin version b18577b

Installed CocoaPods plugins

- cocoapods-binary-cache : 0.1.11 (pre_install and post_install hooks)
- cocoapods-deintegrate  : 1.0.4
- cocoapods-plugins      : 1.0.0
- cocoapods-search       : 1.0.0
- cocoapods-trunk        : 1.5.0
- cocoapods-try          : 1.2.0
@trinhngocthuyen
Copy link
Contributor

I believe it's a duplicate of the issue in this comment #31 (comment)

@savage7
Copy link
Author

savage7 commented Jan 27, 2021

I tested several things.

  • Created new XCode projects
  • Used existing projects
  • Added the compiler options described in the other tickets (CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES)

Nothing was successful.

What "worked":

  • Remove any "import RealmSwift" in the app code
  • Build the app
  • It fails because it cannot find Realm
  • add the import again
  • build again (no rebuild)
  • it works

It also works when cleaned but:

  • when i delete the derived data the error appears again

I'm not really sure how Xcode handles this, but my assumption is that in "ModuleCache.noindex" Realm exists after rebuilding without including it. When deleting this cache it fails again.

I also tried changing the "Compilation mode" from den default incremental to whole module, this didn't solve the issue.

@savage7
Copy link
Author

savage7 commented Jan 27, 2021

I was not able to use this with this plugin for this.

I ended up with this solution:

  • build RealmSwift myself with library evolution enabled, the current provided binary from Realm does not include this.
  • don't use the Pod but integrate die xcframework for Realm and RealmSwift manually in the XCode project

@sskjames
Copy link

sskjames commented Feb 9, 2021

I was not able to use this with this plugin for this.

I ended up with this solution:

* build RealmSwift myself with library evolution enabled, the current provided binary from Realm does not include this.

* don't use the Pod but integrate die xcframework for Realm and RealmSwift manually in the XCode project

I'm facing this error too. Sorry, I'm new to all of this and I don't understand the solution quoted above. Any update on this?

@savage7
Copy link
Author

savage7 commented Feb 9, 2021

@sskjames
I didn't solve this issue with the plugin.
I prebuilt Realm myself and created two "binary podspecs" which overwrite the normal Realm and RealmSwift Pods.

Build Realm:

  1. Download the source code https://github.com/realm/realm-cocoa/releases/tag/v10.5.1
  2. Open realm-cocoa-10.5.1/Configuration/RealmSwift/RealmSwift.xcconfig
  3. set BUILD_LIBRARY_FOR_DISTRIBUTION to YES
  4. call the build.sh script: build.sh xcframework ios
  5. Host the build binaries somwhere in a git repo or file share
  6. Create a binary podspec
  7. Pin Realm and RealmSwift to these podspecs

Step 6 and 7 are described in more detail here:
I described how you can create the podspecs here #62

@sskjames
Copy link

Hi @savage7, thank you very much for the detailed explanation.
@trinhngocthuyen, is there a possibility to address this in cocoapods-binary-cache?

@cnadeau
Copy link

cnadeau commented Feb 22, 2021

follow up on @sskjames question:

How come setting the library evolution flag in the post install for realm/realmswift for prebuild did not produce the same result?

@trinhngocthuyen: Would it be possible to use prebuild_code_gen to create a binary podspec that sets the vendored framework as suggested by @savage7 in his workaround, have is compressed within the prebuilt zip file and make it available for the Podfile?

Thanks @savage7 and @trinhngocthuyen for your previous detailed answers

@dcacenabes
Copy link

dcacenabes commented Jul 29, 2021

@sskjames
I didn't solve this issue with the plugin.
I prebuilt Realm myself and created two "binary podspecs" which overwrite the normal Realm and RealmSwift Pods.

Build Realm:

  1. Download the source code https://github.com/realm/realm-cocoa/releases/tag/v10.5.1
  2. Open realm-cocoa-10.5.1/Configuration/RealmSwift/RealmSwift.xcconfig
  3. set BUILD_LIBRARY_FOR_DISTRIBUTION to YES
  4. call the build.sh script: build.sh xcframework ios
  5. Host the build binaries somwhere in a git repo or file share
  6. Create a binary podspec
  7. Pin Realm and RealmSwift to these podspecs

Step 6 and 7 are described in more detail here:
I described how you can create the podspecs here #62

I have been trying this approach, I thought I got it working, but I was wrong. I think there is a bug in realm project and reported it in their Github issues page.. I set BUILD_LIBRARY_FOR_DISTRIBUTION to yes and call the build script, and published this as my own pod. This worked like a charm until I bumped to Xcode 13 beta. At that point, I get the error:

Showing Recent Messages
Failed to build module 'RealmSwift'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.20.104 clang-1300.0.21.1)'). Please select a toolchain which matches the SDK.

So it looks like even Realm was built with BUILD_LIBRARY_FOR_DISTRIBUTION set to YES, it can not be used with a different compiler version :(

@rgmyyw
Copy link

rgmyyw commented Nov 27, 2023

The problem still exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants