When using Cruise Control to build an iPhone XCode project with Unit Tests, an error of "Code Sign error: a valid provisioning profile matching the application's Identifier 'com.yourcompany.Calculator' could not be found" is generated. This isn't encountered when run through XCode? Is Cruise Control trying to launch the app rather than just build it? Any suggestions?
I don't know for sure if xcodebuild properly runs the code signing tool, but it sounds to me that you'll need to change your build process to use that tool (codesign).
I'm not sure if it's a pre-build or post-build task.
codesign man page: http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/codesign.1.html
According to this this SO post, you may be able to get around this by telling xcodebuild to assume the target is the iPhone Simulator instead of the actual iPhone (with the -target command line option)
The problem was caused by the addition of the Unit Test Bundle to the project. To ensure that tests were built and run along with the main project, I had dragged the Unit Tests target into the main project Target.
By default, it had assigned the Unit Test Bundle to be built against the iPhone Device 3.1.2 SDK rather than the simulator.
Also, the Unit Test Bundle had an auto-generated .plist file which contained the default Bundle Identifier of com.yourcompany...etc.
So despite specifying a target which I knew had a default SDK of the iPhone Simulator 3.1.2, the inclusion of the Unit Test Bundle caused the error to keep appearing.
Selecting 'Get Info' for the Unit Test bundle, select the Build tab and set the Base SDK to iPhone Simulator 3.1.2 and all will be well.
Related
Currently, I have an issue with one of the libs that I use in the project, it simply won't let me make the build for the iOS simulator.
Getting the following error message:
Building for iOS Simulator, but the linked library '!##$%^&.a' was built for iOS.
In my class I have the following code:
#if (TARGET_IPHONE_SIMULATOR==0)
void !##$%^&_init(void);
#endif
I have tried to exclude the file when building the app for the iPhone simulator by adding it in Build Settings > Build Options > Excluded Source File Names > Any iOS Simulator SDK
I have also tried to exclude the following architectures: arm64, arm64e, and armv7.
Setting Build Active Architecture Only to YES, didn't do the trick for me, nor validating build product nor validate workspace.
Actually, none of the above-mentioned solutions worked for me, so I had to ask this question here.
As a workaround you should be able to change Build system to "Legacy Build System" under File/Project Settings.
The proper solution would be to package your library as XCFramework.
I'm building an iPhone application, and I want to run a custom built-on-the-fly Mac OS X command-line utility during the build phase of the iPhone target. I set up the command-line utility as a dependent target of the iPhone target, but it won’t build, telling me:
target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphoneos’ platform
Is there any way to do this correctly?
Thanks!
Have you tried adding a run script build phase? From there, you should be able to execute any other scripts you wish, including compiling other tools or projects.
Right click on the target and Add New Build Phase.
I have followed the instructions Apple publishes for unit testing applications on iPhone and things work great when I set the active SDK to "iPhone Simulator". I have it configured to always build and run my tests as part of building the application itself.
Apple implies (by omission) that this should work all of the time, but the tests are skipped when I set the active SDK to "iPhone Device". I am also linking with OCMock, and instead of a failing test, this warning is in the build log:
ld: warning: in .../build/Debug-iphoneos/OCMock.framework/OCMock, missing required architecture arm in file
It's very nice to make the unit test bundle a dependency of the main application, so these tests run at every build, but its utility is greatly diminished if it doesn't work during device builds. Is this a known, but undocumented, limitation?
As Kristopher commented, this is just the way XCode behaves. The Run Script step at the end of your Unit Test target will actually run the built target when the SDK is set to Simulator, but if you look at the build output it will just balk when building against the Device SDK.
Basically, build your LogicTests against the Simulator SDK and build your ApplicationTests against the Device SDK. It's a pain, but that's just the way it works.
Also, if you want to get OCMock working for ARM (which you will likely want for Application Tests that run on the actual device), I believe their OCMock lib target is "fat"/Universal by default. That is, it will include both i386 code and arm code within the same library. You'll have the best results if you check out their repository and build it yourself.
I've created a iPhone static library project with two targets like this
Project
--> Library (Device) target
--> Library (simulator) target
The device target has the SDK set to the device so it produces an armv6/7 library and the simulator target is set to the simulator SDK so it produces an i386 library.
The issue I'm having is that the SDK settings on the targets keep getting overridden by the XCode active target setting. i.e. if I build the device target, but the XCode window is showing the active SDK as being the simlulator, XCode will build a simulator library instead of a device library, ignoring the settings of the target. Although it will put it into the *-iphoneos/ directory in the build directories!
I originally had the same issue with another static library project, and after a lot of playing around got everything to work correctly. i.e. The targets ignore the XCode active SDK because they have their own specifications of what to build.
The problem is that I don't know what made it work in that project and I have not been able to reproduce the issue in it either.
Does anyone have any ideas as to what is going on?
ciao
Derek
OK, I think I've figured it out.
Set the project SDK to the general setting, ie. Simulator SDK so that you get the APIs and libraries correct during coding.
Set each target to the SKD it needs to build. ie. device SDK or simulator SDK.
Leave XCodes SDK set to current SDK, effectively telling it to not override the targets.
I'm using google unit testing code.
I'm building it quite nicely with xcodebuild on the command line. Now I want to run it (preferably on attached Device but simulator would also work) and catch all the feedback from the tests.
But I can't find out how to run it. Any ideas?
Jeff Haynie's iphonesim project on Github looks like it could work. I had trouble building 27812bb4b (make failed on a warning in nsprintf.m), but that may just be me using a pre-release OS and SDK. See also this related question.
If you followed the instructions from the Google page (creating the target, adding the test files to the target) and you have an iPhone SDK certificate (you need it to upload apps to the device) you can just change the Active SDK to your device (upper left corner combo in XCode)
If you don't have a certificate, you need to apply to the SDK program.
The only iPhone simulator and debugger I'm aware of comes with the iPhone SDK. In order to use the iPhone SDK you need to have an Intel-based mac with OS 10.5 Leopard installed, in which case you might as well be programming/compiling in XCode instead of using the command line.
There has to be some misunderstanding here. What exactly do you want to run from the command line? The test suite? If so, the test suite should be a separate target, so that all you have to do is build it, for example like this:
xcodebuild -target UnitTests -sdk iphonesimulator2.2.1 -configuration Debug
If you have the testing target configured correctly, it will run the RunIPhoneUnitTest.sh shipped with the Google Toolbox and the script will run all your tests.