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

Undefined symbol: _OBJC_CLASS_$_PrivateSentrySDKOnly #1300

Closed
4 tasks done
mahmed8003 opened this issue Feb 28, 2023 · 7 comments · Fixed by #1303
Closed
4 tasks done

Undefined symbol: _OBJC_CLASS_$_PrivateSentrySDKOnly #1300

mahmed8003 opened this issue Feb 28, 2023 · 7 comments · Fixed by #1303

Comments

@mahmed8003
Copy link

Platform:

  • Flutter Android or iOS

IDE:

  • IntelliJ/AS
  • XCode

Platform installed with:

  • pub.dev

Output of the command flutter doctor -v below:

Flutter 3.7.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c07f788888 (6 days ago) • 2023-02-22 17:52:33 -0600
Engine • revision 0f359063c4
Tools • Dart 2.19.2 • DevTools 2.20.1

The version of the SDK (See pubspec.lock):

sentry_flutter: ^6.19.0
sentry_flutter: ^6.21.0

Failed to run the app on iPhone simulator, Error during the compilation process.

Launching lib/main.dart on iPhone 8 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                           18.6s
Failed to build iOS app
Error (Xcode): Undefined symbol: _OBJC_CLASS_$_PrivateSentrySDKOnly

Error (Xcode): Undefined symbol: _OBJC_CLASS_$_SentryBreadcrumb

Error (Xcode): Undefined symbol: _OBJC_CLASS_$_SentryDebugMeta

Error (Xcode): Undefined symbol: _OBJC_CLASS_$_SentrySDK

Error (Xcode): Undefined symbol: _OBJC_CLASS_$_SentryUser

Could not build the application for the simulator.
Error launching application on iPhone 8.

Everything works fine when I run the app on a real ios device. I am able to create new builds and upload them. But when I try to run the app on an ios simulator compilation process throws the above errors. I first face this error when I upgraded to sentry_flutter: ^6.19.0 and later today I upgraded to sentry_flutter: ^6.21.0 and the issue still persists.
I have tried cleaning project, cleaning pods, removing Podfile.lock but nothing worked.
pod install actually installs Installing Sentry (7.31.5)

@marandaneto
Copy link
Contributor

@mahmed8003 its likely something in your environment, just created an empty project and it works.
can you provide a minimal reproducible example?

@ichiwaki-altlas
Copy link

same problem.

@mahmed8003
Copy link
Author

@marandaneto I created a new project and integrated the sentry library, everything worked fine on the simulator but then I added these configurations to Pod file and the error start to appear again.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
        config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
        config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
    end
    flutter_additional_ios_build_settings(target)
  end
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"
  end
end

Following is the test project run for ios simulator.
sentry_test.zip

@brustolin
Copy link
Collaborator

Hello @mahmed8003.
By adding the following line, you're asking the compiler to not compile Sentry for the simulator

config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"

I tried your sample and it works when I target a real device.
Why do you need this?

@mahmed8003
Copy link
Author

Hi @brustolin
I need to exclude iphonesimulator* because of Mapbox. If I remove these settings I get the following error.

Launching lib/main.dart on iPhone 8 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                           32.9s
Failed to build iOS app
Error (Xcode): Building for iOS Simulator, but linking in dylib built for iOS, file '/xxxxxxx/xxxxxxx/ios/Pods/Mapbox-iOS-SDK/dynamic/Mapbox.framework/Mapbox' for architecture arm64

Could not build the application for the simulator.
Error launching application on iPhone 8.

I have had these settings before and the sentry was working fine with older versions.

@brustolin
Copy link
Collaborator

brustolin commented Mar 1, 2023

I have had these settings before and the sentry was working fine with older versions.

Thats interesting, I would have to investigate.

For now try this pod configuration:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
        config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
        config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386" unless target.name.include? 'Sentry'
    end
    flutter_additional_ios_build_settings(target)
  end
end

@mahmed8003
Copy link
Author

@brustolin your comment enabled me learn more about pod configurations 🤝
so I tweak the configuration a little more and with the following configurations things are working fine on the simulator

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
        if target.name.include?('Mapbox') or target.name.include?('mapbox_gl')
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"
        end
    end
  end
end

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

Successfully merging a pull request may close this issue.

4 participants