why realm.io is needs in additional frameworks? - realm

I create app with Realm database (RealmSwift)
When i try build app, there are a lot of errors , experimentally i found several libraries i should link to project for success compilation.
But i don't want to get it for final app version (size of app will very big), what to do ?
These frameworks for example:
CoreVideo.framework
CoreMedia.framework
AudioToolbox.framework
CommLibiOS.a
MediaLibiOS.a
My app doesn't use any video/audo/media features of Realm , i don't know why i need to link it.
If I try to delete for example AudioToolbox.framework from linked list , i have a lot of errors like this:
Undefined symbols for architecture x86_64:
"_AudioComponentFindNext", referenced from:
-[MPAudioUnitEngine voiceAudioUnit] in MediaLibiOS.a(MPAudioUnitEngine.o)
Why Realm needs these libraries?
p.s. sorry for my English

Realm doesn't require linking any of the libraries you've referenced. These must be referenced in your own Xcode project's configuration.
Realm Swift requires the following libraries to be linked: Realm, Foundation & libc++. Following the installation instructions in Realm's documentation should get all this set up properly: https://realm.io/docs/swift/latest/#installation
I suggest you look at some of the Realm example Xcode projects to compare and identify what you may be doing differently. https://github.com/realm/realm-cocoa/tree/master/examples

Related

How to use .NET 6-windows and .NET 6 targets in one library

