objectbox / objectbox-swift

Swift database - fast, simple and lightweight (iOS, macOS)
https://swift.objectbox.io
Apache License 2.0
423 stars 30 forks source link

Crash at launch after upgrading to 1.4 #45

Open thanhhai08sk opened 3 years ago

thanhhai08sk commented 3 years ago

Describe the bug I was using 1.3.1 but then encounter the issue "Could not open env for DB (12)". I try to upgrade to 1.4.1 and 1.4.0 but the app crash at launch with:

dyld: symbol '_$s9ObjectBox13EntityBindingP09generatorD7VersionSiyFTq' not found, expected in '/private/var/containers/Bundle/Application/4D3A6114-9D36-4C10-856E-9FD825083863/Journal it!.app/Frameworks/ObjectBox.framework/ObjectBox', needed by '/private/var/containers/Bundle/Application/4D3A6114-9D36-4C10-856E-9FD825083863/Journal it!.app/Frameworks/CoreIOS.framework/CoreIOS'

ObjectBox is used in the common module CoreIOS. The generator script seems to work: "$PODS_ROOT/ObjectBox/generate_sources.sh" -- --output "$PROJECT_DIR/generated/EntityInfo-CoreIOS.generated.swift" --model-json "$PROJECT_DIR/model-CoreIOS.json" # add this parameter to make entities exportable: --visibility public

Basic info (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Upgrade Objectbox following https://swift.objectbox.io/install
  2. Build
  3. Crash at launch
greenrobot commented 3 years ago

Upgrade Objectbox following https://swift.objectbox.io/install

So, you did the following?

pod repo update
pod update ObjectBox
Pods/ObjectBox/setup.rb

Can you paste the output of running setup.rb, please?

thanhhai08sk commented 3 years ago

Yes, I did. The output:

MacBook-Pro:CoreIOS HaiNguyen$ Pods/ObjectBox/setup.rb
 ObjectBox Project Setup 

🔸 Looking for project files in the current directory ...
🔸 Found a single project.
🔸 Using "/Users/HaiNguyen/Documents/githubProject/JournalIt/journal_it/ios/CoreIOS/CoreIOS.xcodeproj"
🛑 No launchable Xcode targets found in "/Users/HaiNguyen/Documents/githubProject/JournalIt/journal_it/ios/CoreIOS/CoreIOS.xcodeproj"
ℹī¸ Please specify project and target explicitly; run with --help for help

Not sure if there's anything wrong but CoreIOS is a framework module, EntityInfo-CoreIOS.generated.swift was refreshed on each build, and I didn't have problem with version 1.3.1

When specify the target:

MacBook-Pro:CoreIOS HaiNguyen$ Pods/ObjectBox/setup.rb --skip-modified /Users/HaiNguyen/Documents/githubProject/JournalIt/journal_it/ios/CoreIOS/CoreIOS.xcodeproj CoreIOS
 ObjectBox Project Setup 

🔸 Using "/Users/HaiNguyen/Documents/githubProject/JournalIt/journal_it/ios/CoreIOS/CoreIOS.xcodeproj"

Target "CoreIOS":

  🔸 Script was modified.
  🔸 Existing script: "$PODS_ROOT/ObjectBox/generate_sources.sh" -- --output "$PROJECT_DIR/generated/EntityInfo-CoreIOS.generated.swift" --model-json "$PROJECT_DIR/model-CoreIOS.json" # add this parameter to make entities exportable: --visibility public
  🔸 Expected script: "$PODS_ROOT/ObjectBox/generate_sources.sh" -- --output "$PROJECT_DIR/generated/EntityInfo-CoreIOS.generated.swift" --model-json "$PROJECT_DIR/model-CoreIOS.json" # add this parameter to make entities exportable: --visibility public
  🔹 Skipped target "CoreIOS".

 🔸 No changes made to project. 
 ℹī¸ If your code generation was not setup properly run with --help to see options

 đŸ’Ŧ Please remember to use the .xcworkspace CocoaPods created from now on instead of your project.
greenrobot commented 3 years ago

Can you please try what is suggested here: # add this parameter to make entities exportable: --visibility public

To do this you have to locate the script in the Xcode build phase "[OBX] Update Sourcery Generated Files".

It might also be helpful to check the following docs: manual-installation, setup-script, and code generation.

Once we know what exactly is going on we'll try to make it simpler in the future. E.g. looking at setup.rb:

  if !target.launchable_target_type? # probably a framework. Add a common use case reminder.
      obx_shell_script << " # add this parameter to make entities exportable: --visibility public"
  end

It might be better to detect a framework reliably, but not sure how exactly that could be done yet with what xcodeproj has to offer.

thanhhai08sk commented 3 years ago

Unfortunately, I tried to add --visibility public but got the same result.

Checked the docs, though I can't find anything to try out for this problem.