DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
122 stars 42 forks source link

[1.1.0] ios use_frameworks! results in build errors #262

Closed AlexanderEggers closed 2 years ago

AlexanderEggers commented 2 years ago

I am using the sdk version 1.1.0 and use_frameworks! in my project. Unfortunately I have noticed that 1.1.0 is resulting in build errors - 1.0.0 runs fine in comparision.

❌  /Users/alex/Documents/Projects/my-app/node_modules/@datadog/mobile-react-native/ios/Sources/DdLogs.swift:10:11: 'Logger' is ambiguous for type lookup in this context

extension Logger: NativeLogger { }
              ^

❌  /Users/alex/Documents/Projects/my-app/node_modules/@datadog/mobile-react-native/ios/Sources/DdLogs.swift:40:29: cannot convert value of type 'Logger' to closure result type 'NativeLogger'

        self.init { builder.build() }
              ^

▸ Compiling QueueHolder.swift
▸ Compiling Attributes.swift

❌  error: emit-module command failed with exit code 1 (use -v to see invocation)

I have modified the pod file according to your description in the README but that didn't solve my problem.

louiszawadzki commented 2 years ago

Hi @AlexanderEggers, thanks for reaching out!

So far we've not been able to reproduce your issue, could you provide us with the following additional information:

Could you also see if you XCode gives more information about this? You can open ios/MyApp.xcworkspace, then go to Pods > Development Pods > DatadogSDKReactNative > DdLogs.swift and see if the line is underlined.

Thanks a lot!

AlexanderEggers commented 2 years ago

Hi @louiszawadzki,

Thanks for replying to my issue.

$RNFirebaseAsStaticFramework = true

require_relative '../node_modules/expo/scripts/autolinking.rb'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'

project 'my_app',
'DEV_AU_DEBUG' => :debug,
'DEV_AU' => :release,
'DEV_AU_APPLEPAY' => :release,
'DEV_US' => :release,
'LIVE_AU' => :release,
'LIVE_AU_APPLEPAY' => :release,
'LIVE_US' => :release,
'LIVE_US_APPLEPAY' => :release,
'PROD_AU' => :release,
'PROD_US' => :release

use_frameworks! :linkage => :static

target 'my_app' do
  config = use_native_modules!

  use_expo_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'

  pod 'Braintree', :inhibit_warnings => true
  pod 'Braintree/Apple-Pay'
  pod 'Braintree/DataCollector'
  pod 'Braintree/PayPal'
  pod 'BraintreeDropIn', :inhibit_warnings => true
  pod 'BraintreeDropIn/UIKit'

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

  pod 'ZendeskSupportSDK'

  tealium_path = '../node_modules/tealium-react-native/tealium-react-native-swift.podspec'
  pod "tealium-react-native-swift", :path => tealium_path

  # Enables Flipper.
  #
  # NOTE: This cannot be used until we introduce RN 0.69 to the project.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  # use_flipper!({ 'Flipper' => '0.161.0' }, configurations: ['dev_au_debug'])

  dynamic_frameworks = ['DatadogSDKBridge','DatadogSDKCrashReporting', 'GoogleUtilities', 'FirebaseCore']

  # Make all the other frameworks into static frameworks by overriding the static_framework? function to return true
  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if !dynamic_frameworks.include?(pod.name)
        puts "Overriding the static_framework? method for #{pod.name}"
        def pod.static_framework?;
          true
        end
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end

  post_install do |installer|
    react_native_post_install(installer)

    installer.pods_project.targets.each do |target|
      if target.name == 'RCT-Folly'
        target.build_configurations.each do |config|
          config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
        end
      end
    end

    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        # Force CocoaPods targets to always build for x86_64
        config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end

DEPENDENCIES:

SPEC REPOS: trunk:

