HeligPfleigh / react-native-thermal-receipt-printer

A RN library for thermal printer
155 stars 102 forks source link

Getting build error on Xcode simulator but working fine on Android emulator #167

Open MaheshKaemSolutions opened 5 months ago

MaheshKaemSolutions commented 5 months ago

Current Behavior Getting this error In /Volumes/MaheshWork/RNDThermalPrinter/node_modules/react-native-thermal-receipt-printer/ios/PrinterSDK/libPrinterSDK.a(GCDAsyncSocket.o), building for iOS Simulator, but linking in object file built for iOS, file '/Volumes/MaheshWork/RNDThermalPrinter/node_modules/react-native-thermal-receipt-printer/ios/PrinterSDK/libPrinterSDK.a' for architecture arm64 even after removing flipper related lines from podfile and appDelegate.mm. Expected Behavior

How to reproduce

  1. Install the library using yarn, run the build on xcode with selected emulator apple 15 or apple xS.
  2. you will get this error in between the build installed library with version :1.2.0-rc.2 Your Environment ios mac M2 Chip
software version
iOS or Android ios
react-native 0.73.2
node
npm or yarn

Screenshot 2024-01-22 at 6 31 16 PM

miklosherald09 commented 5 months ago

Hi @MaheshKaemSolutions . Do you find any solution for this??

MaheshKaemSolutions commented 5 months ago

@miklosherald09 actually this library doesn't support simulators, but you can build this library on real device and it's working fine over there.

lchenfox commented 1 month ago

For people encounters this problem, it can be resolved by the following steps:

installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

Then, it should look like

target 'NewRN' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'NewRNTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )

    # Adding these lines below.
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end

  end

end

Don't forget to execute npx pod-install in your root directory or pod install in ios directory.

Then, it looks like the following screenshot WechatIMG254

Finally, clean your xcode and run any simulator if you like. It should work as expected.