Closed tisfeng closed 4 years ago
same here. And it also happens at https://github.com/realm/realm-cocoa/issues/6312#issue-509416695
I have just run into this - appears to be a regression: #1449. pod deintegrate, pod install and rebuild appears to temporarily solve this.
@Fawxy @CoSNaYe @tisfeng If you upgraded from a previous version of Realm JS, it can help to remove ios/build
. Actually, when upgrading any library containing C++ code, it is a good idea to clear the build
folder.
@kneth This was on a fresh install and I'm running from Xcode so don't have an ios/build
folder.
I have just run into this - appears to be a regression: #1449. pod deintegrate, pod install and rebuild appears to temporarily solve this.
@Fawxy Thank you, this method does work, but it is only a temporary workaround. . Because I can compile successfully after doing this locally, but I submit these pods changes to the remote repository, and then pull to the local again, I will still encounter the same problem, I need to pod deintegrate, pod install again.
Moreover, this solution is not suitable for multi-person collaboration, my colleagues will still encounter this problem after they git pull.
Thank you anyway, but is there a better solution?
@kneth maybe my problem is not the reason. I have tried deleting the ios / build file and recompiling. Unfortunately, it still reports the same error. Even in a newly created project, npm install --save realm and pod install, will still report this error.
What's more interesting is that sometimes I try to create a new project. The process of installing realm is normal and can compile successfully. But if I submit it to a remote repository, and then create another folder locally, and then git clone from the remote, this will often fail every compilation. It's weird, I'm curious to know why this is the case.
@kneth Because pod deintegrate, pod install does guarantee to solve this problem locally, I guess the problem may be related to realm's pods configuration environment.
Our team has included the pods related files into the Git version management. This way, every time a new commit change is pulled, only npm install is needed, and then it can be compiled and run. Will this development method cause pods configuration problems for third-party libraries like the realm.js ?
Our team has included the pods related files into the Git version management.
@tisfeng if I understand you correctly, you're comitting the projects ios/Pods
directory to your sourcecode repository? As I understand it, there are competing approaches on this - I think https://stackoverflow.com/questions/9446644/what-goes-into-your-gitignore-if-youre-using-cocoapods outlines the pros and cons. Would you be open to considering not doing that, to see if this fixes the issue?
I searched my ios/Pods
directory for absolute paths (which is often the root cause of such an issue) and I found that ios/Pods/Target Support Files/RealmJS/RealmJS.xcconfig
does indeed contain an absolute path. Although this is for the React headers, so if this was the cause of your issue, I would have expected a missing React header, not a missing Realm header.
A fix for this might actually be in the Podspec already, please try:
node_modules/realm/RealmJS.podspec
and remove the comment from line 77 and comment out line 78pod install
and commit + push as you would normally do.@kneth @Fawxy Thanks for your help. I think the pod deintegrate
is the key.
@kraenhansen Thanks for your answer,but I not sure whether you mean modify node_modules/realm/RealmJS.podspec
......
# 👇 could be '"$(PODS_ROOT)/Headers/Public/React-Core/"', but this breaks linting.
"'#{app_path}/ios/Pods/Headers/Public/React-Core'"
to
......
'"$(PODS_ROOT)/Headers/Public/React-Core/"'
# "'#{app_path}/ios/Pods/Headers/Public/React-Core'"
If yes, as above, according to your solution, I tried to do it twice, but I still get an error. I modify node_modules/realm/RealmJS.podspec and then pod install, then commit git push the modified code. After that, I create a new directory, git clone the test branch and then npm install, the compilation still reports the same error as before.
Which of my steps did I do wrong? Or is there another possibility for the cause of this problem?
Which of my steps did I do wrong? Or is there another possibility for the cause of this problem?
I think you're doing what I suggested: Can you verify that ios/Pods/Target Support Files/RealmJS/RealmJS.xcconfig
does not contain absolute paths when its freshly checked out of git?
If that didn't fix the issue, we have to find a minimal way of reproducing your issue: Can you try taking a copy of your project, remove everything which doesn't seem to be causing the issue and push it to a public repository with instructions on how to reproduce the issue.
@kraenhansen I sure this file does't contain absolut paths. This is the content of RealmJS.xcconfig file in my current compilation error project:
CC = $(PODS_TARGET_SRCROOT)/scripts/ccache-clang.sh
CLANG_CXX_LANGUAGE_STANDARD = c++14
CLANG_CXX_LIBRARY = libc++
CLANG_WARN_DOCUMENTATION_COMMENTS = NO
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/RealmJS
CURRENT_PROJECT_VERSION = 3.4.2
CXX = $(PODS_TARGET_SRCROOT)/scripts/ccache-clang++.sh
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/DoubleConversion" "${PODS_ROOT}/Headers/Public/GCDWebServer" "${PODS_ROOT}/Headers/Public/React-Core" "${PODS_ROOT}/Headers/Public/React-DevSupport" "${PODS_ROOT}/Headers/Public/React-RCTActionSheet" "${PODS_ROOT}/Headers/Public/React-RCTAnimation" "${PODS_ROOT}/Headers/Public/React-RCTBlob" "${PODS_ROOT}/Headers/Public/React-RCTImage" "${PODS_ROOT}/Headers/Public/React-RCTLinking" "${PODS_ROOT}/Headers/Public/React-RCTNetwork" "${PODS_ROOT}/Headers/Public/React-RCTSettings" "${PODS_ROOT}/Headers/Public/React-RCTText" "${PODS_ROOT}/Headers/Public/React-RCTVibration" "${PODS_ROOT}/Headers/Public/React-RCTWebSocket" "${PODS_ROOT}/Headers/Public/React-cxxreact" "${PODS_ROOT}/Headers/Public/React-jsi" "${PODS_ROOT}/Headers/Public/React-jsiexecutor" "${PODS_ROOT}/Headers/Public/React-jsinspector" "${PODS_ROOT}/Headers/Public/glog" "${PODS_ROOT}/Headers/Public/yoga" "$(PODS_TARGET_SRCROOT)/src/" "$(PODS_TARGET_SRCROOT)/src/jsc/" "$(PODS_TARGET_SRCROOT)/src/object-store/src/" "$(PODS_TARGET_SRCROOT)/src/object-store/external/json/" "$(PODS_TARGET_SRCROOT)/vendor/" "$(PODS_TARGET_SRCROOT)/vendor/realm-ios/include/" "$(PODS_TARGET_SRCROOT)/react-native/ios/RealmReact/" "$(PODS_ROOT)/Headers/Public/React-Core/"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/../../node_modules/realm
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
VERSIONING_SYSTEM = apple-generic
Is there anything wrong with the contents of this file?
@kraenhansen I have pushed a test demo, can you please take a look https://github.com/tisfeng/RealmTestDemo/tree/realm_test_branch2
@kraenhansen My demo has been uploaded, have you checked and found the problem?
@tisfeng thanks for making a demo. I hope to be able to have a look at it today.
@kraenhansen Thank you very much, I have been troubled by this problem for several days, and I very much hope that it can be completely solved.
I managed to reproduce the error, running npm install
, opening the Xcode workspace and attempt to build. I then cleaned the build directory from Xcode and ran pod install
in the ios
directory and then successfully build the project from XCode. I then got an (unrelated) runtime error running the app in the simulator.
Can you verify that cleaning the build folder and running pod install
in the ios
folder removes the error? And is this a viable fix for you?
Or perhaps I am missing something here - you mentioned earlier that running pod install
fixes the issue temporarily, but once the changes gets committed, pushed and pulled the error re-appears?
BTW what version of XCode are you running?
@kraenhansen Yes, running pod install locally is a temporary workaround. . However, because our group uses Git to manage the entire cocopods file, if another colleague git pulls my commit, ideally, he should be able to compile successfully after executing npm install instead of running pod install again.
So, at the moment, I want to find a thorough solution that will allow my colleague to compile successfully without executing pod install after submitting the push code.
@kraenhansen My Xcode Version 11.2.1 (11B53)
@kraenhansen I also tested Xcode Version 10.1 (10B61), but still reported this error.
Your version of XCode should be fine 👍
Taking my fixed local branch and cloning it locally does indeed seem to bring back the error. One interesting observation is that running pod install
will update the ios/Podfile.lock
although nothing seemingly changed in the RealmJS
pod. I guess it's from the changed paths in the node_modules/realm/package.json
, but that doesn't happen for other pods installed from node_modules
. I'll investigate more.
Okay - I believe I've found the root cause now.
The RealmJS Podspec has a prepare_command which downloads Realm Core (which contains the missing header). When the repository is cloned and pod install
is never called locally, this command is never called and the headers will be missing.
A quick workaround for your project could be adding a postinstall
script to your projects package.json
, running node node_modules/realm/scripts/download-realm.js ios --sync
:
{
"name": "LejuBlock",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"postinstall": "node node_modules/realm/scripts/download-realm.js ios --sync"
},
// ...
}
UPDATE: We've fixed this in the latest version of Realm JS, so there should be no reason to add ☝️ that ..
@kraenhansen Thank you very much for your investigation, this solution solved my problem perfectly!
@tisfeng I'm glad this fixed your immediate issue - thanks for the reproduction and your patience. I have a PR ready with a more permanent fix: https://github.com/realm/realm-js/pull/2623 - once merged and released, I would like for you to remove the "postinstall" script and test it again.
@tisfeng Realm JS v3.6.0 was just released with a fix for your original issue. I would highly appreciate if you tried removing the "postinstall" hack, upgrade Realm JS to the latest version and confirm the fix?
The same goes for anyone else that might have used the "postinstall" fix: @N3TC4T, @froliveira94, @chaeunlee, @protez, @keima (judging from your reactions)
@kraenhansen OK, I will try to upgrade later, but I may not have time to upgrade recently.
After I upgrade, I will inform you after confirming the result. Thank you.
@kraenhansen Thanks, I tried the latest version (v3.6.0) but looks the issue is not fixed or at least not just for me.
Steps:
@N3TC4T Thanks for your comment! Please create an issue on the repository with a link to a repository with the least amount of code that reproduce your issue and instructions on the exact commands to run to get to the error. I would love to get rid of these header related bugs, once and for all.
@kraenhansen I still get the error, currently doing the pod method
@kraenhansen I still get the error, currently doing the
pod method
I don't think I understand what the pod method
is 🙂
@Oba-One I would love to help you get rid of this. The only way for me to make progress is if you create an issue on this repository with a link to a repository with the least amount of code that reproduce your issue and instructions on the exact commands to run to get to the error. Thanks!
Goals
I want to build project successfully
Expected Results
build success
Actual Results
build failed: 'realm/util/assert.hpp' file not found
Steps to Reproduce
npm install --save realm pod install build
Version of Realm and Tooling