EXTERNAL SOURCES: boost: :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" DatadogSDKReactNative: :path: "../node_modules/@datadog/mobile-react-native" DoubleConversion: :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" EXBrightness: :path: "../node_modules/expo-brightness/ios" EXLocation: :path: "../node_modules/expo-location/ios" Expo: :path: "../node_modules/expo" ExpoLinearGradient: :path: "../node_modules/expo-linear-gradient/ios" ExpoModulesCore: :path: "../node_modules/expo-modules-core/ios" ExpoWebBrowser: :path: "../node_modules/expo-web-browser/ios" FBLazyVector: :path: "../node_modules/react-native/Libraries/FBLazyVector" FBReactNativeSpec: :path: "../node_modules/react-native/React/FBReactNativeSpec" glog: :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" lottie-ios: :path: "../node_modules/lottie-ios" lottie-react-native: :path: "../node_modules/lottie-react-native" Permission-Camera: :path: "../node_modules/react-native-permissions/ios/Camera" Permission-Notifications: :path: "../node_modules/react-native-permissions/ios/Notifications" RCT-Folly: :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" RCTRequired: :path: "../node_modules/react-native/Libraries/RCTRequired" RCTTypeSafety: :path: "../node_modules/react-native/Libraries/TypeSafety" React: :path: "../node_modules/react-native/" React-callinvoker: :path: "../node_modules/react-native/ReactCommon/callinvoker" React-Codegen: :path: build/generated/ios React-Core: :path: "../node_modules/react-native/" React-CoreModules: :path: "../node_modules/react-native/React/CoreModules" React-cxxreact: :path: "../node_modules/react-native/ReactCommon/cxxreact" React-jsi: :path: "../node_modules/react-native/ReactCommon/jsi" React-jsiexecutor: :path: "../node_modules/react-native/ReactCommon/jsiexecutor" React-jsinspector: :path: "../node_modules/react-native/ReactCommon/jsinspector" React-logger: :path: "../node_modules/react-native/ReactCommon/logger" react-native-appboy-sdk: :path: "../node_modules/react-native-appboy-sdk" react-native-branch: :path: "../node_modules/react-native-branch" react-native-camera: :path: "../node_modules/react-native-camera" react-native-config: :path: "../node_modules/react-native-config" react-native-date-picker: :path: "../node_modules/react-native-date-picker" react-native-get-random-values: :path: "../node_modules/react-native-get-random-values" react-native-google-maps: :path: "../node_modules/react-native-maps" react-native-maps: :path: "../node_modules/react-native-maps" react-native-netinfo: :path: "../node_modules/@react-native-community/netinfo" react-native-safe-area-context: :path: "../node_modules/react-native-safe-area-context" react-native-splash-screen: :path: "../node_modules/react-native-splash-screen" React-perflogger: :path: "../node_modules/react-native/ReactCommon/reactperflogger" React-RCTActionSheet: :path: "../node_modules/react-native/Libraries/ActionSheetIOS" React-RCTAnimation: :path: "../node_modules/react-native/Libraries/NativeAnimation" React-RCTBlob: :path: "../node_modules/react-native/Libraries/Blob" React-RCTImage: :path: "../node_modules/react-native/Libraries/Image" React-RCTLinking: :path: "../node_modules/react-native/Libraries/LinkingIOS" React-RCTNetwork: :path: "../node_modules/react-native/Libraries/Network" React-RCTSettings: :path: "../node_modules/react-native/Libraries/Settings" React-RCTText: :path: "../node_modules/react-native/Libraries/Text" React-RCTVibration: :path: "../node_modules/react-native/Libraries/Vibration" React-runtimeexecutor: :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" React-TestFairy: :path: "../node_modules/react-native-testfairy" ReactCommon: :path: "../node_modules/react-native/ReactCommon" ReactNativeART: :path: "../node_modules/@react-native-community/art" RNCAsyncStorage: :path: "../node_modules/@react-native-async-storage/async-storage" RNCPicker: :path: "../node_modules/@react-native-picker/picker" RNDeviceInfo: :path: "../node_modules/react-native-device-info" RNFBApp: :path: "../node_modules/@react-native-firebase/app" RNFBCrashlytics: :path: "../node_modules/@react-native-firebase/crashlytics" RNGestureHandler: :path: "../node_modules/react-native-gesture-handler" RNKeychain: :path: "../node_modules/react-native-keychain" RNPermissions: :path: "../node_modules/react-native-permissions" RNReanimated: :path: "../node_modules/react-native-reanimated" RNScreens: :path: "../node_modules/react-native-screens" RNSVG: :path: "../node_modules/react-native-svg" tealium-react-native: :path: "../node_modules/tealium-react-native" tealium-react-native-swift: :path: "../node_modules/tealium-react-native/tealium-react-native-swift.podspec" Yoga: :path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS: Appboy-iOS-SDK: 640c2d51cec128008da5c4c680df3d76e8c137bc boost: a7c83b31436843459a1961bfd74b96033dc77234 Braintree: 78a33deb6f6ec617c2c4891fbe352854358b3a8d BraintreeDropIn: b57b653d130981aad7ad9bc97a69d3d7ef86f7a1 Branch: b5b57fc2e6f098916fd2ea26c9b66f52ffe7e293 DatadogSDK: e19da4405bc7c13e1376569aefc4587afddc7747 DatadogSDKCrashReporting: 11d9933a97233f61cb03109914b63249b55b6a43 DatadogSDKReactNative: 85cff5d535b90ea0dd7f339c7ef68b527da7fa28 DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 EXBrightness: b6550cfe265e2131a0ddc7ebe97697813199850d EXLocation: b8cba3cb354bee6abb181c1dd245abe5aef22955 Expo: fcdb32274e2ca9c7638d3b21b30fb665c6869219 ExpoLinearGradient: 1a3af07c6dab3c612967a294836df9ae717431df ExpoModulesCore: 5a973701f4400d70254bc836305228731c829010 ExpoWebBrowser: 5804ac42a8269d0e534bc4461993005f72535649 FBLazyVector: 34f7420274737b6fcf2e2d9fd42641e66b4436a3 FBReactNativeSpec: 68c23fb2cea9393190e0815b673d742fa33d2dab Firebase: 800f16f07af493d98d017446a315c27af0552f41 FirebaseCore: 25c0400b670fd1e2f2104349cd3b5dcce8d9418f FirebaseCoreDiagnostics: 17cbf4e72b1dbd64bfdc33d4b1f07bce4f16f1d8 FirebaseCoreExtension: 2904492b693a6871ddbd1088c9d1fe6e54384050 FirebaseCoreInternal: 50a8e39cae8abf72d5145d07ea34c3244f70862b FirebaseCrashlytics: d20fa38bb8c88cb0f1c9211286bc23ab58c1b464 FirebaseInstallations: 41f811b530c41dd90973d0174381cdb3fcb5e839 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 476ee3e89abb49e07f822b48323c51c57124b572 Google-Maps-iOS-Utils: 3343332b18dfd5be8f1f44edd7d481ace3da4d9a GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f GoogleMaps: 6e9c923ca035989709fcb5771544fda4cc5fa2a4 GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1 lottie-ios: 9ae750cdc7820fecbd3c2f0cfc493038208fcdc4 lottie-react-native: b702fab740cdb952a8e2354713d3beda63ff97b0 nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 Permission-Camera: bf6791b17c7f614b6826019fcfdcc286d3a107f6 Permission-Notifications: 150484ae586eb9be4e32217582a78350a9bb31c3 PLCrashReporter: 2a08001f8e6a30abe405ee8f13d2753cfb5d682a PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb RCT-Folly: 4d8508a426467c48885f1151029bc15fa5d7b3b8 RCTRequired: b8caca023d386d43740dfb94c2cf68f695fa5e77 RCTTypeSafety: ec44ea1d6ad1e5cd6447b22159ff40c2ebbd23b1 React: 9f8c8afb9a9d61b7a1b01a1c6fb7f0d4f902988f React-callinvoker: f813eee352cfd333208e8d67a72f584f5435769d React-Codegen: 771562186fec8c7830897f97ca59de683abd3184 React-Core: 74670b4b715083e1c9003462f3f4fe32a70ba5c5 React-CoreModules: 34bd5b93e5322e60102a5ad78b992c882e558022 React-cxxreact: adc9fc6a9333ae779bd72effaf77173bd9f22bf7 React-jsi: ab91137ea7d92a86e48b6f15d3a5580bea471776 React-jsiexecutor: a5043e9e1e1bd13b80b58b228c6901b3721a4f54 React-jsinspector: 86e89b9f135787a2e8eb74b3fc00ec61e9a80ae1 React-logger: f790bd10f86b38012e108fb4b564023602702270 react-native-appboy-sdk: fda756a8584dcb328be47c76a34d896dea84da91 react-native-branch: a655936d3cb08e238ace630f7067a3a7058c06a5 react-native-camera: 3eae183c1d111103963f3dd913b65d01aef8110f react-native-config: 7cd105e71d903104e8919261480858940a6b9c0e react-native-date-picker: 55193347d8d0f40948f441ffd4e5db6f0a8fbe13 react-native-get-random-values: a6ea6a8a65dc93e96e24a11105b1a9c8cfe1d72a react-native-google-maps: 751f1dd2362c09d4ac45b09970d78f138a109268 react-native-maps: f4067ffa5044ade5bf98d6dde15014318a537c2f react-native-netinfo: 129bd99f607a2dc5bb096168f3e5c150fd1f1c95 react-native-safe-area-context: b456e1c40ec86f5593d58b275bd0e9603169daca react-native-splash-screen: 4312f786b13a81b5169ef346d76d33bc0c6dc457 React-perflogger: fa15d1d29ff7557ee25ea48f7f59e65896fb3215 React-RCTActionSheet: e83515333352a3cc19c146e3c7a63a8a9269da8f React-RCTAnimation: 8032daa2846e3db7ac28c4c5a207d0bfb5e1e3ad React-RCTBlob: fe40e206cebcb4f552e0ecdac3ef81b3baf3cb37 React-RCTImage: dfc0df14cbfec1ec54fdd4700b8fe3bf8127dde2 React-RCTLinking: ac9f65f0c8db738a6156ae7640ba92494b4770a5 React-RCTNetwork: cf289a0386a1bd057e5eabb8563dfe5ce0af868c React-RCTSettings: 7889cfcf6c7d5738f3cb8889557a38eeea2f04ff React-RCTText: fd249e1f8406fb6e35cc77a2b9ff66a3477bf41a React-RCTVibration: f41f116aad644973f24653effb3db3de64fa0314 React-runtimeexecutor: 8cdd80915ed6dabf2221a689f1f7ddb50ea5e9f3 React-TestFairy: dd24c6e7d580bcaaebd35a9d756c1ee301363ca3 ReactCommon: 5b1b43a7d81a1ac4eec85f7c4db3283a14a3b13d ReactNativeART: 78edc68dd4a1e675338cd0cd113319cf3a65f2ab RNCAsyncStorage: 0c357f3156fcb16c8589ede67cc036330b6698ca RNCPicker: 0b65be85fe7954fbb2062ef079e3d1cde252d888 RNDeviceInfo: 0a7c1d2532aa7691f9b9925a27e43af006db4dae RNFBApp: a6fca2cd8f392b5efc1f2ab7bd4b3b64a6039abf RNFBCrashlytics: 47491b7a815adba32e8ad7427fed0c3b5143bf61 RNGestureHandler: 920eb17f5b1e15dae6e5ed1904045f8f90e0b11e RNKeychain: ff836453cba46938e0e9e4c22e43d43fa2c90333 RNPermissions: dcdb7b99796bbeda6975a6e79ad519c41b251b1c RNReanimated: 5bdcbcc3a72aedeee7bb099604262403aa75a1e5 RNScreens: 0df01424e9e0ed7827200d6ed1087ddd06c493f9 RNSVG: 1153e8eeb34c788841016c517dba9f57f20b762f SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866 tealium-react-native: 245d29a52eead468ed2d243dfbe8896ed3e3de8b tealium-react-native-swift: dd7e7470cb8c067e2040d0e4dd004a9094a2679a tealium-swift: 1e06aa9071e84086360d407dc4687906dd759542 TestFairy: 34488ae6a253b9b7f67da8651f3ef9c6b5bae1ad Yoga: 2f6a78c58dcc2963bd8e34d96a4246d9dff2e3a7 ZendeskCommonUISDK: ba160fe413b491af9e7bfcb9808afcd494dc83a5 ZendeskCoreSDK: 4236eb56f9386cf0770900df04c857b9b4d79d03 ZendeskMessagingAPISDK: 410f9bcf07c79fe98d6f251da102368d6b356c54 ZendeskMessagingSDK: 95d396c981dacfab83cc7b9736e8561d51a3052b ZendeskSDKConfigurationsSDK: ebced171fd1f4eb57760e8537d8cfa6a450122be ZendeskSupportProvidersSDK: 77a62fe6bacc05bb10ff20edce75612fa109fd61 ZendeskSupportSDK: ba72e90e327635b5fde3d023a3de33242a6ee8ab

