Using xbuild on iOS application does not generate ipa - ios

We have implemented Continuous Integration with Jenkins to help perform our builds for faster deployment. We have reviewed the documentation provided through the Xamarin website, and have come to an issue. In the walkthrough it describes how to use various plugins to perform the process, we use build scripts to perform our builds because we have some post-actions that we execute after the build, such as submitting the ipa to the TestFlight. The problem is that for iOS it is has been documented that we need to use xbuild instead of mdtool when building from the terminal/command line.
We followed this portion of the guide to construct our xbuild within the build script. It appears that the xbuild command works and creates the project reference dlls and even generates an exe, but does not generate an ipa file even if we set this /p:BuildIpa=true on the xbuild to ensure the ipa generation. We also have provided a location for the ipa to be generated within to ensure we are not missing the file with this /p:IpaPackageDir=$BUILD_PATH. Here is the whole xbuild command that we are currently using, is there something that is incorrect or we are missing?
/Library/Frameworks/Mono.framework/Commands/xbuild $PROJECT_FILE / t:Build /p:BuildIpa=true /p:IpaPackageDir=$BUILD_PATH /p:Configuration=”Release” /p:Platform=”iPhone” /p:OutputPath=$BUILD_PATH
($BUILD_PATH) -- The build path is just “%WORKSPACE%\bin\iPhone\Release\”
I did find this resource as well, which states that xbuild requires the solution file for iOS to build correctly, is that correct?
If this is correct, how do we resolve these errors because I have not been able to find any documentation that explains how to properly define the solution and project files for xbuild deployment, or even how to exclude particular projects during the build:
/Users/developer/.jenkins/workspace/Mobile3_Branch_3.20/ServicePro/iOS/Mobile3.Forms.UWP/Mobile3.Forms.UWP.csproj: warning : Could not find project file /Library/Frameworks/Mono.framework/External/xbuild/Microsoft/WindowsXaml/v14.0/Microsoft.Windows.UI.Xaml.CSharp.targets, to import. Ignoring.
/Users/developer/.jenkins/workspace/Mobile3_Branch_3.20/ServicePro/iOS/Mobile3.ServicePro.UWP/Mobile3.ServicePro.UWP.csproj: warning : Could not find project file /Library/Frameworks/Mono.framework/External/xbuild/Microsoft/WindowsXaml/v14.0/Microsoft.Windows.UI.Xaml.CSharp.targets, to import. Ignoring.
Project "/Users/developer/.jenkins/workspace/Mobile3_Branch_3.20/ServicePro/iOS/Mobile3.sln" (Mobile3.ServicePro.iOS target(s)):
Target ValidateSolutionConfiguration:
/Users/developer/.jenkins/workspace/Mobile3_Branch_3.20/ServicePro/iOS/Mobile3.sln: error : Invalid solution configuration and platform: "“Release”|“iPhone”".
Task "Error" execution -- FAILED
Done building target "ValidateSolutionConfiguration" in project "/Users/developer/.jenkins/workspace/Mobile3_Branch_3.20/ServicePro/iOS/Mobile3.sln".-- FAILED
Done building project "/Users/developer/.jenkins/workspace/Mobile3_Branch_3.20/ServicePro/iOS/Mobile3.sln".-- FAILED
Here is the xbuild command we used to build the solution:
/Library/Frameworks/Mono.framework/Commands/xbuild /p:Configuration=”Release” /p:Platform=”iPhone” /p:OutputPath=$BUILD_PATH /p:BuildIpa=true /p:IpaPackageDir=$BUILD_PATH /t:Build $SOLUTION_FILE
We are not concerned with building the UWP projects when building the iOS project because we have a separate build script that generates the appxbundle file correctly.

You can build an "individual project/app" by setting the SolutionDir and building a .csproj, all the referenced projects will be built and an .ipa created, something like:
xbuild
/p:SolutionDir="./src"
/p:OutputPath="$PWD/artifacts/"
/p:IpaPackageDir="$PWD/artifacts/"
/p:Configuration=Release
/p:Platform=iPhone
/target:Build
src/iOS/XamarinForms.iOS.csproj
Note: This assumes your provisioning profiles are setup on this Mac.

Related

Capacitor iOS App with Share Extension build fails with clean build folder

