objectbox / objectbox-c

C and C++ database for objects and structs
https://objectbox.io/
Apache License 2.0
211 stars 37 forks source link

support Apple M1 Silicon #10

Closed jochendev closed 3 years ago

jochendev commented 3 years ago

bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)

Base config: OS Darwin and arch arm64 Adjusted OS to Macos Using configuration Macos::arm64 Error: the platform configuration Macos::arm64 is unsupported. You can select the configuration manually (use --help for details) Possible values are:

vaind commented 3 years ago

I'm taking this to the objectbox-c project, where the library needs to be provided. Should then "just work" within objectbox-dart without further changes.

vaind commented 3 years ago

The just released C-API 0.13 adds Apple Silicon support. Can you please try again? The same install script from dart should work

jochendev commented 3 years ago
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
Base config: OS Darwin and architecture arm64
Adjusted OS to MacOS and architecture to universal
Using configuration macos-universal
Resolved URL: https://github.com/objectbox/objectbox-c/releases/download/v0.13.0/objectbox-macos-universal.zip
Downloading ObjectBox library version v0.13.0 for macos-universal...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   637  100   637    0     0    288      0  0:00:02  0:00:02 --:--:--   288
100  782k  100  782k    0     0   113k      0  0:00:06  0:00:06 --:--:--  223k
Downloaded:
836K    download/objectbox-0.13.0-macos-universal.zip

Extracting into download/objectbox-0.13.0-macos-universal...
Archive:  download/objectbox-0.13.0-macos-universal.zip
   creating: download/objectbox-0.13.0-macos-universal/include/
  inflating: download/objectbox-0.13.0-macos-universal/include/objectbox-sync.h
  inflating: download/objectbox-0.13.0-macos-universal/include/objectbox-sync.hpp
  inflating: download/objectbox-0.13.0-macos-universal/include/objectbox.h
  inflating: download/objectbox-0.13.0-macos-universal/include/objectbox.hpp
   creating: download/objectbox-0.13.0-macos-universal/lib/
  inflating: download/objectbox-0.13.0-macos-universal/lib/libobjectbox.dylib
Copied to /usr/local/lib/lib:
total 3936
-rwxr-xr-x  1 jochen  wheel  2011344  3 18 22:01 libobjectbox.dylib
OK. Do you want to install the library into /usr/local/lib? [Y/n] Y
Installing /usr/local/lib/libobjectbox.dylib
Password:
Installed objectbox libraries:
-rwxr-xr-x  1 root    wheel   1.9M  3 18 22:02 /usr/local/lib/libobjectbox.dylib
-rwxr-xr-x  1 jochen  wheel   1.9M  3 18 22:01 libobjectbox.dylib

The download was successful, but it seems to have got a new error

flutter: E -> Exception: Invalid argument(s): Failed to load dynamic library (dlopen(/usr/local/lib/libobjectbox.dylib, 1): no suitable image found.  Did find:
    file system sandbox blocked open() of '/usr/local/lib/libobjectbox.dylib')
flutter: E -> Exception: #0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:55)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:20:12)
vaind commented 3 years ago

Could you please verify this isn't something flutter-specific (I've found some issues with this error text) by running tests in the objectbox-dart repo?

pub --version
git clone https://github.com/objectbox/objectbox-dart.git
cd objectbox-dart/objectbox
pub get
pub run build_runner build
pub run test

I hope to see 00:08 +98: All tests passed! at the end :)

vaind commented 3 years ago

If that works, I guess we'll need to do some changes to support Flutter Desktop for MacOS. There's an issue for that in objectbox-dart: https://github.com/objectbox/objectbox-dart/issues/166

jochendev commented 3 years ago
 flutter pub run test

......
00:12 +98: All tests passed!
vaind commented 3 years ago

OK, it's good to hear that it works in general, let's figure out flutter-desktop distribution issues for MacOS in the issue I've linked in my previous comment.

vaind commented 3 years ago

From objectbox-c point of view, the distributed library seems to work fine.

greenrobot commented 3 years ago

@jochendev PS.: there's another test for M1 assuming you have Xcode and Cocoapods... Checkout https://github.com/objectbox/objectbox-swift-integration-test and run ./test.sh -v 1.5.0-rc2 in the project's folder.

jochendev commented 3 years ago

./test.sh -v 1.5.0-rc2

Invoking projects using args: -v "1.5.0-rc2" -s ""
=========================================================================
Building integration test project 'IntTestiOSEmpty'
=========================================================================
Using version: 1.5.0-rc2
Detected CocoaPods version 1.10.1
Updating local specs repositories

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command

/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod install --repo-update


### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

CocoaPods : 1.10.1 Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20] RubyGems : 3.2.3 Host : macOS 11.2.3 (20D91) Xcode : 12.4 (12D4e) Git : git version 2.24.3 (Apple Git-128) Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib Repositories : master - git - https://github.com/CocoaPods/Specs.git @ d8fb701e923847a2057e4395b9ee4d932fec51d8

           trunk - CDN - https://cdn.cocoapods.org/

### Plugins

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


### Podfile

```ruby
# Uncomment the next line to define a global platform for your project
  # platform :ios, '9.0'

target 'IntTestiOSEmpty' do
    use_frameworks!

    # Pods for IntTestiOSEmpty
  pod 'ObjectBox', '1.5.0-rc2'

  end

Error

LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:78:in `deprecated_local_podspecs'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:60:in `preheat_existing_files'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:257:in `update'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:135:in `block (3 levels) in update'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:134:in `block (2 levels) in update'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:133:in `each'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:133:in `block in update'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:131:in `open'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:131:in `update'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:145:in `block in update_repositories'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:143:in `each'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:143:in `update_repositories'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:235:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:234:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `load'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `<main>'

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours: https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+missing+compatible+arch+in+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues

If none exists, create a ticket, with the template displayed above, on: https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket: https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...

and 5 more at: https://github.com/cocoapods/cocoapods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%2C%200x0009%29%3A%20missing%20compatible%20arch%20in%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%20-%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues&utf8=✓

jochendev commented 3 years ago

Test is succeeded when i run arch -x86_64 ./test.sh -v 1.5.0-rc2

** TEST SUCCEEDED **

    _
 _ //  ALL DONE (2021年 3月21日 星期日 22时30分58秒 CST)
 \X/
jochendev commented 3 years ago

@greenrobot This error is similar to CocoaPods #10287.

jochendev commented 3 years ago

Is there any way to work on M1? @vaind @greenrobot

greenrobot commented 3 years ago

@jochendev Please check https://github.com/objectbox/objectbox-c/releases/tag/v0.14.0 for the latest C release.

vaind commented 3 years ago

I think this was about flutter originally... the next release (objectbox-dart v0.15.0) will bundle native library for desktop platforms the same way it does for mobile. There's, however, an outstanding issue with permissions. See my comment here: https://github.com/objectbox/objectbox-dart/issues/166#issuecomment-832822701