I added in my iOS project 3 targets (with different provisioning, different plist and specific configurations).
Target 1 --> MyApp-Info.plist
Target 2 --> MyApp-2-Info.plist
Target 3 --> MyApp-3-Info.plist
However, when I execute the command cordova build ios I can not choose the target to compile. It is always the target by default (Target 1).
In the logs of the Terminal, I have always the following line:
ProcessInfoPlistFile build/emulator/MyApp.app/Info.plist MyApp/MyApp-Info.plist
Is there a way to choose the target to compile? or a Xcode project configuration?
Use a before_build hook in combination with a shell variable to dynamically copy/rename the required .plist file to MyApp-Info.plist. Eg: BUILD_TARGET=1 cordova build ios. The before hook should then of course take BUILD_TARGET into account.
Related
When building the same app (on Mac VS2019) from the same prepared zip archive with removed bin and obj folders and cleaned solution right before build I get different IPA "archives".
The one from jenkins is missing Assets.car and app icons so the app doesn't show home screen icon and splash during loading. During the _CopyResourcesToBundle target that should copy all required assets it gives:
Building target "_CopyResourcesToBundle" partially, because some output files are out of date with respect to their input files.
Because it runs into partial state it probably doesn't copy all the required files.
When building on the local machine with the same VS2019 (8.4.2) for Mac and the same Xcode (11.0) no matter when using IDE or the terminal it gives correct IPA file.
Building target "_CopyResourcesToBundle" completely.
...
Output file "bin/iPhone/Release/RssReader.app/AppIcon60x60#2x.png" does not exist.
Output file "bin/iPhone/Release/RssReader.app/AppIcon76x76#2x~ipad.png" does not exist.
Output file "bin/iPhone/Release/RssReader.app/Assets.car" does not exist.
...
bin/iPhone/Release/RssReader.app/AppIcon60x60#2x.png
LogicalName=AppIcon60x60#2x.png
Optimize=false
OriginalItemSpec=obj/iPhone/Release/actool/bundle/AppIcon60x60#2x.png
OutputPath=bin/iPhone/Release/RssReader.app/AppIcon60x60#2x.png
bin/iPhone/Release/RssReader.app/AppIcon76x76#2x~ipad.png
LogicalName=AppIcon76x76#2x~ipad.png
Optimize=false
OriginalItemSpec=obj/iPhone/Release/actool/bundle/AppIcon76x76#2x~ipad.png
OutputPath=bin/iPhone/Release/RssReader.app/AppIcon76x76#2x~ipad.png
bin/iPhone/Release/RssReader.app/Assets.car
LogicalName=Assets.car
Optimize=false
OriginalItemSpec=obj/iPhone/Release/actool/bundle/Assets.car
OutputPath=bin/iPhone/Release/RssReader.app/Assets.car
The above part is obviously not present when building on jenkins.
This looks like several other threads when others were struggling with missing assets and they were clearing some misty Xamarin cache folders, adding and removing assets to the project with rebuild, cleaning and removing bin/obj folders.
This is not the same case as app is always built on the cleared workspace in the tmp location with removed bin and obj folders and cleaned before the build. Adding/removing and moving the location of the resource also doesn't help.
Apps cannot be built on symlink locations due to msbuild internal issue.
See: https://github.com/xamarin/xamarin-macios/issues/7759
I have tried to integrate FanMenu framework to my project, and then I got the following error and my app is not working
:-1: Multiple commands produce '/Users/amira/Library/Developer/Xcode/DerivedData/star-gvkwjukrellysodofwfcqkjcyhwo/Build/Products/Debug-iphoneos/FanMenu/FanMenu.framework/Info.plist':
1) Target 'FanMenu' (project 'Pods') has copy command from '/Volumes/Data/Work/StarApp/iOS-user-Registration-master/Pods/FanMenu/Sources/Info.plist' to '/Users/amira/Library/Developer/Xcode/DerivedData/star-gvkwjukrellysodofwfcqkjcyhwo/Build/Products/Debug-iphoneos/FanMenu/FanMenu.framework/Info.plist'
2) Target 'FanMenu' (project 'Pods') has process command with output '/Users/amira/Library/Developer/Xcode/DerivedData/star-gvkwjukrellysodofwfcqkjcyhwo/Build/Products/Debug-iphoneos/FanMenu/FanMenu.framework/Info.plist'
can anyone help please ?
Go to File -> Workspace Settings -> Build system -> Legacy build system.
I also faced the same problem. After change the settings. Everything is good now
I've got an open source Xamarin project which has an API key in the AndroidManifest.xml file. At the moment, I've dealt with that issue by .gitignore-ing AndroidManifest.xml, but that's a messy solution and it stops me using an automated build environment like AppCenter.
It can be done with a Gradle file: https://developer.android.com/studio/build/manifest-build-variables
However, in Xamarin we don't have access to Gradle. I can't find a way to do this is in a Xamarin project. Am I missing something obvious?
Unfortunately environment variables are not available when AndroidManifest.xml (or Info.plist for iOS builds) is being read.
One way I've found of changing configuration values in those files, including the com identifier is to run pre-build scripts via Project Options -> Build -> Custom Commands.
The actual scripts can be very simple. Something like:
#!/bin/sh
cat ./manifest/prod/AndroidManifest.xml > Properties/AndroidManifest.xml
You'll need a different version of the script for each build configuration. In my case I need to vary the com identifier based on environment in order to isolate production vs development push notifications from Pushy.me.
This shows up in your .csproj file like this:
<CustomCommands>
<CustomCommands>
<Command>
<type>BeforeBuild</type>
<command>set_manifest_dev.sh</command>
<workingdir>${ProjectDir}</workingdir>
</Command>
</CustomCommands>
</CustomCommands>
First of all, I'm a complete beginner on the whole Xamarin-life-cycle, build tools and terms, so sorry if this is quite basic/incorrect in some wording.
We have a Example.sln file with the following project definitions; one for Android and one for iOS:
Project("{...}") = "Example", "Example\Example\Example.csproj", "{...}"
EndProject
Project("{...}") = "Example.Droid", "Example\Example.Droid\Example.Droid.csproj", "{...}"
EndProject
Project("{...}") = "Example.iOS", "Example\Example.iOS\Example.iOS.csproj", "{...}"
EndProject
I'm currently trying to build just the iOS project with xbuild on the command line. My question is if there's a way to specify this on an xbuild flag; e.g. tried with /t:Example.ios:Build and stuff alike without luck. So I simply tried unbundling the Android project and running:
$ xbuild /p:Configuration="Ad-Hoc" \
/p:Platform="iPhone" \
/p:IpaPackageDir="./Builds" \
/t:Build Example.sln
Which, I guess, since the Droid project is still before iOS on the .sln, is failing when looking for the Android SDK:
/Users/ci/Example-app/Example.sln (Build) ->
(Build target) ->
/Users/ci/Example-app/Example/Example.Droid/Example.Droid.csproj (default targets) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets (_BuildSdkCache target) ->
: error XA5205: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory.
Temporarily removing the Android project from the solution did the trick (preserving the Example\Example.Droid files but commenting out the 2 lines) but it's not quite optimal for me, i.e. maybe in some other CI job I want to just build the Android app, etc.
Thanks!
You could disable the Android project from being built for your Platform=iPhone case via the Configuration manager (see Solution Configurations section). Or you can create a separate config/platform combo for your solution that enables only the common projects and the iOS ones.
Once you have that, then you can just select that configuration and platform combination on the command line with xbuild or msbuild with
xbuild /p:Configuration=.. /p:Platform=.. foo.sln.
I would suggest you to execute the xbuild command from the folder of your Xamarin iOS project or specify a target for your command like this:
xbuild /p:..... iOSProject/app.csproj
xbuild takes the path of the project or solution file to build, as the
main argument. If no file is specified then it tries to build any
solution file or project file in the current directory, that has a
*proj extension.
If you need to force an SDK or a specific build tools path you have to specify:
/p:AndroidSdkDirectory=$YOUR_SDK_PATH
/p:AndroidSdkBuildToolsVersion=23.x.x
xbuild command reference
As we known, we can set target membership for a certain file/bundle in right navigator of xcode.
But now I want to set target membership in a certain configuration. So how can I set target for a file/bundle in xcconfig file?
Many Thanks!
You could attach a build phase that:
runs before you copy bundles phase.
It would detect whether the config is Debug vs Release using ${CONFIGURATION}
and then copy the file into a location/name where it would then get picked up by the copy files phase.