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

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

Open
MaheshKaemSolutions opened this issue Jan 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@MaheshKaemSolutions
Copy link

MaheshKaemSolutions commented Jan 22, 2024

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

  • What do you expect should be happening?
  • Include a screenshot or video if it makes sense.

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

@MaheshKaemSolutions MaheshKaemSolutions added the bug Something isn't working label Jan 22, 2024
@miklosherald09
Copy link

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

@MaheshKaemSolutions
Copy link
Author

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

@arlovip
Copy link

arlovip commented May 27, 2024

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

  • First, adding the following scripts to your Podfile
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.

  • Second, adding arm64 to Any iOS Simulator SDK in Build Settings->Arthitectures->Excluded Architectures->Debug->Any iOS Simulator SDK

Then, it looks like the following screenshot
WechatIMG254

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants