realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.27k stars 2.14k forks source link

Can't install realmswift 2.10.1 with cocoapods and xcode 9 #5337

Closed westd closed 6 years ago

westd commented 6 years ago

I upgrade to xcode 9 last night and I tried updating my realmswift pod to be swift 3.2 compatible

Goals

install realm with cocoapods 'pod install --verbose'

Expected Results

pod install finishes successful

Actual Results

-> Installing Realm (2.10.1)

Git download Git download $ /usr/bin/git clone https://github.com/realm/realm-cocoa.git /var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T/d20170924-6578-7tcmvt --template= --single-branch --depth 1 --branch v2.10.1 Cloning into '/var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T/d20170924-6578-7tcmvt'... Note: checking out '76f0f67e59d8ebff0af7b91adfc77056d2135858'.

 You are in 'detached HEAD' state. You can look around, make experimental
 changes and commit them, and you can discard any commits you make in this
 state without impacting any branches by performing another checkout.

 If you want to create a new branch to retain commits you create, you may
 do so (now or later) by using -b with the checkout command again. Example:

   git checkout -b <new-branch-name>

 $ /usr/bin/git -C
 /var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T/d20170924-6578-7tcmvt
 submodule update --init --recursive
 Submodule 'Realm/ObjectStore' (https://github.com/realm/realm-object-store.git) registered for path 'Realm/ObjectStore'
 Cloning into '/private/var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T/d20170924-6578-7tcmvt/Realm/ObjectStore'...
 Submodule path 'Realm/ObjectStore': checked out '4de03a96f86848297c36e89b7e9da49bf8b4d46d'
 Submodule 'external/catch' (https://github.com/philsquared/Catch) registered for path 'Realm/ObjectStore/external/catch'
 Submodule 'external/pegtl' (https://github.com/ColinH/PEGTL) registered for path 'Realm/ObjectStore/external/pegtl'
 Cloning into '/private/var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T/d20170924-6578-7tcmvt/Realm/ObjectStore/external/catch'...
 Cloning into '/private/var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T/d20170924-6578-7tcmvt/Realm/ObjectStore/external/pegtl'...
 Submodule path 'Realm/ObjectStore/external/catch': checked out 'ee67ac6b7c3595251342671485c65cf81d725896'
 Submodule path 'Realm/ObjectStore/external/pegtl': checked out '3c4128a7e7e1288eb746418ea60c41477358f26a'

Running prepare command $ /bin/bash -c set -e sh build.sh cocoapods-setup [!] /bin/bash -c set -e sh build.sh cocoapods-setup

/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/executable.rb:69:in execute_command' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/executable.rb:27:inblock in executable' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_preparer.rb:66:in block (2 levels) in run_prepare_command' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_preparer.rb:60:inchdir' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_preparer.rb:60:in block in run_prepare_command' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:64:insection' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_preparer.rb:59:in run_prepare_command' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_preparer.rb:37:inprepare!' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:202:in copy_and_clean' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:159:inblock (2 levels) in uncached_pod' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:157:in each' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:157:inblock in uncached_pod' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:181:in call' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:181:inin_tmpdir' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:153:in uncached_pod' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader/cache.rb:33:indownload_pod' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/downloader.rb:42:in download' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_installer.rb:120:indownload_source' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer/pod_source_installer.rb:60:in install!' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:364:ininstall_source_of_pod' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:329:in block (2 levels) in install_pod_sources' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:85:intitled_section' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:328:in block in install_pod_sources' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:320:ineach' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:320:in install_pod_sources' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:163:inblock in download_dependencies' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:64:in section' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:161:indownload_dependencies' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:117:in install!' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/command/install.rb:41:inrun' /Library/Ruby/Gems/2.0.0/gems/claide-1.0.2/lib/claide/command.rb:334:in run' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:52:inrun' /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/bin/pod:55:in <top (required)>' /usr/local/bin/pod:23:inload' /usr/local/bin/pod:23:in `

'

Steps to Reproduce

I followed the suggested steps to clear caches several time, but always the result above

pod cache clean Realm pod cache clean RealmSwift pod deintegrate || rm -rf Pods pod install --verbose

Realm framework version: 2.10.1

Realm Object Server version: ?

Xcode version: 9.0

iOS/OSX version: 11

Dependency manager + version: cocoapods 1.3.1

bdash commented 6 years ago

The error looks a lot like what happens when the Realm core library fails to download, which the cache clearing steps you mention should resolve. Have you re-tried since reporting this failure?

Alexander-Foster commented 6 years ago

After updating to High Sierra, it is not installed in the same environment

Version 2.10.0 is fine... 2.10.1 and 3.0.0-beta also something wrong

westd commented 6 years ago

Yes I've tried the cache clearing steps above several times and on 3 different networks, always same result. Is there any other debugging steps I can try? What's the link to the core library it's trying to download so I can see if I'm able to download it from here

westd commented 6 years ago

I'm still using macos Sierra by the way. For me the problem started happening when I upgrade to xcode 9

dungi commented 6 years ago

I have the same issues while building RealmSwift with Carthage and Xcode 9

SlayterDev commented 6 years ago

Same issue. Xcode 9 and latest Realm version.

bdash commented 6 years ago

The sh build.sh cocoapods-setup step downloads Realm's prebuilt core binary from https://static.realm.io/downloads/sync/realm-sync-cocoa-1.10.8.tar.xz. The downloaded file ends up at $TMPDIR/sync_bin/sync-1.10.8.tar.xz. We'll use an existing file at this location in the future to avoid unnecessarily re-downloading the file.

Can someone that's seeing this file check if that downloaded file exists, and if it looks to be a valid file? If you run xxd $TMPDIR/sync_bin/sync-1.10.8.tar.xz | head you should see that the first few bytes of the file are fd37 7a58 5a00 (.7zXZ.). You should also see (using ls -l) that the file is 44827356 bytes in size.

westd commented 6 years ago

this is what I see:

ls -la $TMPDIR/sync_bin/sync-1.10.8.tar.xz ls: /var/folders/ml/2x_8p6kx15q3979kssq7s75h0000gn/T//sync_bin/sync-1.10.8.tar.xz: No such file or directory

The sync_bin directory doesn't exist either

bdash commented 6 years ago

Thanks, so you don't have a stale file causing problems. If you wouldn't mind, can you please try the following steps?

git clone https://github.com/realm/realm-cocoa.git
cd realm-cocoa
sh build.sh download-sync

That'll do the same work to download the sync library as is performed when installing via CocoaPods, but without involving CocoaPods. That'll help to narrow down where the problem is occurring.

westd commented 6 years ago

Davids-MacBook-Pro:dev dwest$ git clone https://github.com/realm/realm-cocoa.git Cloning into 'realm-cocoa'... remote: Counting objects: 74072, done. remote: Compressing objects: 100% (95/95), done. remote: Total 74072 (delta 92), reused 96 (delta 59), pack-reused 73918 Receiving objects: 100% (74072/74072), 50.71 MiB | 792.00 KiB/s, done. Resolving deltas: 100% (51985/51985), done. Davids-MacBook-Pro:dev dwest$ cd realm-cocoa Davids-MacBook-Pro:realm-cocoa dwest$ sh build.sh download-sync Davids-MacBook-Pro:realm-cocoa dwest$

westd commented 6 years ago

There was no output at all from the last line, and it executed immediately (no sign it was trying to do any actual work)

bdash commented 6 years ago

That's very surprising. One of the first things that the download-sync command does is print out what it is doing (Using version of core already in core/ directory / core is not a symlink. Deleting... / The core library seems to be up to date).

Would you mind sharing the output of which sh?

westd commented 6 years ago

Davids-MacBook-Pro:realm-cocoa dwest$ which sh /bin/sh

bdash commented 6 years ago

Ok, that’s what you should see, but it means I don’t have any idea why it’s failing to download the prebuilt binary. Can you please double check whether a core directory was created inside realm-cocoa by your earlier attempt?

westd commented 6 years ago

there doesn't seem to be any core directory:

Davids-MacBook-Pro:realm-cocoa dwest$ ls -la total 528 drwxr-xr-x 32 dwest staff 1088 26 Sep 17:01 . drwxr-xr-x 19 dwest staff 646 26 Sep 17:00 .. -rw-r--r-- 1 dwest staff 227 26 Sep 17:01 .dir-locals.el drwxr-xr-x 12 dwest staff 408 26 Sep 17:01 .git -rw-r--r-- 1 dwest staff 60 26 Sep 17:01 .gitattributes drwxr-xr-x 3 dwest staff 102 26 Sep 17:01 .github -rw-r--r-- 1 dwest staff 1418 26 Sep 17:01 .gitignore -rw-r--r-- 1 dwest staff 130 26 Sep 17:01 .gitmodules -rw-r--r-- 1 dwest staff 10308 26 Sep 17:01 .jenkins.yml -rw-r--r-- 1 dwest staff 519 26 Sep 17:01 .swiftlint.yml -rw-r--r-- 1 dwest staff 1559 26 Sep 17:01 .travis.yml -rw-r--r-- 1 dwest staff 109386 26 Sep 17:01 CHANGELOG.md -rw-r--r-- 1 dwest staff 4487 26 Sep 17:01 CONTRIBUTING.md drwxr-xr-x 3 dwest staff 102 26 Sep 17:01 Carthage drwxr-xr-x 9 dwest staff 306 26 Sep 17:01 Configuration -rw-r--r-- 1 dwest staff 7562 26 Sep 17:01 Jenkinsfile.releasability -rw-r--r-- 1 dwest staff 13657 26 Sep 17:01 LICENSE -rw-r--r-- 1 dwest staff 4256 26 Sep 17:01 README.md drwxr-xr-x 136 dwest staff 4624 26 Sep 17:01 Realm -rw-r--r-- 1 dwest staff 5656 26 Sep 17:01 Realm.podspec drwxr-xr-x 4 dwest staff 136 26 Sep 17:01 Realm.xcodeproj drwxr-xr-x 23 dwest staff 782 26 Sep 17:01 RealmSwift -rw-r--r-- 1 dwest staff 1720 26 Sep 17:01 RealmSwift.podspec -rw-r--r-- 1 dwest staff 1564 26 Sep 17:01 SUPPORT.md -rwxr-xr-x 1 dwest staff 51215 26 Sep 17:01 build.sh -rw-r--r-- 1 dwest staff 100 26 Sep 17:01 dependencies.list drwxr-xr-x 4 dwest staff 136 26 Sep 17:01 docs drwxr-xr-x 7 dwest staff 238 26 Sep 17:01 examples -rw-r--r-- 1 dwest staff 7897 26 Sep 17:01 logo.png drwxr-xr-x 7 dwest staff 238 26 Sep 17:01 plugin drwxr-xr-x 10 dwest staff 340 26 Sep 17:01 scripts drwxr-xr-x 3 dwest staff 102 26 Sep 17:01 tools

glebus commented 6 years ago

Same issue. Xcode 9, Hight Sierra and latest Realm version.

bdash commented 6 years ago

If anyone that's hitting this wouldn't mind spending a few minutes screen sharing with me on Google Hangouts, Skype, or similar, so I can troubleshoot what's going, please drop me a line at mar@realm.io.

westd commented 6 years ago

I sent you an email - we can do it tomorrow some time if you like

kkrawczynski commented 6 years ago

not sure is it related 1:1 but when i use 2.10.1 (Carthage + Xcode 9) then Swift compiler yells that RealmSwift was compiled with Swift 3.1

bdash commented 6 years ago

@kkrawczynski, an issue related to Carthage and Swift versions sounds completely different than the issue being discussed here. Please file a new issue and provide the information requested in the issue template.

bdash commented 6 years ago

I spent a few minutes debugging this on a user's machine. The underlying cause looks to be that our script for detecting which Xcode and Swift version should be used does not correctly handle the currently-selected command-line tools being Xcode's standalone command-line tools (/Library/Developer/CommandLineTools) rather than command-line tools within Xcode itself. Many thanks to Adrian for taking his time to help me look into this.

I'd appreciate some information from others that are seeing this (@westd?), namely the output of xcode-select -p and verification that you're seeing a failure immediately after pod install --verbose runs sh build.sh cocoapods-setup, to help confirm that people are all seeing problems for the same reason.

As an immediate workaround for anyone hitting this issue, you can do sudo xcode-select -s /Applications/Xcode.app to select the command-line tools bundled within Xcode. I'll look to make a more complete fix in Realm.

bdash commented 6 years ago

This should hopefully be fixed in v2.10.2.

westd commented 6 years ago

Is there a work around we can use to get it working before that's released?

bdash commented 6 years ago

v2.10.2 was released a few hours ago. I also mentioned a workaround for v2.10.1 in my earlier comment.

westd commented 6 years ago

Awesome, thanks

glebus commented 6 years ago

@bdash v2.10.2 has solved problem. Thank you!

westd commented 6 years ago

By the way, it didn't work for me 'out of the box', I got this:

Installing Realm (2.10.2) [!] /bin/bash -c set -e sh build.sh cocoapods-setup

WARNING: The active Xcode command line tools, as returned by /Library/Developer/CommandLineTools, are not from Xcode. The newest version of Xcode will be used instead. No version of Xcode could be found

I worked around using your command 'sudo xcode-select -s /Applications/Xcode.app'. Might be an idea to add that command to the error message?

lidkxx commented 6 years ago

@westd sudo xcode-select -s /Applications/Xcode.app is a life saver! ❤️

LeVanTuan commented 6 years ago

@bdash saved my life 💯

Tr736 commented 6 years ago

for me the problem was happening because I have multiple versions of Xcode (to support older swift) by simply ensure Xcode is named Xcode in the applications dir resolved the issue

khirsh commented 6 years ago

@bdash Thanks! This problem just happened to me today. I had multiple versions of Xcode and I renamed them "Xcode 9.2.app" and "Xcode 9.3.app". I wonder if the unusual name of the app created confusion for your script. In any case, your solution worked when I used my unusual name of the app:

sudo xcode-select -s "/Applications/Xcode 9.3.app"

In any case, I just wanted to report that this problem still exists in some edge cases.

parrot88 commented 6 years ago

'sudo xcode-select -s /Applications/Xcode.app', Danke!

amrutsaba commented 5 years ago

Hi All,

I am using realm 2.10.2 version and i have another library using swift4. When I do POD install, it gives error realm.h not found , if i remove this swift library it builds successfully

has anyone facing similar issue or any solution to this?

Thanks Amrut