0

I am working on an existing ReactNative project to add new features to the IOS app. But I tried to build and run the IOS app using "react-native run-ios" command, I am getting the following error.

Could not find "Podfile.lock" at null.lock. Did you run "pod install" in iOS directory?

To resolve the problem, first I run the following command in the ios folder of the project.

pod install

When I do that, I am getting the following error in the console.

[!] No `Podfile' found in the project directory.

To solve that error, I tried doing the following:

  • I run "sudo gem install cocoapods"
  • Then in the ios folder I run "pod init"
  • Then I run "pod install" within the ios folder

Then I got the following error:

[!] The target `xxxxxx xxxTests` is declared multiple times.

I removed the repeating one in the Podfile and tried running pod install again. This time it run but I am getting the following warning.

[!] The Podfile does not contain any dependencies.

[!] Automatically assigning platform `iOS` with version `12.0` on target `Inventory Smart` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] Automatically assigning platform `tvOS` with version `12.0` on target `Inventory Smart-tvOS` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

When I run react-native run-ios, I am getting the following error.

error Could not find "Podfile.lock" at null.lock. Did you run "pod install" in iOS directory?

How can I solve the issue?

halfer
  • 19,824
  • 17
  • 99
  • 186
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372

1 Answers1

-1

Solution 1: The target xxxxxx xxxTests is declared multiple times.

It is pretty much prominent that your Podfile consists of the target xxxxxx-xxxTests multiple times. You just have to go inside the Podfile, and remove the duplicate problematic target xxxxxx-xxxTests code.

  • It will somehow look like this, you just have to remove one of the two declared code from the Podfile
target 'xxxxxx-xxxTests' do
  inherit! :search_paths
  # Pods for testing 
end 

You will be able to run the app now, you just have to do the below commands after you're done with the above fix.

pod install
cd ..
npm run ios

UPDATED ANSWER

Solution 2: Automatically assigning platform iOS with version 12.0

In your top section of Podfile, uncomment # podfile :ios, 'x.0' by removing # from the referred code, here x is the version number which would be there by default, so do not get confused. Or just mention this line globally, podfile :ios, '10.0'. This should ideally fix your issue.

Then run the following commands:

cd ios && rm -rf Pods
pod install
cd ..
react-native run-ios
Alok
  • 8,452
  • 13
  • 55
  • 93
  • Hello, I updated the question, please have a look. – Wai Yan Hein Jun 09 '21 at 13:07
  • Hello @WaiYanHein please see the **Updated Answer** section for your solution, and let me know if that works out for you – Alok Jun 09 '21 at 13:17
  • Hello. Thanks for the quick reply. Unfortunately it did not work. XCode is complaining that boost/operators.hpp file not found. – Wai Yan Hein Jun 09 '21 at 13:28
  • @WaiYanHein if you have done the above things, then just do `cd ios && rm -rf Pods && pod install`, and then `cd .. && react-native run-ios`. See if that works for you. The issue might be coming from the **Pods** only. Hence we are trying to clean out the project and then running the app. – Alok Jun 09 '21 at 13:31
  • Now, it is complaning Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues.. It was all working before. The simulator is open there. I am getting it when I run "react-native run-ios". – Wai Yan Hein Jun 09 '21 at 13:36
  • @WaiYanHein Try this and let me know: `react-native run-ios --simulator="iPhone 11"` – Alok Jun 09 '21 at 13:39
  • @WaiYanHein Try the [Stackoverflow Solution for react-native-run-ios-returns-error-could-not-find-iphone-x-simulator](https://stackoverflow.com/questions/54504076/react-native-run-ios-returns-error-could-not-find-iphone-x-simulator) and see if that fixes your problem. You can also vote this answer, if it anyway helped you. It will help me get some reward for the time I have invested in helping you out to solve some of the issues which you raised initially, and got fixed. Would appreciate it very much – Alok Jun 10 '21 at 10:19