Error when attempting to run detox test with xcodebuild created .app file - react-native

I'm trying to create a .app that I can then reference in my .detoxrc.json file but I'm running into 2 issues.
This is the command I'm using...
xcodebuild -workspace ios/Boomin.xcworkspace -scheme Boomin -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=YES -arch x86_64
The only .app file I can see is created in the ios -> build -> Build -> Products -> Debug-iphonesimulator directory and it's called customer.app. It looks like customer comes from my terminal user account. How do I rename this?
When I try to run detox test --configuration ios I get the following...
detox[19353] ERROR: field CFBundleIdentifier not found inside Info.plist of app binary at /ios/build/Build/Products/Debug-iphonesimulator/customer.app
How do I resolve both these issues?
Thanks,

Related

xcodebuild test on Xcode 14: Could not find test host for DoSomethingElseTests: TEST_HOST evaluates

I'm running the following command to build and test my project:
xcodebuild -sdk iphonesimulator -configuration DoSomethingElse -project DoSomethingElse.xcodeproj -scheme DoSomethingElse -destination "platform=iOS Simulator,name=iPhone 8 Plus" test
But I'm getting this error:
Reason: Could not find test host for DoSomethingElseTests: TEST_HOST evaluates
But I run the unit test using XCode IDE works just fine.
Any of you knows what I'm doing wrong?, or if there is a way around this?
I'll really appreciate your help

How do I fix Something went wrong in #nrwl/run-commands - Command failed: detox build -c ios.sim.retail.debug

I am experiencing an issue with opening an app for the first time
detox[12987] ERROR: [cli.js] Command failed: export EXCLUDED_ARCHS=arm64 && ENVFILE=.env.dev.detox xcodebuild -workspace ./apps/retail-mobile/ios/app.xcworkspace -scheme app -configuration Debug -sdk iphonesimulator -derivedDataPath ./apps/retail-mobile/ios/build -quiet
ERROR: Something went wrong in #nrwl/run-commands - Command failed: detox build -c ios.sim.retail.debug
How do I fix this? I'm totally confused as it was working before.

iOS 14, lipo error while creating library for both device and simulator

We have been using lipo command to create a framework which works on both device and simulator when integrated in other project.
following are the build commands used to generate device and simulator builds
xcodebuild -target SampleSDK ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" OBJROOT="${OBJROOT}/DependentBuilds"
xcodebuild -target SampleSDK ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" OBJROOT="${OBJROOT}/DependentBuilds"
after this we are copying swift modules from iphonesimulator(if it exists) to the copied framework dir
cp -R "$BUILD_DIR/${CONFIGURATION}-iphonesimulator/${PRODUCT_NAME}/Modules/SampleSDK.swiftmodule/" "${UNIVERSAL_OUTPUTFOLDER}/${PRODUCT_NAME}/Modules/${PROJECT_NAME}.swiftmodule/"
and then lipo command
lipo -create "$BUILD_DIR/${CONFIGURATION}-iphonesimulator/${PRODUCT_NAME}/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PRODUCT_NAME}/${PROJECT_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${PRODUCT_NAME}/${PROJECT_NAME}"
the above command is failing with following error
fatal error: lipo: /path/to/Library/Developer/Xcode/DerivedData/Sample-bhfmlauxsdympmdjkjyvujaljevg/Build/Products/Debug-iphonesimulator/SampleSDK.framework/SampleSDK and /Users/rramshettysiddaraju/Library/Developer/Xcode/DerivedData/Sample-bhfmlauxsdympmdjkjyvujaljevg/Build/Products/Debug-iphoneos/SampleSDK.framework/SampleSDK have the same architectures (arm64) and can't be in the same fat output file
I tried one of the answers in stackoverflow, about adding user-defined setting VALID_ARCHS and then removing it. but that didnt work
The reason for the error is that Xcode 12 includes a slice for the "arm64" architecture when building for the simulator (in addition to the usual "i386" and "x86_64" architectures for Xcode <12). This is probably for supporting the simulator on (future) Macs using Apple Silicon processors. As your device build also includes the "arm64" architecture, lipo does not know which of the two "arm64" slices you want and refuses to create a combined fat binary framework.
As a workaround, you can either exclude the "arm64" architecture from the simulator build by appending the EXCLUDED_ARCHS build variable:
xcodebuild -target SampleSDK ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" OBJROOT="${OBJROOT}/DependentBuilds" EXCLUDED_ARCHS="arm64"
Alternatively, use lipo -remove to remove the "arm64" architecture from the simulator build before combining the simulator and device frameworks into one:
lipo -remove arm64 "$BUILD_DIR/${CONFIGURATION}-iphonesimulator/${PRODUCT_NAME}/${PROJECT_NAME}" -output "$BUILD_DIR/${CONFIGURATION}-iphonesimulator/${PRODUCT_NAME}/${PROJECT_NAME}"
In the long run, you might be better off building an XCFramework, which should support devices and simulators without the need for using lipo. But I haven’t tested this yet.
styv is right.
You can also set Excluded Architectures in the Xcode Build Settings
#xtyv's suggestion is spot on: using an XCFramework is the way to go.
Here is a Makefile to generate an XCFramework (apply substitutions and add other architectures accordingly to your scenario):
ARCHS = aarch64-apple-ios aarch64-apple-ios-sim
LIB = lib<library_name>.a
XCFRAMEWORK = <framework_name>-iOS.xcframework
all: $(XCFRAMEWORK)
.PHONY: $(ARCHS)
$(ARCHS): %:
cargo build --target $#
$(XCFRAMEWORK): $(ARCHS)
xcodebuild -create-xcframework $(addprefix -library , $(foreach arch, $(ARCHS),$(wildcard target/$(arch)/debug/$(LIB)))) -headers <header_file> -output $#

xcodebuild builds test target but cannot run xctest

I run a command in terminal
sudo /usr/bin/xcodebuild -project awesome.xcodeproj -scheme "AwesomeTests"
-configuration Production test -derivedDataPath ~/Documents/buildData
-sdk "OS X 10.9"
last lines of output looks like
error: failed to launch '/Applications/Xcode.app/Contents/Developer/usr/bin/xctest'
-- error: Host::LaunchProcess (launch_info) => pid=0,
path='/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver'
err = Problems with launching via XPC. XPC error : Connection interrupted (0x00000005)
** TEST SUCCEEDED **
Before outputing these lines I'm prompted with: "xcodebuild is trying to take control of a root process. Type your password to allow this"
I'm using Xcode 5.0.2.
As #trojanfoe noted, the sudo was the cause of the error.
It seems like ~/Documents/buildData folder was created with root permissions and couldn't be accessed from xtest.

GHUnit CLI Build: Availability.h errors

I am trying to do a command line build of a GHUnit target which builds fine inside Xcode. I am running the following command to build:
GHUNIT_CLI=1 xcodebuild -target
BasicBrowserUnitTest -configuration
Debug -sdk iphonesimulator4.0 build
It gets along pretty nice, until it finds an error in Availability.h, an SDK header:
/Xcode4
GM/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/AvailabilityInternal.h:56:42:
error: operator '<' has no left
operand
Obviously, I haven't made any changes to Apple's stuff, why am I getting this error and how do I fix it?
The problem is that I wasn't specifying the correct SDK version:
GHUNIT_CLI=1 xcodebuild -target
BasicBrowserUnitTest -configuration
Debug -sdk iphonesimulator4.0 build
Needed to be:
GHUNIT_CLI=1 xcodebuild -target
BasicBrowserUnitTest -configuration
Debug -sdk iphonesimulator4.3
build
Or in this case, the latest SDK version.