xcodebuild did not generate Coverage.profdata for cocospods project - jenkins

i want to get my project's code coverage (which is managed by cocoapods), i run the following cmd :
xcodebuild -scheme KVODemo -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 6' -enableCodeCoverage YES -workspace KVODemo.xcworkspace test
but i can not find the Coverage.profdata file (for normal project which is not managed by cocoapods is under the $PROJECT_TEMP_ROOT/CodeCoverage/$PROJECT_NAME/Coverage.profdata)
i just want to know how to get the code coverage for cocoa pods project.

ok , after a detail look at the cmd xcodebuild , i noticed something.
here is some info in the "man xcodebuild":
xcodebuild -showBuildSettings
[-project name.xcodeproj |
[-workspace name.xcworkspace -scheme schemename]]
the $PROJECT_TEMP_ROOT i mentioned in my question is the result of
xcodebuild -showBuildSettings |grep PROJECT_TEMP_ROOT
and this should the same as the xcodebuild -showBuildSettings -project xxx.xcodeproj
because my project is managed by cocoa pods, so i should get the $PROJECT_TEMP_ROOT in this way :
xcodebuild -showBuildSettings -workspace xxx.xcworkspace -scheme xxx
and finally , find the Coverage.profdata in the $PROJECT_TEMP_ROOT/CodeCoverage/$PROJECT_NAME/Coverage.profdata

Related

iOS app distribution failed with error ITMS-90635 nested bundle contains arm64(machine code) whereas main bundle contains arm64(bitcode)

I have made my own fat framework that I distribute over Cocoapods.
But when I try to upload an app with bitcode enabled using my framework, I am rejected with error ITMS-90635, see:
I want my framework to be compatible with bitcode, so I set ENABLE_BITCODE=YES, BITCODE_GENERATION_MODE=bitcode (also tried with OTHER_CFLAGS="-fembed-bitcode" in addition) when building the framework.
Here is how I build my framework:
[...]
echo "Clean ${TARGET_NAME} for simulator"
xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' -scheme ${SCHEME} CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=YES BITCODE_GENERATION_MODE=bitcode clean
echo "Clean ${TARGET_NAME} for generic device"
xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -configuration ${CONFIGURATION} -destination generic/platform=iOS -scheme ${SCHEME} CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=YES BITCODE_GENERATION_MODE=bitcode clean
echo "Build ${WORKSPACE_NAME} for simulator"
xcrun xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -scheme ${SCHEME} -configuration ${CONFIGURATION} -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=YES BITCODE_GENERATION_MODE=bitcode
echo "Build ${WORKSPACE_NAME} for generic device"
xcrun xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -scheme ${SCHEME} -configuration ${CONFIGURATION} -destination generic/platform=iOS -sdk iphoneos CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=YES BITCODE_GENERATION_MODE=bitcode
[...]
lipo -create "${DEVICE_BIN}/${TARGET_NAME}" "${SIMULATOR_BIN}/${TARGET_NAME}" -output "${UNIVERSAL_PATH}/${TARGET_NAME}.framework/${TARGET_NAME}"
What I really do not understand is that my framework seems to have bitcode enabled, see:
Am I doing something wrong when building my framework?
Ok, I finally found what was wrong :)
Once lipo done, I used to copy/paste
Build/Products/Release-iphoneos/MyFramework.framework/Modules/MyFramework.swiftmodule/
into
Build/Products/Release-iphonesimulator/MyFramework.framework/Modules/MyFramework.swiftmodule/
and then I was distributing this final framework:
Build/Products/Release-iphonesimulator/MyFramework.framework.
Do the opposite! Once lipo done, copy/paste MyFramework.swiftmodule/'s Release-iphonesimulator/ into the Release-iphoneos/ one and distribute the .framework in Release-iphoneos/.

TravisCI.yml for iOS, destination not correct

