I have a little problem with one of my projects. In my workspace I have my main project and a lot of projects for static libraries. When I build from Xcode, everything works fine, but with xcodebuild, one of my project is not built, it seems that implicit dependencies do not work.k. Maybe I did something wrong with my configuration. So there it is.
My scheme configuration:
My QAPreferences.a information:
My target settings:
From Xcode, if I build with buildAppTarget in debug for iphoneos, it works.
From xcodebuild, with command below, QAPreferences project is not built.
xcodebuild -workspace myProject.xcworkspace -scheme buildApp -configuration Debug -sdk iphoneos
It worked before, but I recently added QAPreferences, and it does work since this moment. Maybe the problem comes from QAPreferences project...
Regards,
Quentin
So I finally found why the QAPreferences was not build through xcodebuild but I still do not understand the reason. In fact QAPreferences 'Build Archive Architecture Only' was set to YES, I just set it to NO and now it works!
I had a similar issue but forgot to specify the -workspace argument to xcodebuild, which led to it seeming like the implicit dependencies weren't working correctly. I realize this wasn't the issue with the original question, but for people having issues with implicit dependencies, this could be helpful.
Related
We have several different proprietary API provided to us as Frameworks that offer similar functionality. The API is of course not identical, so we want to build a wrapper facade Framework around these, so our apps do not need to care which of the API they are using.
As a start, I have created a framework that uses one of these APIs and has unit tests that verifies that it works as expected. We have added the third party framework binary as a part of the project, and the Framework search path is like this:
$(inherited)
$(PROJECT_DIR)/Carthage/Build/iOS
$(PROJECT_DIR)
All non-recursive. The Cartage path is here because we use Quick and Nimble for our unit tests. I have the framework in question stored at the project root.
We want to distribute our framework using Carthage, and later also as a Cocoapod.
The problem is that when I try to build our framework by the command: carthage build --no-skip-current --platform iOS, I get the error:
*** Building scheme "Nimble-iOS" in Nimble.xcodeproj
*** Building scheme "Quick-iOS" in Quick.xcworkspace
*** Building scheme "XXX" in XXX.xcodeproj
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -project /Users/andre/Development/yyy/xxx/XXX.xcodeproj -scheme XXX -configuration Release -sdk iphonesimulator -destination platform=iOS\ Simulator,id=AE9E3D9D-BE2C-4AE1-AB37-C6BE8948067B -destination-timeout 3 ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES build (launched in /Users/andre/Development/yyy/XXX)
And the log contains this:
iphonesimulator/XXX.build/Objects-normal/i386/XXXLockService.o
/Users/andre/Development/yyy/XXX/XXX/LockServiceFactory.swift:7:71: error: 'PinServiceAccessImpl' is unavailable: cannot find Swift declaration for this class
case .xxx: return XXXLockService(lockService: PinServiceAccessImpl.getInstance())
^~~~~~~~~~~~~~~~~~~~
PinServiceAccess.PinServiceAccessImpl:2:12: note: 'PinServiceAccessImpl' has been explicitly marked unavailable here
open class PinServiceAccessImpl : NSObject {
When using a framework from an app, the documentation states that we should add the framework's as an embedded binary, but this option is not available when the project is a framework.
What puzzles me is that the unit tests seems to find the PinServiceAccessImpl.getInstance()!
I guess there are some details about linking that I don't know about that makes the build fails. Does anyone have an idea of what we are missing out?
The problem got solved when updating the deployment target to 11.0.
I have a problem using xcodebuild to build the iOS app to custom directory.
Everything works well if I am building using command:
xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyAppScheme -sdk iphoneos -configuration Release ONLY_ACTIVE_ARCH=NO
...but I would like the .app and .dSYM files to be saved in a specific directory (./build for example). So, I tried adding:
CONFIGURATION_BUILD_DIR=./build
or
OBJROOT=./build SYMROOT=./build
as a xcodebuild parameters. Then I've got this error (output comes from xctool as it's more readable, but the same error occurs when using xcodebuild):
✗ Link MyApp
(...)
ld: library not found for -lPods-MyApp-SomePodName
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As I am using Cocoapods, my workspace contains app's project and "Pods" project. I tried using xcodebuild on several other projects that uses Cocoapods and I am always getting this error (SomePodName differs depending on project's dependencies) when trying to provide custom output directory. Please note, that it works without an issue when CONFIGURATION_BUILD_DIR, OBJROOT and SYMROOT parameters are skipped.
I wonder if anything changed recently, because I am pretty sure that I was able to build to custom directory using xcodebuild in the past. Currently, Travis-CI is still able to do it without an issue, but I have no luck when trying on my local machines.
Perhaps providing CONFIGURATION_BUILD_DIR, OBJROOT or SYMROOT is not the perfect way for specifying custom output directory. I am not sure if the problem is connected directly to Cocoapods, but the errors are always connected with some pod library.
Any hints will be appreciated.
My environment:
OS X 10.10.3
Xcode 6.3
xctool 0.2.3
cocoapods 0.36.3
Update: Problem solved
It looks like xcodebuild requires absolute path for CONFIGURATION_BUILD_DIR, OBJROOT and SYMROOT parameters.
Providing absolute path solved the problem:
CONFIGURATION_BUILD_DIR=/Users/me/Dev/MyApp/build
I'm writing a script to build and generate an .app file from an specific target and scheme (to work with simulator). I was using something like:
DEVELOPER_DIR=$xcode_app_path/Contents/Developer xcodebuild -sdk iphonesimulator -scheme "${SCHEME}" -target "${TARGET}" ONLY_ACTIVE_ARCH=NO CONFIGURATION_BUILD_DIR="${build_folder}" clean build
The problem is, that I need to open XCode for the code above to work, otherwise will show me a message telling me that:
xcodebuild: error: The project 'Project-name' does not contain a scheme named "${SCHEME}"
I still yet, don't understand what is XCode doing in background. But if I open the IDE and run the script, works. If I open and later close it, and run the script works. It's not working if the project hasn't been opened first with XCode ¬¬
Any suggestion would be appreaciated
If someone is facing the same experience, this is what I found out. And works.
Well, apparently when you create a new scheme through command line, by default is not "shared". So when you start to link to the folder
xcshareddata --> xcschemes
(trying to build with command line, for example) there's nothing to link with. Xcode do this automaticaly under the hood when you open your project...
The guys from CocoaPods were facing the same issue, so they created a Ruby gem that shares the scheme and place the file in his xcscheme folder:
This is the repo: https://github.com/CocoaPods/Xcodeproj
Also, thanks to this post and this post I found out how to use xcodeproj gem, and change the shared option with a script that I put downhere:
require 'xcodeproj'
xcproj = Xcodeproj::Project.open("MyProject.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
I'm able to change my Product name with CLI xcodebuild but when I open my project I still have the old name. I would like to affect my product name's project permanently with CLI.
Is it possible ? Or perhaps I'm doing something wrong :
/usr/bin/xcodebuild -configuration Debug PRODUCT_NAME="NewName"
Passing PRODUCT_NAME to xcodebuild invocation will not change the product name in project but only in this particular build. You need to set it via Xcode in GUI mode if it needs to be done permanently. Look here
Try the following:
Hint 1
how-to-change-the-product-name-with-command-line-builds
/usr/bin/xcodebuild -configuration Debug BUILD PRODUCT_NAME="NewName".
You might have to add BUILD keyword there.
Make sure you have CLEAN your configuration as well
I'm currently using xcodebuild to automate testing for iOS.
Right now, I'm stuck on trying to pass compiler flags through Xcode directly to the compiler. These flags are: -fprofile-arcs -ftest-coverage.
I don't have the liberty of modifying the xcodeproj, that's why I want to inject these flags via the xcodebuild command.
It would be something like:
xcodebuild -project path/to/my.xcodeproj -scheme MyApp -fprofile-arcs -ftest-coverage
Is that feasible? How?
Apparently most compiler flags can be expressed as constants, and these can be passed to the compiler via xcodebuild easily.
To get them, simply select the option in the xcode build settings view, and hit command-C (copy). In my case, they were GCC_GENERATE_TEST_COVERAGE_FILES and GCC_INSTRUMENT_PROGRAM_FLOW_ARCS.
My command roughly looks like this:
xcodebuild GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES ...
To set compiler flags with xcodebuild, you need to put them in the OTHERCFLAGS option.
For example:
xcodebuild -project path/to/my.xcodeproj -scheme MyApp \
OTHERCFLAGS="-fprofile-arcs -ftest-coverage"
Yes, all of the compiler setting actually boils down to string key-value pairs. I answered a very similar question about setting preprocessor macros from the command line that is just as applicable to these settings you would like to set:
Setting a #define from the command line in xcode 4.6
I would also like to call attention to the use of ${inherited} -- using this values allows you to use the Xcode project-specified values AND append your own. Documentation for each of the build settings including those that you located via copy-paste can be found here:
http://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html
Glad you were able to get it to work -- now you can really make xcodebuild do even more for you without requiring changes of the target Xcode project!