Travis-CI with: ERROR: Cannot find schemes - ios

This is my .travis.yml file
language: objective-c
osx_image: xcode7.2
script:
xctool -project ProjectName.xcodeproj -scheme ProjectName build -sdk iphonesimulator
While Travis is running I've got this error:
$ xctool -project ProjectName.xcodeproj -scheme ProjectName build -sdk iphonesimulator
ERROR: Cannot find schemes. Please consider creating shared schemes in Xcode.
TIP: This might happen if you're relying on Xcode to autocreate your schemes
and your scheme files don't yet exist. xctool, like xcodebuild, isn't able to
automatically create schemes. We recommend disabling "Autocreate schemes"
in your workspace/project, making sure your existing schemes are marked as
"Shared", and making sure they're checked into source control.

This problem is easy to solve:
Go to your project scheme and click Manage Schemes...
Tick Shared for your scheme
Click Close, commit and push.
Problem Solved. Now Travis is working without problems.
I also wrote a post in my blog about Travis-CI.

In addition to the answer by Gabriel.Massana, make sure the files are checked into version control (SVN/GIT).

Related

How can I build the Xcode-generated Swift Package Workspace with xcodebuild?

When you open a Package.swift file, Xcode will generate a workspace with the path: .swiftpm/xcode/package.xcworkspace.
I'd like to use xcodebuild to build this but it does not seem to work. The error messages are not helpful, just tells me that clang failed.
The actual command I'm running is:
xcodebuild -workspace .swiftpm/xcode/package.xcworkspace -scheme MyLibrary-Package -sdk iphonesimulator OTHER_SWIFT_FLAGS="-D SWIFT_PACKAGE"
Funny enough, trying to build a scheme that describes an individual target works:
xcodebuild -workspace .swiftpm/xcode/package.xcworkspace -scheme SpecificTarget -sdk iphonesimulator OTHER_SWIFT_FLAGS="-D SWIFT_PACKAGE"
Am I missing some build flags needed to build the combination scheme? Has anyone else struggled with this and have any advice?
Note:
The ultimate goal here is to be able to verify that my Swift Package builds in CI. If there is an easier way to achieve this goal then I'm happy to go another route. (The easier might just be multiple commands to build the individual targets but this is less robust)

Xcodebuild is not creating an app

I'm trying to create a simulator app to submit to Facebook for review. I've followed their instructions to the letter, but keep running into problems. I am using CocoaPods and have a workspace instead of a plain old project. Here's the command I'm running:
xcodebuild -arch i386 -sdk iphonesimulator8.1 -workspace [APP].xcworkspace -scheme [APP]
I get a ** BUILD SUCCEEDED ** message, but either one of two things will happen:
No build folder is created, and I can't find where the .App file is.
A .App is created in a build folder, but is 0 bytes in size and crashes when running with ios-sim.
I read that changing the Run scheme to 'Release' might fix it, but that didn't do anything. Any ideas?
So, I had the same problem and solved it by doing the following:
I made my app as release build instead of debug in xcode: Product->Scheme->Edit Scheme and then Build Configuration set to Release.
After doing this I then went back to the command line and added a destination for the build:
xcodebuild -arch i386 -sdk iphonesimulator8.1 -workspace [APP].xcworkspace -scheme [APP] -derivedDataPath /path/to/build
If you are still having problems make sure you clean and build all of your targets (pods included) and try the above steps again.
Hope this works; it did for me.

xctool fails to clean my iOS project

