iOS React Native app fails to install with Xcode 12 build tools when installed via Detox - react-native

I'm trying to run detox tests, on Android they run correctly.
When using Xcode 11 build tools, the app installs correctly and all tests run.
When using Xcode 12 the app fails to install. The app attempts to be installed 3 times, and eventually the simulator complains that it's unable to install and the app icon is darkened on the simulator.
I've tried debug and release configurations, and I am cleaning/building each time. Running the scheme directly in Xcode on v12, the application installs and works normally.
The build command:
xcodebuild -workspace ios/myapp.xcworkspace -configuration Debug -scheme myscheme -sdk iphonesimulator -derivedDataPath ios/build/datapath
What am I missing to get this working on Xcode 12?

It's hard to tell why this happens. Personally I didn't run into such issues with Xcode 12.
You can try the following:
Make sure to use the latest Detox version, sometimes specific Xcode versions require some adjustments (there's Xcode 12.4, 12.5, etc.)
Make sure your applesimutils is up to date (see instructions here).
RN apps sometimes have issues with the new build system, try adding -UseModernBuildSystem=NO to your xcodebuild command.

As per my knowledge, few previous versions of detox don't support Xcode 12. Upgrading detox might solve the issue.

Related

framework version upgrade causing problem to my project

I was building a react native project and got an upgrade message when I run "yarn run ios":
simctl[5640:1381079] CoreSimulator detected version change. Framework version (857.14) does not match existing job version (857.13). Attempting to remove the stale service in order to add the expected version. error Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues. SyntaxError: Unexpected token I in JSON at position 0、
However, after this upgrade, there is something wrong with my project. Any suggestion how to back to the old version?
I tried to use other version of ios simulator and tried to clean the xcode build, but its not help.
I ran into a similar issue. The trick was
Quit all iOS simulators
Let Xcode install the newest iOS simulators
Run the project from the Xcode workspace.
After that I was able to start the simulator again from npx react-native run-ios --simulator='iPhone 14' or yarn run iOS

How is detox code inserted into the app bundle

I use detox to run e2e tests on react native.
This artcile written by one of the people working on detox says
Gray box essentially uses a piece of code that is planted in the app, it can help us see what’s going on inside.
My question is, how does that happen? Looking at the docs the command used for detox build is
xcodebuild -project ios/YourProject.xcodeproj -scheme YourProject -sdk iphonesimulator -derivedDataPath ios/build
No detox-specific mention to be seen there.
Also, the docs state here that the build command is optional and that
You can also choose not to use it and provide a compiled app by yourself.
Well, how do I do that? How do I inject detox / make sure detox is not injected into my app? If I download compiled app from my CI server it does not work with detox (not surprisingly since the detox code is not planted into the app). But if I use the detox build command (which seem to just run whatever the build command in the config specifies), the tests work. There seems to be some "magic" happening which is not understandable for a newcomer.
Thanks.
It's magic!
Well, actually it isn't. The build step is completely optional, and as stated in the documentation, Detox works with any valid app.
In order to load Detox, we tell the dynamic linker to load it using the DYLD_INSERT_LIBRARIES environment variable. So it only loads Detox when you run detox test from the command line.
This is easy on the simulator as it has access to your Mac's file system. Once we implement support for testing on actual hardware devices, we will still use that environment variable, but we will have to inject it inside your IPA file directly.

Trouble with CLI and iOS simulator

I'm moving to a new machine and want to start out fresh. I'm leaving Appcelerator Studio behind and want to go all CLI.
The project I'm working on is still on SDK 5.5.1.
When I try to build our app for the iPhone simulator it builds fine and launches the simulator but when it tries to start the app the simulator goes black execpt for the status bar. No errors are thrown in the terminal and nothing interesting shows up in console.app
I can launch the app in the simulator on my old machine without issues (done it 1000 times or so).
I build with: appc run -p ios
This is the last output I get:
[INFO] Launching iOS Simulator
-- Start simulator log -------------------------------------------------------
[INFO] Application started
[INFO] OurAppName/2.8.1 (5.5.1.b18727f)
This is my setup:
Appcelerator Command-Line Interface, version 5.5.1
2017-02-08 14:54:46
Name = Mac OS X
Xcode 8.1
Version = 10.12.3
Node.js Version = 4.7.3
npm Version = 2.15.11
Titanium CLI Version = 5.0.9
Titanium SDK Version = 5.5.1.GA
SDK Path = /Users/-/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA
Target Platform = iphone
What am I missing?
You could try building on a specific simulator
run
appc run -p iOS --device-id
it will prompt you with all the devices available and you can choose among the list (choose an iOS 9 simulator, it looks like the problem is with the iOS 10 simulator)
Not sure if it helps, but we're using Titanium SDK 5.4.0, and so far still using Xcode 7. For another project, using Titanium 6 we are using Xcode 8.
We experienced some issues in communication between Studio/CLI and Xcode/Simulator.
if you are using Xcode 8.1 then you can use the following command
appc ti build -p ios -I 10.1
where -p is platform and -I is IOS version
if you want to check IOS version
Step 1: Go to Xcode
Step 2: Window -> Devices.
please see the image it will clear all things.
It worked for me.

Hello, World! program for React Native throws "Could not parse the simulator list output" on Mac

I just started learning React Native and was trying to run my Hello, World! app using the steps given in https://facebook.github.io/react-native/docs/getting-started.html#content
I took the following steps
1. `brew install watchman`
2. `npm install -g react-native-cli`
3. `react-native init hello`
4. `cd hello`
5. `react-native run-ios`
Instead of launching the iOS app, I got the following error in the terminal:
Found Xcode project hello.xcodeproj
Usage: simctl list [devices|devicetypes|runtimes]
Could not parse the simulator list output
I also tried to run it using Xcode; however Xcode shows lot of compilation errors.
Following are details on my system
OS: Mac OS v10.10.5 (Yosemite)
Node.js version: 4.4.1
Xcode version: Version 6.3 (6D554n)
Following is a screenshot of errors shown in Xcode.
Error disappeared after I launched Xcode and allowed to install some updates.
The problem was that I updated Xcode and never opened it after the update completed. After I opened Xcode it did install components then when I tried again it worked fine.
In my situation, I closed the current terminal and reopened it, then the error was gone.
I realized that I was using a beta version of Xcode. Once I installed the latest version of Xcode then all errors were gone and the app were launched in the simulator.

How to use xcodebuild in Xcode 7 with a watch extension

Our command used to be like this
xcodebuild -configuration Release -target "xxx" -sdk iphoneos9.0 -scheme "xxx" archive
Now in Xcode 7, we get this error:
Build settings from command line:
SDKROOT = iphoneos9.0
=== BUILD TARGET xxx WatchKit Extension OF PROJECT Mobile WITH CONFIGURATION Release ===
Check dependencies
target specifies product type 'com.apple.product-type.watchkit2-extension', but there's no such product type for the 'iphoneos' platform
How do we specify to use iOS 9.0 SDK and the watchos 2.0 SDK?
If you need a simulator build run this:
xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target -destination 'name=iPhone 6' build
And if you need a device build run this:
xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target build
The trick is that for any build you need to remove -sdk option. For simulator build you need to specify -destination which should be iPhone 6 or iPhone 6 Plus. And for devices builds you skip -destination.
There are several reasons that you're seeing this error, but it boils down to dependencies. If you select a scheme that builds an iOS target, then you don't have a problem using the following command. Note that I used iphoneos to automatically select the latest SDK.
xcodebuild -configuration Release -target "ios" -sdk iphoneos -scheme "ios" build
The problem you're running into is triggered because of a dependency on the watchOS extension. I've created a sample project and added a watchOS application. In the build phases tab, you see in the Dependencies section that the iOS target has a dependency on the WatchOS target.
This isn't a problem if you specify a destination in your build command. But it does give a problem if you tell xcodebuild to build with a specific SDK. Why? Because the WatchOS target cannot be built with the iOS SDK. If you specify iphoneos as the SDK, the build will fail.
Specifying a destination solves the problem, but know that you are using a specific simulator. If you use the same command on a different machine and that simulator isn't available, then the build will fail.
To be honest, I don't know if there's a middle road that lets you select the latest SDK and still use the correct SDK for each target, regardless of dependencies. If you remove the dependency of the iOS target, then the above build command shouldn't fail. You may also need to update the scheme you're using.