Recently I'm trying to use Jenkins for Oclint statically analyzing objective-c sources.
So I followed the guide on the Oclint.org, especially this page oclint_guide_with_Jenkins
And then, I run the build job on the Jenkins.
But the job was always failed with below logs.
(Extra logs were just about svn check-out)
+ oclint-json-compilation-database -- -report-type pmd -o oclint.xml -rc=LONG_LINE=120
Error: compile_commands.json not found at current location.
Can anyone show me the way to solve this problem? :)
You need to generate the compile_commands.json , I am not sure if xcodebuild can do that , but you can use Facebook's xctool : https://github.com/facebook/xctool which is a wrapper over xcodebuild and provides different reporters.
You can use Homebrew to install xctool as well, once install use the following commands to generate compile_commands.json and then run the oclint command.
If you have a workspace file :
xctool -scheme $scheme -workspace $workspaceFile -sdk iphonesimulator ARCHS=i386 VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -reporter json-compilation-database:compile_commands.json build
If you have project file :
xctool -scheme $scheme -project $projectFile -sdk iphonesimulator ARCHS=i386 VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -reporter json-compilation-database:compile_commands.json build
Related
I am working on a C++ Xcode project. Let's say it PA.xcodeproj. I am building its target targetA using the command line:
xcodebuild -project PA.xcodeproj -target targetA
In targetA, I have specified its dependency targetB and targetB further depends on targetC.
While running the above command, it builds targetB but doesn't build targetC.Is there anything wrong with the above command? I was guessing it should build targetC as well as the targetB depends on it.
For users having trouble building cordova/phonegap apps to send to Facebook for review of permissions using the following command:
xcodebuild arch i386 sdk iphonesimulator7.1
and getting errors like:
file not found #import ...
Here's the solution:
Follow these instructions:
https://developers.facebook.com/docs/ios/creating-ios-simulator-build-for-review
Use this command to build your app
xcodebuild -project HelloWorld.xcodeproj -arch i386 -target HelloWorld -configuration Debug -sdk iphonesimulator clean build VALID_ARCHS=i386 CONFIGURATION_BUILD_DIR=/Users/pedro/Documents/Cordova/HelloWorld/platforms/ios/build
If you want to read more about it, I found the solution here:
https://groups.google.com/forum/#!topic/oclint-users/GD1a242k_X0
Issues between xcodebuild and Jenkins prompted me to try xcodebuild on a vanilla Empty Application template where it still fails:
>> xcodebuild -target FizzBuzz -sdk iphonesimulator7.0 -arch i386
The following build commands failed:
ProcessPCH /var/folders/64/<someHash>/C/com.apple.DeveloperTools/5.0-5A1413/\
Xcode/SharedPrecompiledHeaders/FizzBuzz-Prefix-<someHash>/FizzBuzz-Prefix.pch.pch
FizzBuzz/FizzBuzz-Prefix.pch
normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
>> xcodebuild -version
Xcode 5.0
Build version 5A1413
What is the proper incantation of xcodebuild?
These 3 were the key issues for me:
xcodebuild was still relying on gcc-4.7 (Command Line Tools installed or not). Check $CC and unset $CC to let clang do its job.
Use the -scheme option with xcodebuild ...
... and ONLY_ACTIVE_ARCH=NO.
I have legacy code that relies on pointers being 32-bit and want to use xCodeBuild to build that code from command line. This doesn't work for some reason. Here's the command I use:
xcodebuild -configuration Debug -arch i386
-workspace MyProject.xcworkspace -scheme MyLib
here's the output I get
[BEROR]No architectures to compile for
(ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
Clearly it's trying to build x86_64 code and failing miserably since I only enabled i386 from VALID_ARCHS in xCode project settings.
Is there a way to make it understand I don't want a 64-bit library?
You have to set the ONLY_ACTIVE_ARCH to NO if you want xcodebuild to use the ARCHS parameters. By passing these parameters, you can force the proper architecture.
xcodebuild ARCHS=i386 ONLY_ACTIVE_ARCH=NO -configuration Debug -workspace MyProject.xcworkspace -scheme MyLib
See this reference for details.
Build Active Architecture Only(ONLY_ACTIVE_ARCH)
xcodebuild ONLY_ACTIVE_ARCH...
//or
Build Settings -> Build Active Architecture Only -> ONLY_ACTIVE_ARCH
YES - build binary with a single architecture for a connected device
NO - build binary for a specific -arch(valid architectures aka VALID_ARCHS) if it was specified or for all the architectures in other cases
The recommendation is to use Yes for Debug (to save on build time) and No for Release build.
Note: it is safe to run on simulator
To check the version use lipo -info[About]
I have an xcode Objective-C iPhone static library project. When I build it in xcode I get no errors or warnings. But when I build it using xcodebuild from the command line I get:
"/Developer/usr/bin/gcc" -v -dM -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk -E -arch armv6 -o - -x objective-c /dev/null
gcc-4.2: error trying to exec '/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1': execvp: No such file or directory
I cannot find anything that helps me to understand what the issue is, any ideas?
And yes the /Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 file does exist :-)
For some reason what seemed to fix this for me is actually passing in the architectures to be used.
For instance, this command fails:
/Developer-SDK4/usr/bin/xcodebuild -target ProjectName -configuration Release build PLATFORM_NAME=iphonesimulator BUILDSDK=/Developer-SDK4
But this one works:
/Developer-SDK4/usr/bin/xcodebuild -target ProjectName -configuration Release build PLATFORM_NAME=iphonesimulator BUILDSDK=/Developer-SDK4 ARCHS=i386
Note, this only failed for me when building against the simulator. Building against the device seemed to work just fine.