I'm creating a Capacitor App with the capacitor-share-extension plugin
As described in the documentation on Github, for iOS I first needed to create a "Share Extension" in Xcode.
When I build the app in Xcode everything works fine.
But when I clean the build folder in Xcode (Product -> Clean build folder), the build is failing. In consequence, I cannot build the app on a fresh machine or in my build pipeline, which blocks me from using the plugin. (For reference I'm using Bitrise Xcode Archive Plugin)
From the error, it looks like Xcode cannot find an appex file that is created in my local cache (but I also failed to include that file in my project folder). The error message is this:
Failed to set unique install ID on plugin <my-bundle>.<my-extension>
Failed to open /Users/<username>/Library/Developer/CoreSimulator/Devices/4A7360A3-D373-4A0A-BB08-AF354F97FFAF/data/Library/Caches/com.apple.mobile.installd.staging/temp.9hhnWo/extracted/Payload/<my-app>.app/PlugIns/<my-share-extension>.appex/<my-share-extension>
Failure Reason: No such file or directory
Is it possible to include all required files in my project folder so that I can build without the cache and without going through Xcode to manually create the Share Extension?
Or can I somehow create the Share Extension through a CLI command so that I can build in my build pipeline (already asked by this SO question Creating iOS share extension through the command line)?

Intellij generated Project for Kotlin Multiplatform always show build failed

I am using intellij to create a Kotlin Multiplatform Project for Android and iOS. I have not done any changes to the generated template but when opening the iOS Project in xcode and running it, it shows Build Failed with this logs.
/Users/archie.quinones/Library/Developer/Xcode/DerivedData/iosApp-bwuvtubwlwgrwofszlveznlcosbj/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/app.build/Script-F861D812207FA4320085E80D.sh: line 2: /Users/archie.quinones/IdeaProjects/MppApplication/iosApp/../gradlew: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
Can some guide me how to make this work?
Thank you very much.
There is a small confusion here. AFAIK, there should be a note in your Gradle script, with something like
//Before opening the project from iosApp directory in Xcode,
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
So please, open the project directory in Terminal and execute gradle wrapper task manually.
This is a known issue of the Kotlin/MPP wizard, here is the ticket. It is not a problem, as you can produce the wrapper by yourself, but I agree, that it might be unobvious.

Delphi MSBuild Build Android From Command Line that selects App Store or Development platform configuration

What I want to parametertise is the platform configuration, so that I can specifically build an APK for the AppStore.
msbuild MyProject.dproj /p:Config=Release /t:Build;Deploy /p:Platform=Android
Currently whatever is actually selected/saved to Project File, the msbuild always builds the development platform configuration for release.
Platform Configuration Options
I've tried a few possible /p parameters (such as buildtype etc) but none of them seem to work.
How to do this?
I just tried this command-line (broken across 2 lines to avoid scrollers) and it produced the output expected for an App-Store build:
msbuild project_name.dproj /p:Config=Debug /t:Build;Deploy
/p:Platform=Android /p:BT_BuildType=AppStore
This gave:
....blah blah...
C:\Program Files (x86)\Embarcadero\Studio\19.0\bin\CodeGear.Deployment.targets :
warning :
Missing provisioning information for the "Application Store" platform configuration,
the file '.\Android\Debug\project_name\bin\project_name.apk' has been sucessfully
generated but it has not been signed and it is a non-instalable package.
This is not normally output on my build, and I hadn't set up suitable app-store provisioning, so it suggests we are getting the desired results.
It seems that for Android the BT_BuildType property can either be Debug or AppStore. For iOS it can also be AdHoc.

Xcode, Git, Jenkins, PhoneGap 1.5.0 Build Error

I have developed an application with phonegap 1.5.0 previously and now we just pushed into git repository. The app was build successfully in xCode and I was able to install the app and run it on the iPad but when we tried to build it from Jenkins, we got this error
/Users/...../Classes/AppDelegate.m:28:
/Users/......./Classes/AppDelegate.h:31:13: fatal error: 'Cordova/CDVViewController.h' file not found
#import <Cordova/CDVViewController.h>
I really don't know why is this happening. Did I not include any file into gitt that causes this problem? or is there any extra steps that I need to take to put the codes into git? Any advice on this is deeply appreciated.
My PhoneGap project is able to build and generates .ipa.
Here's what I have done for my CI integration using Jenkins:
Install Xcode integration plugin for Jenkins (manage Jenkins --> Manage Plugins --> Available --> Xcode integration).
In your Job configuration, click the Add build Step button and choose Xcode.
In Xcode configuration:
3.1. Add Clean before build.
3.2. Add Target of your project (e.g.: SamplePhonegap).
3.3. Add SDK (e.g.: iphoneos6.1).
3.4. Add Configuration as Debug or Release.
3.5. Add Xcode Project Directory which contain .xcodeproj (e.g.: ${WORKSPACE}).
3.6. Build output directory (e.g.: ${WORKSPACE}/build) [Mandatory Step for PhoneGap App].
3.7. Add Build IPA.
3.8. Add Code Signing Identity (e.g.: iPhone Developer: S*** ** (6**)).
3.9. Add Unlock KeyChain.
3.10. Add keyChain Path (e.g.: ${HOME}/Library/Keychains/login.keychain).
3.11. Add Keychain password.
Finally build your app - it will build and generate the .ipa file.
Note:
3.6 step is mandatory because a PhoneGap project has two build paths: one is our project build path and another one is cordova build path. Jenkins tough to find the path default (In native not need to specify, because it has only one build path Jenkins can easily find). So it's mandatory to provide Build output directory path.
What you can do is to try to clone the git repo to your local machine and build from there. If it's ok, it means that you need to check Jenkins setting/configuration.
This by far the best solution i found.Original Answer
Xcode 6.x
add $(OBJROOT)/UninstalledProducts/include to BuildSettings->Header Search Paths
Xcode 7.x
add $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include to BuildSettings->Header Search Paths
1.Double click the and you can add this in.
2.Change $(OBJROOT)/UninstalledProducts/include to $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

Xcode commandline building with dependent project

I'm building a iOS application that uses a library that I've built using jverkoey's framework structure. All is well and good, until I try to let my CI environment (Jenkins) build my project. Jenkins builds using the commandline and when it does so my dependent framework gets built in it's own build directory, and when my main application builds in it's own directory it can't find the framework.
As a test I copied the output from my dependent frameworks build directory into the main apps build directory and re-ran my commandline build and everything works fine. So what I think I have to do is update my Jenkins build scripts to be able to move the dependent build output before building the main app, or change them to all build in the same directory as XCode does from the IDE with it's DerivedData directory.
The question is, how? I'm no expert when it comes to building from the commandline and I could really use some help here.
Ok, I figured this out. Just incase anyone else has a similar problem you can set the SYMROOT setting to whatever directory you want when running xcodebuild.
xcodebuild -target MyTarget SYMROOT=/Build/MyProj/Sym.root

Resources