Bei Kunden, die ich besuche, kommt es immer wieder mal zu Problemen oder Missverständnissen bei der Installation oder Lizenzeingabe von Delphi, deshalb hier ein paar Hinweise:
Vergangene Woche haben wir mit Embarcadero Deutschland erfolgreich die nunmehr dritte Coderage über die Bühne gebracht.
Hier findet ihr sämtliche Webinare zum nächträglichen Anschauen. Vielen Dank an Matthias Eissing – für die nicht unerhebliche Arbeit und auch die Geduld, alle Videos der Sprecher einzusammeln und aufzubereiten.
Hier mein Beitrag, der zeigt, wie man in FireMonkey iOS Apps den Apple Schlüsselbund aktiviert, um bei Login-Feldern dem Benutzer die Arbeit zu erleichtern. Den in der Session erwähnten Quelltext findet ihr hier.
FireMonkey Apps für iOS und Android werden in Delphi im Rahmen des Bereitstellungsprozesses automatisch signiert – dies ist inbesondere für iOS Apps unabdingbar und wurde daher in der Delphi IDE auch entsprechend umgesetzt.
Bei Windows Anwendungen (egal ob 32 oder 64 Bit) ist dagegen keine Signatur-Option in Delphi zu finden. Dies dürfte dazu führen, dass viele Delphi Apps unsigniert verteilt werden. Dies ist jedoch spätestens seit Windows 10 nicht mehr zu empfehlen, denn der mit Windows 10 eingeführte „SmartScreen-Filter“ blockiert standardmäßig „nicht vertrauenswürdige“ Anwendungen. Eine unsignierte Anwendung (EXE) ist per se „nicht vertrauenswürdig“, da ihre Herkunft nicht verifiziert werden kann.
Single Sign-on with Facebook’s Login API and Delphi – my session at Coderage XII. Please see below for the link to the materials.
Supplying a username and a password has been standard for many years to grant access to protected applications. This works reasonably well, yet there are issues that you may want to address with your applications:
- shared passwords between apps, because it is easier to remember only a few passwords, than one password per application
- too easy to guess, non-strong passwords
- keeping your users passwords in a safe location
- missing protection for sensitive account actionsFacebook offers an API, that allows any application (desktop and mobile) to authenticate against Facebook account information, which basically implements single sign-on on a broad scope. A Facebook user only needs to create and keep track of his Facebook credentials. This password can be selected in a complex way as it is the only one that users need to remember, which makes it harder to guess. Facebooks also provides infrastructure and staff that actively protects their user database against any sorts of cyber attacks.
In this session I demonstrate how to implement Facebook’s Login APIs in your Delphi application.
If your Xcode version updates (manually or by Apple’s updating mechanism) then make sure to re-import the iOS/macOS SDK from within Delphi.
To build and deploy iOS/macOS apps with Delphi, you need Xcode for the final steps, even though the actual binary is compiled by Delphi. Apple frequently delivers minor updates to Xcode. Current version as of the writing of this article is 8.3.2. This version number of the Xcode build used for preparing apps is apparently checked by Apple, when uploading an IPA file to App Store/iTunes Connect. They don’t do any spooky things, they just check the DTXcodeBuild key in your app’s info.plist file:
This info.plist file is generated by Delphi, and contains various essential settings, such as version number, device requirements etc. Many of these settings can directly be configured, by modifying the values in Delphi – Project – Options – Version Information
DTXCodeBuild is filled in by Delphi automatically though. When you import iOS/macOS SDK, then PAServer obviously issues this command:
/usr/bin/xcodebuild -version -sdk
That returns the available SDK versions and the Xcode build number:
iPhoneOS10.3.sdk - iOS 10.3 (iphoneos10.3) SDKVersion: 10.3 Xcode 8.3.2 Build version 8E2002
This build version number is apparently stored and used to fill the DTXcodeBuild key’s value.
To bring this number in Delphi in sync with the actual Xcode version, after Xcode was updated (or switched with xcode-select), you have to delete the SDK from Delphi and re-import it using Delphi – Tools – Options – SDK Manager.
This is especially important if you imported the 10.3 SDK while having Xcode 8.3.0 installed. In that case your Delphi iOS apps would be tagged with being built with exactly that version – no matter if you downgraded to Xcode 8.2.1 or applied my „Package Application fix“ – which is required due to a tool chain change that Apple imposed with Xcode 8.3 and up. Any iOS app tagged with being built with Xcode 8.3.0 will be refused by Apple, as that version has been deprecated.
Since Apple updated Xcode to version 8.3.x, iOS IPA deployment is broken with Delphi up to 10.2 (Tokyo). There is an official workaround, which basically instructs to download Xcode 8.2 and use that for now:
Unfortunately though, Apple started sending out notifications, that it won’t accept any builds created with Xcode versions older than 8.3.2 anymore. This is what I’ve received from Apple a few days ago:
We have discovered one or more issues with your recent delivery for „AppEvents“. Your delivery was successful, but you may wish to correct the following issues in your next delivery:
Deprecated Xcode Build – Due to resolved app archives issues, we will be deprecating Xcode 8.3 on May 10, 2017, at which time app archives built with 8.3 will no longer be accepted by the App Store. Download Xcode 8.3.2 or newer, rebuild your app and resubmit.
After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to iTunes Connect.
The App Store team“
The problem with Delphi and Xcode 8.3 is basically a tool, that Apple decided to remove from its tool chain, but which Delphi still depends on. So the solution is to copy that missing tool „PackageApp“ from 8.2 to 8.3. Below are the steps that made my Delphi 10.2 (Tokyo) iOS deployment fully working again:
- Install current Xcode from Appstore into your applications folder – currently 8.3.2
- Download Xcode 8.2.1 from
- Unzip Xcode_8.2.1.xip to a separate folder (e.g. /tmp/Xcode)
- Make a backup copy of your current Xcode version:
cp -R /Applications/Xcode.app /tmp/Xcode.8.3.app (might take a minute or two)
- Copy the following file from 8.2.1 to your current Xcode app:
sudo cp /tmp/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
Apple requires you to specify if your apps are using any form of encryption. If you do not use encryption, you have to confirm that in your app settings on iTunes Connect – this is not new, Apple started asking for that long time ago. Important to notice is though that since a while Apple requires your app to have a special entry in it’s info.plist file – even if do not use any encryption. Without that your app will fail to verify for Testflight and Appstore deliveries.
It’s easy to add that entry in Delphi. Go to Project – Options – Version information. The list/grid is actually editable, just go to the last row and press cursor down. Then add „ITSAppUsesNonExemptEncryption – false“ as shown in the screenshot
Embarcadero just made a hotfix for Delphi/RADStudio 10.2 Tokyo available, which fixes several debugger issues and – important for you C++ guys – it fixes a string related security issue, which could potentially overwrite memory with affected scanf and scanf_s methods.
If you need to „pump“ records from one data source to an other, then TFDBatchmove is for you.
Using FireDAC’s BatchMove component allows you to easily map the fields of one query to an other, regardless if they belong to the same database/connection or two totally different databases. You can actually even copy records from text files to „real“ databases and vice versa.
Just build a BatchMove chain like this:
SourceData and DataTarget are regular TFDQueries, Reader and Writer are TFDBatchmoveDatasetReader/Writer components, that just connect the queries with the TFDBatchmove component in the middle.
The actual magic is done by adding field mappings, from source to target:
In this case source and target fieldnames are mostly the same, which wouldn’t even require adding mappings. There are a couple of calculated fields in the source query too. They are used to format/modify the data, so that it would match the format requirements in the destiantion query.
These fields are calculated in QOPCQuery.OnCalcFields like this:
procedure TDMMain.QOPCSourceDataCalcFields(DataSet: TDataSet); begin if QOPCSourceDataoSchnittgruppe.IsNull then DataSet.FieldByName('FANr').AsString := '' else DataSet.FieldByName('FANr').AsString := GenFANr(QOPCSourceDataoSchnittgruppe.AsInteger);
The calculated fields work fine, but when calling BatchMove.execute it will raise an exception. The reason is simple:
FireDAC’s internal logic depends on TDataSet.FieldDefs, but calclulated fields won’t show up there. You have to use „InternalCalc“ instead of „Calculated“, to push your calculated fields to its datataset’s FieldDefs collection.
When you add lines to a TMemo in Delphi Applications, then you might want to scroll to the very end of that particular Memo, so that the newest lines are kept in view.
In FireMonkey it’s as easy as just calling GoToTextEnd:
procedure TFormMain.AddLog(AMessage: string); begin Memo1.Lines.Add(AMessage); Memo1.GoToTextEnd; end;
You might notice though, that when you clear the Memo at certain times, the scrollbars may get out of sync. To avoid that, you need to call ProcessMessages right after „clear“. Apparently the scrollbars get confused, when you add lines directly after clear command, because the actual position needs to be rendered first (which the ProcessMessages does).
procedure TFormMain.AddLog(AMessage: string); begin if Memo1.Lines.Count > 100 then begin Memo1.Lines.Clear; Application.ProcessMessages; //without this, scrollbars will show wrong size/position end; Memo1.Lines.Add(AMessage); Memo1.GoToTextEnd; end;