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.
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.
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 create a Xamarin iOS binding for this Objective C library SPSlideTabController.
I have created a static library and am now in the process of creating a fat binary. I have the Makefile set up correctly and saved in the same folder as my static library. Not inside the static library folder though. Then I run the make command in the terminal.
Each time I have tried, only one file is generated libSPSlideTabController-i386.a then I get 4 build errors:
** BUILD FAILED **
The following build commands failed:
CompileC build/SPSlideTabBarController.build/Release-iphoneos/SPSlideTabBarController.build/Objects-normal/armv7/SPAppearance.o SPSlideTabBarController/Appearance/SPAppearance.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/SPSlideTabBarController.build/Release-iphoneos/SPSlideTabBarController.build/Objects-normal/armv7/SPSlideTabBarItem.o SPSlideTabBarController/SPSlideTabBar/SPSlideTabBarItem.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/SPSlideTabBarController.build/Release-iphoneos/SPSlideTabBarController.build/Objects-normal/armv7/SPSlideTabBar.o SPSlideTabBarController/SPSlideTabBar/SPSlideTabBar.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/SPSlideTabBarController.build/Release-iphoneos/SPSlideTabBarController.build/Objects-normal/armv7/SPSlideTabBarController.o SPSlideTabBarController/SPSlideTabBarController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(4 failures)
make: *** [libSPSlideTabBarController-armv7.a] Error 65
The ---armv7.a and the ---SDK.a files are not generated.
What am I doing wrong?
Here's my Makefile
XBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
PROJECT_ROOT=./SPSlideTabBarController
PROJECT=$(PROJECT_ROOT)/SPSlideTabBarController.xcodeproj
TARGET=SPSlideTabBarController
all: lib$(TARGET).a
lib$(TARGET)-i386.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator
-configuration Release clean build
-mv $(PROJECT_ROOT)/build/Release-iphonesimulator/lib$(TARGET).a $#
lib$(TARGET)-armv7.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch
armv7 -configuration Release clean build
-mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $#
lib$(TARGET)-arm64.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch
arm64 -configuration Release clean build
-mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $#
lib$(TARGET).a: lib$(TARGET)-i386.a lib$(TARGET)-armv7.a
lib$(TARGET)-
arm64.a
xcrun -sdk iphoneos lipo -create -output $# $^
clean:
-rm -f *.a *.dll
It's better that you share your MAKE file.
I normally open the code in XCode then add a runscript using my GIST here
You could follow this guide for more details.
The command xctool -workspace Foo.xcworkspace -scheme Foo -sdk macosx -configuration Debug test -test-sdk macosx works locally and all of the tests pass.
Using Travis I get the following error:
Failed to query the list of test cases in the test bundle: dlopen(/Users/travis/Library/Developer/Xcode/DerivedData/Foo-bvxkmfrwzzvtxgaeoosknyzjovjc/Build/Products/Debug/OS X Tests.xctest/Contents/MacOS/OS X Tests, 2): Symbol not found: _NSURLSessionTransferSizeUnknown
Referenced from: /Users/travis/Library/Developer/Xcode/DerivedData/Foo-bvxkmfrwzzvtxgaeoosknyzjovjc/Build/Products/Debug/OS X Tests.xctest/Contents/MacOS/OS X Tests
Expected in: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
in /Users/travis/Library/Developer/Xcode/DerivedData/Foo-bvxkmfrwzzvtxgaeoosknyzjovjc/Build/Products/Debug/OS X Tests.xctest/Contents/MacOS/OS X Tests
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
** TEST FAILED: 0 passed, 0 failed, 0 errored, 0 total ** (21121 ms)
The command "xctool -workspace Foo.xcworkspace -scheme Foo -sdk macosx -configuration Debug test -test-sdk macosx" exited with 1.
My .travis.yml file is as follows:
language: objective-c
before_install:
- gem install cocoapods --no-ri --no-rdoc --no-document --quiet
- brew update
- brew uninstall xctool
- brew install xctool
script:
- xctool -workspace Foo.xcworkspace -scheme Foo -sdk macosx -configuration Debug test -test-sdk macosx
Why does this happen and how can I fix this?
Travis does not currently support Mavericks which is the root cause of the problem.
Support for 10.9 is being tracked in this issue on GitHub.
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.