Travis fails after renaming a swift class - swift

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

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

Swift project on GitHub travis-ci check always fail?

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"

rhomobile build for iphone fails, provisioning profile can't be found

I got a simple application I want to run on my iphone. However I get a annoying error the provisioning profile can not be found. It happens after I go to my project folder and run:
sudo rake device:iphone:production
=== BUILD NATIVE TARGET RhoLib OF PROJECT RhoLib WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET rhoextlib OF PROJECT rhoextlib WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET curl OF PROJECT curl WITH CONFIGURATION Release ===
Check dependencies
=== BUILD NATIVE TARGET rhorunner OF PROJECT rhorunner WITH CONFIGURATION Release ===
Check dependencies
Code Sign error: Provisioning profile '0558F1B2-FE5A-4236-B9EE-A200EFAD68E9' can't be found
cd ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rhodes-3.3.3
set bundle identifier
set URL name
restore_default_images
rm -f platform/iphone/Default.png
rm -f platform/iphone/Default.png
cp platform/iphone/Default.bak platform/iphone/Default.png
rm -f platform/iphone/Default.bak
rm -f platform/iphone/Default#2x.png
rm -f platform/iphone/Default-Portrait.png
rm -f platform/iphone/Default-PortraitUpsideDown.png
rm -f platform/iphone/Default-Landscape.png
rm -f platform/iphone/Default-LadscapeLeft.png
rm -f platform/iphone/Default-LandscapeRight.png
restore icon
rm -f platform/iphone/icon.png
cp platform/iphone/icon.bak platform/iphone/icon.png
rm -f platform/iphone/icon.bak
rm -f platform/iphone/icon57.png
cp platform/iphone/icon57.bak platform/iphone/icon57.png
rm -f platform/iphone/icon57.bak
rm -f platform/iphone/icon72.png
cp platform/iphone/icon72.bak platform/iphone/icon72.png
rm -f platform/iphone/icon72.bak
rm -f platform/iphone/icon114.png
cp platform/iphone/icon114.bak platform/iphone/icon114.png
rm -f platform/iphone/icon114.bak
************************************
ERROR during building by XCode !
XCode return next error code = pid 9102 exit 65
I checked the xcode organizer and the profile is both on the phone and the library.
I checked developer.apple.com and the profile is Distribution Ad Hoc for the device plugged in.
My build.yml:
sdkversion: 3.3.2
name: My Application
version: 0.1
vendor: rhomobile
build: release
bbver: 4.6
applog: rholog.txt
iphone:
provisionprofile: 0558F1B2-FE5A-4236-B9EE-A200EFAD68E9
sdk: iphoneos5.1
codesignidentity: "iPhone Distribution"
entitlements:
configuration: Release
emulator: 5.1
emulatortarget: iphone
BundleIdentifier: com.randomname.myapplication
BundleURLScheme: myapplication
wp:
productid:
uid: 3928127822
android:
version: 2.1
extensions:
- accelerometer
Anyone got a clue what I missed here? Already been trying different things for a few days without result :(
After a while I found that the script checks for the provisioning profile in /Library/MobileDevice/Provisioning Profiles instead of ~/Library/MobileDevice/Provisioning Profiles. This is caused by using the sudo command, however without sudo I dont have permission. Workaround is to create a /Library/MobileDevice/Provisioning Profiles folder and copy the installed profile to that location. Code signing works fine now.
edit: even a better solution is to reinstall the rhodes gem without sudo. By installing the suite I had to sudo it to make system changes, however this made the compilation require sudo as well and therefor look in the wrong place for provisioning profiles.
This did the trick:
sudo gem uninstall rhodes
gem install rhodes

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

command-line library build fails with linker error

I am getting a library not found error building GraphViz current release (June 7 2012) with Xcode 4.3 using a script. I may have made mistakes updating build scripts from other people's successful recipes for the new location of Xcode4.3 and the developer tools in the Applications folder.
ld: library not found for -lcrt1.10.6.o
(doing this from memory so exact number on the CRT lib may be wrong)
Am also a little lost also how I would incorporate this into an Xcode build in the IDE. I am a very experienced programmer but having trouble finding my way around Xcode 4 at times. (Decades of Visual Studio et al).
I have copied the instructions from this earlier question and adapted
#!/bin/sh
# For iPhoneOS, see http://clang.llvm.org/ for options
export DEV_iOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
# was /Developer/Platforms/iPhoneOS.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneOS5.1.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/clang
export CXX=${COMPILER_iOS}/clang++
export LDFLAGS="-arch armv7 -pipe -Os -gdwarf-2 -mthumb -isysroot ${SDK_iOS}"
export CFLAGS="${LDFLAGS}"
export OBJCFLAGS="${LDFLAGS}"
export CXXFLAGS="${LDFLAGS} -fvisibility-inlines-hidden"
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/clang
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP="${COMPILER_iOS}/clang++"
export OBJC=${COMPILER_iOS}/clang
export RANLIB=${COMPILER_iOS}/ranlib
./configure \
--build=arm-apple-darwin11 \
--host=arm-apple-darwin11 \
--disable-dependency-tracking \
--enable-shared=no \
--enable-static=yes \
--enable-ltdl=no \
--enable-swig=no \
--enable-tcl=no \
--srcdir=${GVROOT} \
--with-codegens=no \
--with-cgraph=no \
--with-graph=yes \
--with-expat=no \
--with-fontconfig=no \
--with-freetype2=no \
--with-ipsepcola=yes \
--with-libgd=no \
--with-quartz=yes \
--with-visio=yes \
--with-x=no
The compiler normally uses crt1.o combined with crt[i/n].o and crt[begin/end].o to support the constructors and destructors (functions called before and after main and exit).
This error could be caused by this missing library file for the specific deployment target.
First, do some investigation, like:
list all your deployment targets:
ls -la /Developer/SDKs
and find which crt1 libraries do you have for which environment
find /Developer/SDKs -name crt1\*
You could see something like:
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.5.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.o
So as you can see, crt1.10.6.o is missing for MacOSX10.5.
Solution 1:
You can solve that by creating the link to the missing file pointed to the other environment, or you could change your deployment target.
E.g.
ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o /Developer/SDKs/MacOSX10.5.sdk/usr/lib/
Also this could be caused, that you have different gcc installed in your system. See:
which gcc;
xcrun -find gcc;
brew list | grep gcc; brew list gcc47
Solution 2
So when you're compiling using make, you can actually specify the right compiler by CC variable. E.g.
CC=/path/to/gcc-3.4 make
Solution 3
What you can also try is specifying the right target deployment environment variable for gcc, by executing the following lines:
export MACOSX_DEPLOYMENT_TARGET=10.5
export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
If this works, then you can add above lines to your shell profile (~/.profile) to make the change permanent.
How to test
Create the example conftest.c file with the following code:
#ifdef __GNUC__
yes;
#endif
And try to compile it via:
gcc conftest.c
cc conftest.c
cc conftest.cc conftest.c
Troubleshooting
To see which exactly what file is missing, try to debug it using dtruss, e.g.:
sudo dtruss -f gcc conftest.c 2>/dev/stdout | grep crt
You should see something like:
12426/0xb4e3b: stat64("/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/crt1.10.6.o\0", 0x7FFF5FBFE780, 0xB) = -1 Err#2
So once you found the missing file, then you can follow by the first solution by linking the missing file from existing location (e.g. locate crt1.10.6.o). If you will have other missing symbols, then try another file (check the architecture before by: file `locate crt1.10.6.o`).
E.g.
sudo ln -s /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/crt1.10.6.o /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/crt1.10.6.o
sudo ln -s /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/crt1.10.6.o /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64/crt1.10.6.o
Related
Error in xcode project: ld: library not found for -lcrt1.10.6.o
If I remember correctly this is what fixed the library not found problem.
CFLAGS="$(OTHER_CFLAGS) -miphoneos-version-min=5.0"
LDFLAGS="$(OTHER_LDFLAGS) --miphoneos-version-min=5.0"
To link this to Xcode, under Build Settings then Header and Library search paths you need to add the paths to the built versions of the library and the header.
You can add the build script as part of your Xcode project, but I haven't had success with this, plus you should only need to build it once per version, so putting the time into anything other than a build script doesn't have much return.
If you decide to put the script in your project anyway (good luck!), then go to the build phases tab, add a build phase of type "Run Script" and paste your script there.