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

Question: Does current ReactNativeFlipperExample app runs on simulator on M1 macs? #3150

Open
Pyroboomka opened this issue Dec 10, 2021 · 7 comments
Labels
help wanted Extra attention is needed PR welcome We're looking for community members to implement this!

Comments

@Pyroboomka
Copy link

Pyroboomka commented Dec 10, 2021

Been banging my head after getting M1 machine.
My goal is have a working setup with flipper running on simulator outside of Rosetta on my main project.
No success so far, (made it run on device with no changes), but having issues with simulator, so I decided to check against a simpler project.

So my current steps so far were:

  1. Clone the react-native/ReactNativeFlipperExample app
  2. yarn install && cd ios && pod install
  3. Attempt to debug build to iPhone 13 simulator.

Currently on my machine it fails with
Снимок экрана 2021-12-10 в 18 26 38

I'm not sure how it's even supposed to work with excluded architectures, since project.pbxproj file excludes arm64 configuration on main, which gets overridden by react_native_pods postinstall hacks workarounds.
Снимок экрана 2021-12-10 в 18 27 51

Adding bridging header (how I deduced, mainly for ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) does not help a bit.
Then it goes into territory on more attempts to make stuff run, overriding excluded archs again, which kinda ruins the point in trying to run an example project.

I'm interested in is that some problems in my configuration, or I should stop trying and it's not running on M1 machines in current state?

xed version 13.1

Thank you for you time!

@Pyroboomka Pyroboomka changed the title Question: Does current ReactNativeFlipperExample app runs on simultator on M1 macs? Question: Does current ReactNativeFlipperExample app runs on simulator on M1 macs? Dec 10, 2021
@aigoncharov
Copy link
Contributor

@lblasa have you tried to build one of our Sample apps on M1?

@lblasa
Copy link
Contributor

lblasa commented Dec 13, 2021

@aigoncharov unfortunately not, don't have an M1 available to me.

@aigoncharov aigoncharov self-assigned this Dec 13, 2021
@aigoncharov
Copy link
Contributor

@Pyroboomka I am sure we'll address it eventually, but I cannot promise any dates now or provide any direct guidance. If you find a workaround, we'd be beyond happy to hear back from you with the steps or a PR.

@aigoncharov aigoncharov added help wanted Extra attention is needed PR welcome We're looking for community members to implement this! labels Dec 13, 2021
@Pyroboomka
Copy link
Author

Well, can you at least tell me, does it fail with similar errors for you (if you tried to spin it up)? Unfortunately, my colleagues don't have M1 either, so if it breaks with the same errors that would be a good starting point for me.
I'll spend some time this week trying to make it work, but I don't have native iOS development experience, so it's gonna be fun :)

@Pyroboomka
Copy link
Author

Pyroboomka commented Dec 13, 2021

Well, it was kinda easy. Dug through some discussions on react-native repo about M1 issues and referencing this PR https://github.com/facebook/react-native/pull/32284/files which I guess is gonna land somewhere in 0.67 if I understand releases correctly, I just deleted the faulty path in LIBRARY_SEARCH_PATHS and it built successfully.

No point in fixing this I guess, gonna work out of the box in new release (after upgrading to new version correctly)

@personjerry
Copy link

@Pyroboomka Where is LIBRARY_SEARCH_PATHS you're modifying? The key is not defined (i.e. default) for me in my XCode build settings

@personjerry
Copy link

Nevermind, applied your fix by going into react_native_pods.rb and manually adding the fixer function from https://github.com/facebook/react-native/pull/32284/files

For other readers, you can apply this fix by going into node_modules/react-native/scripts/react_native_pods.rb and adding this function above the line def react_native_post_install(installer):

def fix_library_search_paths(installer)
  def fix_config(config)
    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
    if lib_search_paths
      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
        # since the libraries there are only built for x86_64 and i386.
        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
        lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
        end
      end
    end
  end

  projects = installer.aggregate_targets
    .map{ |t| t.user_project }
    .uniq{ |p| p.path }
    .push(installer.pods_project)

  projects.each do |project|
    project.build_configurations.each do |config|
      fix_config(config)
    end
    project.native_targets.each do |target|
      target.build_configurations.each do |config|
        fix_config(config)
      end
    end
    project.save()
  end
end

And then call the function, so your updated react_native_post_install looks like this:

def react_native_post_install(installer)
  if has_pod(installer, 'Flipper')
    flipper_post_install(installer)
  end

  exclude_architectures(installer)
  fix_library_search_paths(installer)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed PR welcome We're looking for community members to implement this!
Projects
None yet
Development

No branches or pull requests

4 participants