I have a simple iOS app that I want to use in Travis CI. I use a matrix with TEST_SDK and TEST_DESTINATION. However, the destination doesn't seem to work properly.
This is my .travis.yml:
language: objective-c
osx_image: xcode9.2
cache: cocoapods
before_install:
- pod repo update
- pod update
env:
matrix:
- TEST_SDK=iphonesimulator11.1 TEST_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.1"
- TEST_SDK=iphonesimulator11.2 TEST_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.2"
script:
- xcodebuild test -workspace iOSApp.xcworkspace -scheme iOSApp -sdk $TEST_SDK -destination $TEST_DESTINATION | xcpretty
The problem is that when I run the script locally, I get this output: xcodebuild: error: Unknown build action '7'.
When I run xcodebuild test -workspace iOS.xcworkspace -scheme iOS -sdk $TEST_SDK -destination platform="iOS Simulator",name="iPhone 7 Plus",OS=11.2 | xcpretty it works fine.
Therefore, I replaced the .travis.yml with : - TEST_SDK=iphonesimulator11.2 TEST_DESTINATION=platform="iOS Simulator",name="iPhone 7 Plus",OS=11.2 for example. However, this errors again with xcodebuild: error: Unknown build action '7'.
How can I get this to work correctly?
I got it working with this:
export TEST_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.1"
and for the build use TEST_DESTINATION in double quotes like
xcodebuild test -workspace iOSApp.xcworkspace -scheme iOSApp -sdk $TEST_SDK -destination "$TEST_DESTINATION" | xcpretty

Unable to build ios app for simulator using xcodebuild

I am currently want to create a debug simulator build using xcodebuild command rather than xcode IDE.
however, I always see a "debug-iphoneos" folder is generated, which is for the real device. I expected the simulator output folder "Debug-iphonesimulator"
Can anyone take a look at my script and suggest why the script is not working for simulator?
xcodebuild -scheme "TestApp" -configuration "Debug" -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' -workspace TestApp.xcworkspace clean archive -archivePath build/TestApp PROVISIONING_PROFILE="$provisioningUUID" CODE_SIGN_IDENTITY="$codeSignIdentity"
now I can run successfully as below:
xcodebuild -arch i386 -sdk iphonesimulator9.3 -workspace "$app.xcworkspace" -scheme "$scheme" -configuration "Debug"
You should run the following instead:
xcodebuild -arch i386 -sdk iphonesimulator9.1 -workspace [name].xcworkspace -scheme [targetName or ProjectName] ONLY_ACTIVE_ARCH=NO VALID_ARCHS="i386 x86_64"
where iphonesimulator9.1 depends on which iPhone Simulator you installed.

Compile for ios simulator and run UITest in 2 times

I try to compile my app for UITesting and in a second time run the UITest on iOS simulator. But I need to do this in 2 times.
In one time I use :
xcodebuild -workspace './MyApp.xcworkspace' -scheme 'MyScheme' -derivedDataPath '~/Documents/derived_data/' -destination 'platform=iOS Simulator,id=6EE927C0-FC0E-4235-8915-3BFF1F128B76,OS=9.2' build test | xcpretty
Any Idea how to copy and launch MyApp.app, MyAppUITests-Runner.app in the simulator?
Thanks.
Alak
Edit:
Anyway to launch something like :
xcrun simctl launch "UITest"
and get xcactivitylog from this ?
try this:
xcodebuild -workspace App.xcworkspace -scheme "App-Scheme" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1' test
it will compile the App and run the UI Test in the simulator.

xcodebuild PLATFORM_NAME always == iphoneos

I am trying to build Xcode project from command line, using iphonesimulator as SDK. Here is the command line:
xcodebuild -scheme SchemeName -configuration Debug -sdk iphonesimulator PLATFORM_NAME=iphonesimulator clean build
However, when I add a post-build action in Xcode like:
echo "PLATFORM_NAME: ${PLATFORM_NAME}"
it always outputs "PLATFORM_NAME: iphoneos" and not iphonesimulator.
Is this a bug, or there is something wrong in my build configuration? Thanks

Resources