Swift project on GitHub travis-ci check always fail? - swift

I don't know how to edit my .travis.yml. Every time travis-ci check fail, I am almost crazy!
This is my travis-ci link: https://travis-ci.org/liman123/DebugMan
This is my .travis.yml, is there anything wrong? Thanks!
osx_image: xcode8.3
language: objective-c
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace
DebugMan.xcworkspace -scheme DebugMan -sdk iphonesimulator -destination
'platform=iOS Simulator,name=iPhone 6,OS=latest' ONLY_ACTIVE_ARCH=NO |
xcpretty
- pod lib lint

language: objective-c
script:
- xctool -project example.xcodeproj -scheme exampleTests build test -sdk
iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES
GCC_GENERATE_TEST_COVERAGE_FILES=YES
after_success:
- bash <(curl -s https://codecov.io/bash)

Wrap your first script command in double quotes:
"set pipefail ... | xcpretty"

Related

Swiftlint unused_import rule does not work

I am using swiftlint for my project with SPM
I want to use unused_imports rule like this:
...
analyzer_rules:
- unused_import
...
But it does not find any violations, even thought they are in the project
I have also tried turn it on in the opt-in-rules section
Do you have any ideas, why this could happened?
I am running swiftlint lint --autocorrect
I found the solution
You need to build your project (or workspace) using xcodebuild tool and save the build logs
Then you may use it to run swiftLint analyze
I created this makefile script to do so:
# Run swiftlint analyze
lint-analyze:
make clean
xcodebuild \
-project <YOUR_PROJECT>.xcodeproj \
-scheme <YOUR_SCHEME> \
-destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \
> xcodebuild.log
swiftlint analyze --fix --compiler-log-path xcodebuild.log --quiet
swiftlint lint --fix --format --quiet

How to compile framework for Mac Catalyst on Xcode 12?

I have been trying to compile the aws-sdk-ios for Mac Catalyst but I wasn't successful yet. Below there is the script that I use to compile for armv7 and x86_64 (simulator).
# Build .a files
xcodebuild ARCHS="i386 x86_64" \
ONLY_ACTIVE_ARCH=NO \
-configuration Debug \
-project "${project_path}" \
-target "${project_name}" \
-sdk iphonesimulator \
SYMROOT=$(PWD)/builtFramework
xcodebuild ARCHS="armv7 arm64" \
ONLY_ACTIVE_ARCH=NO \
-configuration Release \
-project "${project_path}" \
-target "${project_name}" \
-sdk iphoneos \
SYMROOT=$(PWD)/builtFramework
This correctly compiles the project and results into these folders:
I tried to compile the project for Mac Catalyst with multiple variations of the code below (based in multiple examples on the internet):
xcodebuild ONLY_ACTIVE_ARCH=NO \
-project "${project_path}" \
-target "${project_name}" \
-destination "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac"
SYMROOT=$(PWD)/builtFramework
This seems to not create any Release-maccatalyst folder or anything else, even adding these flags:
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES SUPPORTS_MACCATALYST=YES
Or these:
ARCHS="x86_64" VALID_ARCHS="x86_64"
(Also tried with x86_64h, no luck)
With the ARCHS flags above, the compilation fails with these errors:
I am not sure what I need to do to compile the project, anyone could please help me to find the correct script to create the .framework for Catalyst?
Regards,
Pedro

Travis fails after renaming a swift class

I was doing some refactoring on a Xcode Swift project. We had a spelling mistake in the name of a class which I corrected, both in the name of the class and in its declaration. Of course I changed every occurence as well.
The iOS projects builds and runs fine on my machine, but it does not on Travis. When I take a look into the travis logs I can see that the old file name is still in the build path – of course then it has to fail cause it won't be able to find that file.
Here's the .travis.yml
language: objective-c
osx_image: xcode9.2
before_install:
- gem install cocoapods
- pod setup
- pod install
script:
- export LC_ALL=en_US.UTF-8
- xcodebuild clean -project DQ-iOS-App.xcodeproj \
-scheme DQ-iOS-App CODE_SIGNING_REQUIRED=NO
- xcodebuild -verbose -workspace "DQ-iOS-App.xcworkspace" \
-scheme "DQ-iOS-App" -destination "platform=iOS Simulator,name=iPhone 8,\
OS=11.2" CODE_SIGNING_REQUIRED=NO
What am I missing here?
You can try to delete derrived data:
rm -rf ~/Library/Developer/Xcode/DerivedData

xcodebuild not building library for simulator

I'm running a script to build a static library for the device and the simulator to later be merged using lipo.
To build both versions I'm using the following commands:
xcodebuild -target ${L_NAME} -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target ${L_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
The problem is that no iphonesimulator version is created. Inside the Products folder only a Debug-iphoneos version exists.
I eventually found out the problem, I didn't have i386 as a valid architecture

Use ant to create .ipa file

I want to clean, build and create .ipa file using an ant script. Also I need to set the application icon. I searched the web but couldn't find a solution. And i prefer to run the ant through the terminal.
Try searching for Ant + XCodeBuild. There should be plenty examples out there that give you a general idea how you can script an XCode build from ANT.
Key is the terminal xcodebuild command and you can only do this with Ant if you run your build on a Mac.
You can create a script.sh instead a Ant with this:
#!/bin/sh
cd {PROJECT_BUILDDIR}
xcodebuild -sdk iphoneos5.1 -configuration Release "ARCHS=armv6 armv7" clean build
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILDDIR}/${PROJECT_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}"
And for start this, open Terminal and write:
sudo bash script.sh
This is is not tested, maybe exist a some small errors
For some tips