I'm using xctool (v0.1.16) for an iOS project, which is configured as follows:
a workspace
two targets Project and ProjectTests
two schemes Project and ProjectTests
I have a .xctool-args file with the workspace and Project scheme configured.
I run xctool build and xctool -scheme ProjectTests -sdk iphonesimulator test successfully.
However, I run xctool clean and the following happens:
1st it runs xcodebuild clean Project successfully
2nd it runs xcodebuild build clean which fails with the error:
Scheme Tests is not currently configured for the clean action.
It is strange because I don't have a Tests scheme at all.
I run xctool clean -showTasks and have more details about the error. It runs and fails at
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild \
-configuration Debug \
-workspace /var/folders/b7/472b_skj24gf7wmw6c3krp5c0000gn/T/xctool_temp_KMbH0e/Tests.xcworkspace \
-scheme Tests \
OBJROOT=/Users/paristote/Library/Developer/Xcode/DerivedData/Project-fmyqwebczmtplydrfhcmrdzezcft/Build/Intermediates \
SYMROOT=/Users/paristote/Library/Developer/Xcode/DerivedData/Project-fmyqwebczmtplydrfhcmrdzezcft/Build/Products \
SHARED_PRECOMPS_DIR=/Users/paristote/Library/Developer/Xcode/DerivedData/Project-fmyqwebczmtplydrfhcmrdzezcft/Build/Intermediates/PrecompiledHeaders \
-IDECustomDerivedDataLocation=/var/folders/b7/472b_skj24gf7wmw6c3krp5c0000gn/T/xctool_temp_KMbH0e/DerivedData \
clean
However, the same command executed separately finishes successfully.
The workspace at /var/folders/b7/472b_skj24gf7wmw6c3krp5c0000gn/T/xctool_temp_KMbH0e/Tests.xcworkspace simply references two projects, the Project xcodeproj and Pods xcodeproj. It does contain a Tests scheme with a build action.
Why does this command fail in the 1st place? Any help is appreciated.
Cheers.
I fixed this issue by checking the "shared" box for the main scheme:
Choose Product > Scheme > Manage Schemes.
Select the Shared option for the scheme to share, and click OK.
source: https://developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/SchemeShare.html
I fixed it by
Unchecking auto create schemes in XCode scheme management
Removing and recreating the scheme(s) I wanted to build (in your case Project and ProjectTests)
I ran into this issue in xCode 7. I fixed this issue by doing the following:
- Choose Product > Scheme > Manage Schemes.
- Select the "Shared" option for the scheme, and click OK

Xcode Build for Profiling via Terminal

I'm trying to build my XCode project via the terminal. I'd like use Xcode's Product > Build for > Profiling option. So far I have:
xcodebuild -project "MyGame.xcodeproj" -target "MyGameEditor - Mac" -destination 'name=My Mac 64-bit' -configuration Profile
The project builds but not for profiling. I get an error that configuration 'Profile' does not exist.
Any help is appreciated.
What you are trying to sepcify with -configuration is the build configuration, not the build action. Unless you have added extra configurations to your project, you only have "Debug" and "Release" configurations.
What Xcode does when you tell it to profile is it builds the configuration that your scheme specifies to use when profiling, launches the simulator, installs the app, then launches Instruments.
So you need to do a similar thing with two command line calls, one to xcodebuild, one to instruments.
Some helpful links that should help you figure out what you need to do:
http://blog.manbolo.com/2013/04/09/launching-uiautomation-tests-in-command-line
Can the UI Automation instrument be run from the command line?
It is also worth noting that rather than specifying a target and configuration, you should just specify a scheme which provides both and other optional additional features.

Xcode: How to make xcodebuild build a project that contains sub-projects

I have an Xcode project that contains several sub-projects (framework projects that compile as lib files) as part of the main project. The project compiles/builds properly in Xcode (builds the sub-projects correctly from the bottom of the hyarchial tree up to the main app project).
I am now trying to set up the project for Continuous Integration, and when I attempt to build from the command line using xcodebuild... the build fails due to not finding the .a files that should have been built before the main project.
I can build each of the lib files from the cmd line independently, but the entire consolidated project fails. Even though I have the dependancies correctly managed in the target scheme and if I specify the target or scheme when I use xcodebuild, it still will not build the sub-projects.
Is there a way to make xcodebuild build the sub-projects and then the main project as it does in the Xcode IDE? If not, would this work if I converted the entire project into a workspace?
Any help or suggestions would be greatly appreciated. I am running Xcode 5.1.1 on Mavericks.
The solution was a simple one... using the "-scheme" flag instead of "-target" allowed the project to build correctly (all sub-projects/frameworks and then target App)
FAILED:
xcodebuild -project MyProject.xcodeproj -target MyProject -sdk "iphoneos" -configuration “Build” archive OBJROOT=../../build_iOS/Obj.root SYMROOT=../../build_iOS/Sym.root
BUILT AS EXPECTED:
xcodebuild -project MyProject.xcodeproj -scheme MyProject -sdk "iphoneos" -configuration “Build” archive OBJROOT=../../build_iOS/Obj.root SYMROOT=../../build_iOS/Sym.root
There was no need to convert the project to a workspace.
You need to use a workspace to build multiple projects. Also, since you are moving to a CI server, be sure to share your schemes.

Resources