I've segregated my WinUI 3 application into different layers: Application, Infrastructure, Presentation etc.
And all the projects have targets: net6.0-windows and I want to move it to the Uno Platform.
So, I've added a new target: net6.0
And at this moment the problem arises:
Type [WinUI] component already defines a member, called InitializeComponent or some problems with binding.
Is it possible to make such type of library with targets to net6-windows and net6.0?
For the Windows app project itself, you need to use net6-windows, as that provides additional dependencies specific to Windows app projects. All other libraries (non-app projects) can then use net6.0.
Regarding the specific error message, you are getting, the reason might be the generated files have some kind of conflict - you can try deleting the obj and bin folders and rebuild.
The easiest way to make existing Windows app support Uno would probably be to create a blank Uno solution and then migrate the code there (as the solution has already the required setup for platform-specific projects prepared and you can then just add your code.
Uno also provides templates for cross-targeted libraries, so you might be able to use similar approach. The one linked is for "UWP" solution however, so to make it WinUI, you would need to switch from uap10.0.18362 to net6-windows.

When referencing a .Net Standard project within a Xamarin solution, does all the code from the project get compiled into the app

Apologies if this sounds like a silly question. I'm not very experienced with how things are linked/bundled/assembled under the hood.
Before I begin, I'd like to say that I've tried reading documentation (such as https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing) to find the answer, but was unable to.
If I have a Xamarin.Forms solution and I reference a .Net Standard project:
Question 1: Does all the code from this project get compiled and included into the app such that it may be disassembled later, or is it only code from classes that I actually make use of that gets included?
Bit more elaboration:
For example, I may have a School class that expects an IStudent (inject via DI), and a Student class that implements IStudent. Both of these exist in the .Net Standard project that I reference in the Xamarin.Forms project. However, if I only actually make use of the Student class (by registering it with type IStudent in my IoC container), will the code from School get included in the built app as well?
Question 2: If all the code from the project does get included, is there a way to forcefully specify which classes to include/exclude by way of some configuration setting, attributes, 3rd-party library, or something else?
As far as i know everything in the NETStandard project get compiled and shipped with the app.
If you want to remove unused code from compiled assemblies you have to use the linker.
To link everything, you have to select "Sdk and User Assemblies".
The linker tries to dont strip away mthods and fields you are using, but often is too aggressive (for example, methods referenced only by reflection will be stripped).
Luckily there are few methods where you can fine-tune the linker behaviour and make it work. Some link to elaborate on:
Linker in iOS and Android
https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker
Official doc about the linker config:
https://learn.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker
Useful blogposts:
https://xamarinhelp.com/xamarin-linker/
https://medium.com/#harrycblum/reduce-your-xamarin-app-size-with-linking-26247edc87f6

How to setup different firebase environments in Flutter

I am trying to figure out how to set up different firebase environments in a flutter project.
I understand how to do this in firebase, I created two projects, one for production, one for the test. Then, in an iOS or Android project, I could use various methods to switch between these two environments using separate google-services.json or GoogleServices-Info.plist files.
In Flutter I found this description of how to separate environments, but it only explains how to differentiate between environments in the flutter code.
How can I get this environment to change what iOS and Android build at compile time? It would even be sufficient simply to allow a file copy hook at build time.
You can switch accounts using FirebaseApp.configure. You can offer your own solution or secret dev panel to switch between them.
The solutions will build flavours and plist implementations will lock you into builds when you deploy for TestFlight + they are messy.
Here's an example: (You could use Assets as well.)
// Load a named file.
let filePath = Bundle.main.path(forResource: "MyGoogleService", ofType: "plist")
guard let fileopts = FirebaseOptions(contentsOfFile: filePath!)
else { assert(false, "Couldn't load config file") }
FirebaseApp.configure(options: fileopts)
I wrote an article about how to do this for Firebase configuration as well as runtime configuration in dart code using flavors and platform channels.
https://medium.com/#matt.goodson.business/separating-build-environment-configurations-in-flutter-with-firebase-doing-it-the-right-way-c72c3ad3621f
Flutter flavors work pretty seamlessly with Android flavors. For iOS you need to create Xcode schemes for each flavor and link them to build configurations.
For dart configuration, you can use platform channels to get the flavor used during the build at runtime. This lets you configure the app without having multiple main.dart files or passing a target argument.
Salvatore Giordano has written a blog post with a detailed description of how to achieve this:
https://medium.com/#salvatoregiordanoo/flavoring-flutter-392aaa875f36
Flutter accepts a parameter --flavor=<flavor> which allows you to select different build flavors. In Android this works as expected, selecting different build flavors. IOS is a little tricker because a scheme is needed for every flavor, and the build configurations in the form of Release-<flavor> are also needed.
Once these parts are in place, they can be used, to select the firebase configuration as you would in any iOS or Android project.
The challenge is getting Dart code to also be aware of the flavor, and the blog post provides no good solution for this. It suggests the standard method of using different entry points can be used, but the correct entry point must be matched to the correct flavor manually by the person invoking the app.
Specifically to Firebase env config you can use this article and this article from CodeMagic which explains how you can set up plist files with build env variables.
If you need to have a different set of values inside your Dart code, like an option you can use this package. It allows to generate Dart class config file from console command params.
Update 12/05/2020
Since Flutter 1.17 you can actually use compile-time variables with --dart-define argument in flutter run and flutter build commands
Here is an article that describes how to specify and use them.
With the release of Flutter for Web to the stable channel, I put together instructions for targeting multiple firebase projects (e.g. dev, staging, prod) from multiple build platforms (i.e. iOS, Android, and Web).

Microsoft Universal app bundle error when compiling

I'm building a Universal app that includes SqLiteStore. I'm getting this odd error includes misspellings. SQLite doesn't let me pick AnyCPU so I'm at a conundrum. Any ideas on where to look?
error APPX3104: You cannot create an app bundle when building for platform 'x86' which is not included in the list of platforms selected for producting app bundle. Set platform to a one of following values: AnyCPU.
I believe the supported platforms list is set by the AppxBundlePlatforms property. Try something like this:
msbuild Foo.sln /p:Platform=x86;PlatformTarget=x86;Configuration=Release;AppxBundle=Always;AppxBundlePlatforms=x86
For more information see: https://stackoverflow.com/a/29353229/67824

Error Message: ARC is required to compile Pushwoosh SDK

I am new in xcode.
I got recurring message error when building for testing:
*PWRequest.m
User defined issues
"ARC is required to compile Pushwoosh SDK"*
In code it shows:
#if ! __has_feature(objc_arc)
#error "ARC is required to compile Pushwoosh SDK"
#endif
I don't understand. I added a new pushwoosh sdk.
I thank you very much for your help.
You can set ARC on a file basis. Go to the BuildPhases->CompileSources. You can select sources there and pass ARC flag.
Same as here:
How can I disable ARC for a single file in a project?
but with -fobjc-arc flag
You can use XCode project that comes with the SDK. In this case you'll be linking to the output (library) that is produced by this project.
Hope it helps!
So if you want to use Pushwoosh in your app, you're going to need to turn on ARC in your project settings.
And then you'll be using ARC in your app.
Which is somewhat nicer than doing good old fashioned Manual Retain / Release memory management, yes?
If you are determined to use MRC (manual retain count), then follow the steps in this related question.

Resources