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

Compilation errors if flutter module with realm linked to native iOS app #1358

Open
TooComplicatedBye opened this issue Jul 20, 2023 · 3 comments

Comments

@TooComplicatedBye
Copy link

TooComplicatedBye commented Jul 20, 2023

What happened?

I have a native iOS app with a flutter module. (Path to the flutter module is $PROJECT_DIR/TargetA/FlutterModule) When I add realm to the flutter module and try to compile the whole app I get this error:
PhaseScriptExecution [CP-User]\ Download\ Realm\ Flutter\ iOS\ Binaries

/Users/user/Library/Developer/Xcode/DerivedData/MyProject-croqsfsonryeywhahmmyelbgulpt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/realm.build/Script-8CDC23D80A80F3E753C4D0E74C40DA89.sh: line 2: /Users/user/myproject-ios/Pods/../Flutter/flutter_export_environment.sh: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

If I fix the path manually in Pods.xcodeproj(Target: realm) then I get this error:
Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_RealmPlugin", referenced from: objc-class-ref in FlutterPluginRegistrant(GeneratedPluginRegistrant.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Repro steps

Try to compile native iOS app with flutter+realm.

Version

Flutter version: 3.10.6

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

macOS 13.0.1

Code snippets

No response

Stacktrace of the exception/crash you're getting

No response

Relevant log output

No response

@desistefanova
Copy link
Contributor

Hi @TooComplicatedBye!
We managed to reproduce the issue that you have reported.
We are looking for solution and we will write here later.
Thank you for reporting this issue!

@desistefanova
Copy link
Contributor

Hi @TooComplicatedBye!
We will try to find a way to fix the paths, but it will take time. Meanwhile you can copy this file from flutter module /flutter_module/.ios/Flutter/flutter_export_environment.sh into the native app Flutter folder /myproject-ios/Flutter/flutter_export_environment.sh. On this way you won't need to change the project file each time after running pod install
The second error is interesting. Do you think it can be caused of changing the project file? Please check if this will help: https://stackoverflow.com/a/61806331

@vm-martin-mcb
Copy link

I had a similar error when running pod install

[!] /bin/bash -c 
set -e
$PROJECT_DIR/Flutter/flutter_export_environment.sh; cd "$FLUTTER_APPLICATION_PATH"; "$FLUTTER_ROOT"/bin/dart run realm install --target-os-type ios --flavor flutter

/bin/bash: line 2: /Flutter/flutter_export_environment.sh: No such file or directory

Tweaking the realm.podspec scripts resolved the error above:

  s.prepare_command           = '#{project_dir}/Flutter/flutter_export_environment.sh; cd "$FLUTTER_APPLICATION_PATH"; "$FLUTTER_ROOT"/bin/dart run realm install --target-os-type ios --flavor flutter'
  s.script_phases             = [
                                  { :name => 'Download Realm Flutter iOS Binaries',
                                  #Use --debug to debug the install command
                                  :script => '$PROJECT_DIR/../Flutter/flutter_export_environment.sh; cd "$FLUTTER_APPLICATION_PATH"; "$FLUTTER_ROOT\"/bin/dart run realm install --target-os-type ios --flavor flutter',
                                    :execution_position => :before_headers
                                  },
                                  { :name => 'Report Metrics',
                                    :script => '$PROJECT_DIR/../Flutter/flutter_export_environment.sh; cd "$FLUTTER_APPLICATION_PATH"; "$FLUTTER_ROOT"/bin/dart run realm metrics --flutter-root "$FLUTTER_ROOT" --target-os-type ios --target-os-version "$IPHONEOS_DEPLOYMENT_TARGET"',
                                    :execution_position => :before_compile
                                  }
                                ]

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

No branches or pull requests

3 participants