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.
Related
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.
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,
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 $#
I'm trying to run tests with the xcodebuild command line in this way ("Ink" is my project):
xcodebuild test -target "Ink" -sdk iphonesimulator TEST_AFTER_BUILD=YES "VALID_ARCHS=armv6 armv7 i386" -arch i386
but the command prompt give me the result:
unsupported build action 'test' - ** TEST FAILED **
What command is missing?
I guess that the command You try to run is badly ordered (the action You want to execute should always be at the end), try:
xcodebuild -target "Ink" -sdk iphonesimulator TEST_AFTER_BUILD=YES "VALID_ARCHS=armv6 armv7 i386" -arch i386 clean test
I also suppose it may be simplified to:
xcodebuild -target "Ink" -sdk iphonesimulator clean test
Which version of xcodebuild You use? Prior to 5.0 it was impossible to execute test action from command line.
I am using scan-build (checker-258) from the command line to do static analysis on my iOS project and find that uncovers far fewer issues than xcode (about 60% less). If I set xcode 4.2 to use scan-build from checker-258 it finds all the issues (and more). This may be because the command line version us using the old (not modern) run time as it is finding issues like:
error: synthesized property 'foo' must either be named the same as a compatible ivar or must explicitly name an ivar
#synthesize foo;
^
Here is the command I'm using to run the analysis:
scan-build --use-cc=`which clang` -k -o scan-reports xcodebuild -target MyTarget -project myproject.xcodeproj -sdk iphonesimulator5.0 -configuration Debug clean build
Thanks in advance.
Yes, the version of the static analyzer that ships with Xcode 4.2 is older than the version on the clang website. There are instructions here on how to use the newer version within Xcode: http://clang-analyzer.llvm.org/xcode.html
Try to use this command: scan-build -k -V -o scan-reports xcodebuild clean build -configuration Debug -sdk iphoneos5.0 -xcconfig="myConfig.xcconfig"
Where myconfig contains the CODE_SIGNING_IDENTITY="", PROVISIONING_PROFILE=""