Can Xcode (command-line) build an archive without a scheme? - ios

I'm primarily a .NET developer but am trying to compile some applications for iOS using Xcode command-line tools. My goal is to use the command-line to write a script to clone a repository, compile the code, and sign it with my iOS developer certificate.
However, when I clone a Git repository for an iOS/OSX application, it usually only contains a Xcode project file (and sometimes a workspace file). When I try to use 'xcodebuild archive' it requires a scheme to be specified but 'xcodebuild -list' says that none exist.
What is the correct way to automatically generate these schemes from the command-line?

Related

Sign Xamarin iOS service extension with mbuild

Xamarin cross platform app with a notification service extension.
When I build the app in Visual Studio with "Archive app for publishing", then sign manually the iOS project AND the service extension with the ad-hoc profiles (for the example), and upload to AppCenter for distribution, it's installing fine on our test devices.
However, the company process involve TeamCity for building the app automatically at each branch push using a custom script (msbuild)
Was working fine until i added the service extension. Since that, with the same script, the app builds fine but at instal from AppCenter i get "App integrity couldn't be verified".
I suppose there is something wrong with the tricky iOS signing process but can't figure out what.
Do i need to build the service extension separately using msbuild commands, or is it included in the ios project build as they are linked?
All the <CodesignKey> and <CodesignProvision> tags containing the right names in the .csproj files.
The configuration mappings are well configured.
The build script look like this:
msbuild Project.iOS.sln /t:Build
msbuild Project/Project.iOS/Project.iOS.csproj
msbuild /p:Configuration="Ad-Hoc" \
/p:Platform="iPhone" \
/p:IpaPackageDir="%env.PackageDirectory%" \
/t:Build Project.iOS.sln

How to remove scripts (in a framework) when the ios app is archived?

I'm working on a cocoa pod framework which has a couple of shell scripts in it. After installing the pod, the user should add the following in app's build phase -> run script :
“${PODS_ROOT}/MyPod/MyPod/framework/MyPod.framework/scripts/build.sh”
After this the build works fine and app runs. But archiving creates problems. XCode gives an error saying:
iTunes Store Operation Failed
Invalid Signature. Code object is not signed at all. The file at path [SampleApp.app/Frameworks/MyPod.framework/scripts/build.sh] is not properly signed. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose "Clean All" in Xcode, delete the "build" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html
I've two concerns now:
Xcode doens't allow scripts to be a part of archive?
If thats the case, then how do I remove these scripts from archive? Is there a build setting like ${ARCHIVE_DIR} from where I can search for the latest archive and then remove the script. Or, is there some build setting where I can mention what files to ignore while building or archiving?
Also, I've already tried adding these files to 'exclude source file names' to the app's build settings. It didn't work since the script to be executed isn't a part of the app, but part of the framework integrated in app.
Also, my framework is a fat framework generated by using lipo on simulator build and device build. Which means that framework won't be code signed.
Apple does not allow simulation code inside framework when push to store, to overcome this, either ship the framework without simulator arch, or use external script to remove it during app build.
Example script can be found in some framework like Realm, basically you have to add the script file in your framework, and tell user/dev to call this on their build script (it's the strip-frameworks.sh)
This issue is stated in this archiving universal framework bug

can i build and package my ios app separately with xcodebuild?

I am using xcodebuild commandline tool to generate my ios app(mainly c++ source code). The command is like
xcodebuild -project Application.xcodeproj
I want to ask whether can I separate the build phase and package phase, that is to say, first build the binary executable, then at sometime package the app later.
From Apple technical note, xcodebuild supports various build actions such as build, analyze, and archive that can be performed on your target or scheme. However, build is performed by default when no action is specified. So, when you want to package, specify action archive otherwise just leave it empty as shown in Apple Example in the document.

Xcode Server Bot Issue: warning. Build Service Error. Issue: archive at path 'some/path' is malformed

I'm using Cocoapods and KIF to run Continuous Integration on an Xcode server. I have successfully set this up for one project to report on each commit. I'm now using a second project and get the error:
Bot Issue: warning. Build Service Error.
Issue: archive at path '/Library/Developer/XcodeServer/Integrations/Integration-81d42936b22a04037fd4aebed1074e5e/Archive.xcarchive' is malformed.
Integration Number: 1.
Description: archive at path '/Library/Developer/XcodeServer/Integrations/Integration-81d42936b22a04037fd4aebed1074e5e/Archive.xcarchive' is malformed.
The tests passed when ran on the Xcode server machine using Xcode. I tried downloading Provisioning Profiles etc via Xcode but that didn't help. I deleted the Bot and created a new one but that also did't help.
Any help is welcome
At least in my case (and there may be multiple causes), this was caused by having "Skip Install" set on every target, which causes you to end up with an empty archive (but only on Xcode Server).
Basically, xcodebuild (the command-line tool) has lots of critical differences from Xcode in the way it handles archiving. It builds targets that aren't listed in the scheme, and it obeys the Skip Archive flag even for targets listed in the scheme. By contrast, when building locally, Xcode ignores the Skip Archive flag and archives any targets in the scheme (and only the targets listed in the scheme).
I would encourage you to file a bug every time you run into situations where a project builds locally but fails on the server. If everyone did this, perhaps these differences would eventually get fixed....

xcodebuild - set certificate through commandline

I have an Xcode project for an iOS application.
I plan building it through commandline using xcodebuild.
I will be adding minor customizations from build to build, producing slightly different versions of the application (for branding purpose).
What I need is a way to automatically set a specific certificate for each build. Is it possible to somehow set a certificate for the build through command line?
To clarify - every time I build the project, I want to use a new certificate.
before the build, set environment variable CODE_SIGNING_IDENTITY="name of certificate"

Resources