简体   繁体   English

react-native无法将最新版本的ios代码推送到模拟器

[英]react-native unable to push recent version of ios code to simulator

I am building a react-native application that should work in both the Android simulator and the iOS simulator. 我正在构建一个本机应用程序,该应用程序在Android模拟器和iOS模拟器中都应能正常工作。 I've been developing primarily on my Windows machine, and I would use command prompt react-native run-android to see my changes in an Android simulator. 我主要在Windows机器上进行开发,因此我将使用命令提示符react-native run-android在Android模拟器中查看更改。 Once in a while, I would go to my mac mini, do a git pull origin master , and then run react-native run-ios to see my changes in an iOS simulator. 偶尔,我会去Mac mini,做一个git pull origin master ,然后运行react-native run-ios在iOS模拟器中查看我的更改。

Everything has been working fine until a few days ago. 直到几天前,一切都工作正常。 Now when I'm on my mac mini, the following will happen: 现在,当我使用Mac mini时,将发生以下情况:

  • if I run react-native run-android from my terminal, I see my latest react-native changes in the android simulator, which is perfect 如果我在终端上运行react-native run-android ,我会在android模拟器中看到最新的react-native更改,这很完美
  • if I run react-native run-ios from my terminal, I see an EARLIER/OLDER version of my react-native changes of the ios simulator. 如果我从终端运行react-native run-ios ,我会看到ios模拟器的react-native更改的早期版本/旧版本。 This is NOT what I want. 这不是我想要的。 I want my ios simulator to show my latest changes the way a developer would expect. 我希望我的ios模拟器以开发人员期望的方式显示我的最新更改。 I tried typing garbage, syntax errors, deleting files in my react-native project to see if the compiler will respect these errors and fail, but it does not. 我尝试键入垃圾,语法错误,在我的本机项目中删除文件,以查看编译器是否会尊重这些错误并失败,但事实并非如此。 The react-native run-ios command ignores my clearly broken project and continues to build the same earlier version of my react-native project and puts it in the ios simulator. react-native run-ios命令将忽略我明显损坏的项目,并继续构建我的react-native项目的相同早期版本,并将其放入ios模拟器中。 I tried deleting the project, and doing a fresh new git pull, but still the same issue occurs and simulator shows the same earlier version of my project. 我尝试删除该项目,并进行全新的git pull,但是仍然发生相同的问题,并且模拟器显示了该项目的相同早期版本。

Why won't my react-native run-ios command build the latest version of my react-native code and put it in the ios simulator? 为什么我的react-native run-ios命令不会构建最新版本的react-native代码并将其放入ios模拟器中?

Ok, I found a workaround. 好的,我找到了解决方法。

I started a completely new react-native project with the react-native init <sameprojectnameasmybrokenproject> . 我使用react-native init <sameprojectnameasmybrokenproject>开始了一个全新的react-native项目。 Then I copied all my react components and project files (The ones that I created, and not the stuff that react creates boiler templates for) and my package.json file from my broken project to my new project. 然后,我将我所有的React组件和项目文件(我创建的组件,而不是React为其创建锅炉模板的东西)和我的package.json文件从破碎的项目复制到了新项目。 Then I ran react-native run-ios to make sure this new project works fine. 然后,我运行了react-native run-ios以确保该新项目正常运行。


EDIT 编辑

I also copied these four files from my new project into my broken project, and it got the broken project to show the latest build versions again. 我还将这四个文件从我的新项目复制到破碎的项目中,它使破碎的项目再次显示最新的构建版本。

  • ios/nutriag.xcodeproj/project.pbxproj ios / nutriag.xcodeproj / project.pbxproj
  • ios/nutriag.xcodeproj/xcshareddata/xcschema/nutriag.xcscheme ios / nutriag.xcodeproj / xcshareddata / xcschema / nutriag.xcscheme
  • ios/nutriag/AppDelegate.m ios / nutriag / AppDelegate.m
  • ios/nutriag/Info.plist ios / nutriag / Info.plist

So something about these four files was broken in my broken project. 所以这四个文件在我坏掉的项目中坏了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM