为什么当我们将android服务添加到应用程序时,delphi会在应用程序的dpr中自动包含服务数据模块的单位? [英] Why when we add an android service to an app, delphi automatically include in the dpr of the app the unit of the datamodule of the service?

查看:119
本文介绍了为什么当我们将android服务添加到应用程序时,delphi会在应用程序的dpr中自动包含服务数据模块的单位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个新服务时,该服务将具有一个主数据模块(DM),并且当我将该服务添加到已存在的应用程序中时,delphi会自动将其添加到该应用程序的dpr中数据模块的单位:

When i create a new service, then this service will have a main datamodule (DM), and when i add this service to an already existing app, then delphi automatically add to the dpr (in the uses clauses) of this app the unit of the datamodule:

uses ...
     ...
     myService_mainunit;

为什么?这也使得无法在IOS下进行编译...

why ? it's also make after not possible to compile under IOS ...

推荐答案

IDE绝对不知道您的意图是什么.毫无疑问,您只想在Android上使用它,而不管它是否是Android专用代码.您必须编写代码来说明这一点,例如使用条件语句.

The IDE has absolutely no idea what your intentions are. It has no clue that you only want to use this for Android, regardless of if it's Android-specific code or not. You have to write the code which tells it this, such as using conditionals.

创建新的Android服务时,IDE会为您设置一个预制模板.该模板恰好使用数据模块来完成其工作.但是,当您将数据模块添加到项目中时,IDE根本不知道为什么要添加它.它只是在做它的工作,它为添加到项目中的 any every 每个单元执行此操作,而不管该单元的目的是什么.实际上,没有这样的事情:在您的项目中添加一个单元,而在DPR使用中 not .

When you created a new Android Service, the IDE set up a pre-made template for you. This template just happens to use a Data Module to do its work. But when you add the Data Module to a project, the IDE simply does not know why you want to add it. It's just doing its job, it does this for any and every unit you add to your project, regardless of what that unit's purpose is. In fact, there is no such thing as adding a unit to your project and not being in the DPR uses.

在IOS下也无法编译"

"it's also make after not possible to compile under IOS"

同样,通过将平台条件包装在其周围,可以很容易地解决此问题.当然,IDE会控制" DPR文件,因此可能不太容易 ,因为IDE可能会使您的代码格式错误.但是,很可能通过在您的项目中包含此数据模块,而是将其放置在项目可以找到它的位置.

Again, this is easily resolved by wrapping platform conditionals around it. Of course, the IDE "takes control" of the DPR file, so perhaps not that easily, as the IDE could malform your code. It is however very possible by not including this Data Module in your project, but place it in a location where your project can find it.

这篇关于为什么当我们将android服务添加到应用程序时,delphi会在应用程序的dpr中自动包含服务数据模块的单位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