PODFILE CHECKSUM: 67da73f871be5aeb9b8853789bef6eab2acfccd8

COCOAPODS: 1.11.3



- My installed xcode version is 13.4.1.
- I can run the above podfile fine via `pod install` but `react-native run-ios` results in the mentioned error.
- When opening DdLogs.swift in XCode I can see the relevant lines underlined as well.

Let me know if you need anything else.
louiszawadzki commented 2 years ago

Hi @AlexanderEggers, thanks for providing all this information 🙇

It seems that the issue appears when adding :linkage => :static. To solve it, try to add 'DatadogSDKReactNative' to the list of dynamic_frameworks, that seems to solve it for me.

Tell me if this work, if it does I'll update our documentation!

AlexanderEggers commented 2 years ago

Thanks @louiszawadzki - I have tried your suggestion and unfortunately that didn't work for me. I also tried to disable the framework setup and I even get the some error in a non-framework scenario.

louiszawadzki commented 2 years ago

Hi @AlexanderEggers,

I gave it a bit more time this morning, and I indeed can see this error when building.

I tried a few things, and the one that seems to work consistently for me is to include only 'DatadogSDK' in the dynamic_frameworks, removing 'DatadogSDKReactNative', 'DatadogSDKBridge' and 'DatadogSDKCrashReporting', so for you it should look like this:

  dynamic_frameworks = ['DatadogSDK', 'GoogleUtilities', 'FirebaseCore']

There might be some cache issues, so I recommend that before making any new build, you:

Tell me if this work better for you, and if you encounter anymore issue please include the full error to help us troubleshoot.

louiszawadzki commented 2 years ago

@AlexanderEggers alternatively, you can also try this other solution that may work as well: https://github.com/DataDog/dd-sdk-reactnative/issues/263#issuecomment-1241707824

Tell me if any of the two solutions worked for you

AlexanderEggers commented 2 years ago

Using the latest version 1.1.1 (https://github.com/DataDog/dd-sdk-reactnative/releases/tag/1.1.1) resolved the issues for me. 🎉