react-native run-ios builds sporadically - ios

react-native-cli: 2.0.1
react-native: 0.58.4
When I use react-native cli invoking build ios to simulator, it is not building any app. It just opens IOS simulator.
This is everything what i get:
Found Xcode project HelloWorld.xcodeproj
Launching iPhone 6s (iOS 12.1)...
Building using "xcodebuild -project HelloWorld.xcodeproj -configuration Debug -scheme HelloWorld -destination id=32CE8569-3EE3-4DDD-9963-E0ED0E8DA946 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/tokra/Documents/Code/bitbucket.fork/rn-test/HelloWorld/ios/build
I remember it built only once, since then I cannot force rebuild.
Is there any way how to force build xcode in cli using react-native?

Related

Fresh React Native Project Fails on IOS build (M1 MacBook)

I created my first react-native project and I started metro just fine. But When I try to run IOS it fails to build. Any suggestions on what I should check?
latest Xcode installed
karar#Karars-MacBook-Air TheGlobalDoctor % npx react-native run-ios
info Found Xcode workspace "TheGlobalDoctor.xcworkspace"
info Building (using "xcodebuild -workspace TheGlobalDoctor.xcworkspace -configuration Debug -scheme TheGlobalDoctor -destination id=845FA08B-2299-4B05-B9C9-207405392A77")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening TheGlobalDoctor.xcworkspace.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace TheGlobalDoctor.xcworkspace -configuration Debug -scheme TheGlobalDoctor -destination id=845FA08B-2299-4B05-B9C9-207405392A77
Xcode Failed Build error:
fatal error: module map file '/Users/karar/Library/Developer/Xcode/DerivedData/TheGlobalDoctor-axdadhlgtbbtzcabxyzzteupuwlt/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found 1 error generated.
I had a similar issue. You can start XCode using Rosetta to circumvent the problem for now.
To do so open 'Applications' and find XCode. Open it's context menu and select 'Get Info'. In the info view, make sure the "Open using Rosetta" checkbox is checked.
(Thx to Karthik posting the solution in his blog)

Can't debug react-native project from Xcode, but It's running from console

Operating system macOS Mojave (version 10.14.5)
React Native Project 0.59.10
I'm working on one big react-native project. When I'm running react-native run-iso it runs emulator, and everything is perfect.
However, if I'll go into ios directory and try to build a project from Xcode, I'm getting the error. Library not found for -lBase64
I've tried:
Install different versions of Xcode
Remove some system files of xCode in the system. Reinstall Xcode
Tried run on Emulator and Physical device (Both failed)
Deleted build and pod directories out of ios directory
Meanwhile, this project is building from Xcode without a problem to my Colleague computer.
When I'm running through console I see:
info Building using
xcodebuild -workspace [name-of-the-app].xcworkspace -configuration Debug -scheme [name-of-the-app] -destination id=[some-long-id] -derivedDataPath build/[name-of-the-app
Maybe I have to define this parameter somewhere? Any solutions, any ideas?

WebStorm: Set simulator id for React Native

When I run my React Native application WebStorm starting an iPhone X simulator by default. WebStorm's React Native documentation states that:
If you selected the Build and launch checkbox, choose the target
platform, Android or iOS. Depending on your choice, WebStorm will run
the bundler with react-native run-ios or with react-native run-android.
Optionally, type the arguments to be passed to React Native, for
example, specify the simulator type through the ‑‑simulator flag:
‑‑simulator="iPhone 4s".
I have set my flag to iPhone Xs Max as shown below:
But it is still starting iPhone X:
react-native-cli run-ios "‑‑simulator=iPhone Xs Max"
info Found Xcode project MyProject.xcodeproj
info Building using "xcodebuild -project MyProject.xcodeproj -configuration Debug
-scheme MyProject
-destination id=0299DF16-DD84-40FB-8B37-55FC7EFCE271
-derivedDataPath build/MyProject"
The id 0299DF16-DD84-40FB-8B37-55FC7EFCE271 is id of iPhone X.
How can I change this?
I found the problem. What was wrong is dashes of flag simulator. When I copied the code from documentation it had short dashes ‑‑simulator. Correct one should be --simulator.

xctool doesn't run with the requested iOS version

I am running iOS tests on Circle CI using Xcode 6.4 and iOS 8.4 with this command:
xctool -workspace ios.xcworkspace -scheme ios test -sdk iphonesimulator8.4
But when the simulator runs, it fails to run my tests and I receive this error:
Test did not run: The simulator failed to start, or the TEST_HOST
application failed to run. Simulator error: Exception encountered
connecting to CoreSimulatorBridge: Unable to connect to
CoreSimulatorBridge
Looking at the logs, it looks like the simulator actually tries to run against iOS 9:
run-test iosTests.xctest (iphonesimulator9.0, iPhone 4s, application-test)
Is there a way to force it to run on iOS 8.4 so the tests would run?
I had the same issue recently on Circle CI. I'm not sure if it's related to xctool's newest version (0.2.7) or not, but adding this fixed it for me:
-destination platform='iOS Simulator,OS=8.4,name=iPhone 6'
So the full command in your case should be:
xctool -workspace ios.xcworkspace -scheme ios test -sdk iphonesimulator8.4 -destination platform='iOS Simulator,OS=8.4,name=iPhone 6'

XCode 6 Unit Testing Without Building

Is there a way to prevent the app from building when I am just unit testing? When I run the test it builds the app and that takes minutes. I have written the tests in Swift and targets ios 8.
In Xcode 8+, you can pass the "test-without-building" option.
$ xcodebuild -workspace <your_xcworkspace> -scheme <your_scheme> -sdk iphonesimulator -destination ‘platform=iOS Simulator,name=<your_simulator>,OS=10.2’ test-without-building
Read more here: https://medium.com/xcblog/speed-up-ios-ci-using-test-without-building-xctestrun-and-fastlane-a982b0060676

Resources