Monday 21 November 2016

Quick Tip - How to get the path of a file in the main bundle?

If you include files in your Firemonkey project with a remote path of ./ they're copied into the main bundle when the app is built and deployed on iOS.

To access these files, you need to get their full path as follows:

Result:=NSStrToStr(TiOSHelper.MainBundle.pathForResource(StrToNSStr(fn), StrToNSStr(ext)));

fn = the name of the file without the extension
ext = the extension without the starting period (e.g. "caf' not ".caf")

If the file exists in the bundle it's full path and filename will be returned, otherwise it'll be an empty string.

You'll need to include these units in your uses:

uses
iOSapi.Helpers, Macapi.Helpers;


Thursday 14 July 2016

Delphi: External testing is not supported for builds created with beta versions of XCode or iOS

iOS TestFlight and Delphi

Since iOS 8 was released, whenever I built an app to upload to iTunesConnect for Beta testing, it would report an error when I tried to release through TestFlight.

The error I received was:

"External testing is not supported for builds that have been created with a beta version of Xcode or iOS."

Not very helpful. I confirmed that my OS X version wasn't a pre-release, re-installed XCode from the app store and made sure my SDK files were imported from the freshly downloaded XCode.

I checked the generated manifest file to make sure it has the beta entitlement set - which it did, and confirmed that this was flagged the same in the iTC portal against that build.

After a lot of Googling, I couldn't find a solution and gave up - until I recently fell onto an article on the Embarcadero Forums which solved my problem!

The solution:

Your info.plist must contain all the folllowing key/value settings:


<key>DTSDKBuild</key>

<string>13E230</string>

If using Delphi 10.1 Berlin, you can edit the new plist template (info.plist.TemplateiOS.xml) which makes it really easy.

If using earlier versions, you will need to edit the Entitlement.TempliateiOS.xml files in your project folder, making sure not to change the placeholders.

You may also need to add these additional keys if your version of Delphi doesn't already include them (prior to Delphi 10 Seattle):

<key>DTPlatformName</key>
<string>iphoneos</string>
<key>DTPlatformBuild</key>
<string>13A340</string>

Notes and References

The DTSDKBuild key is the internal build number for the version of iOS you're supporting. It must be for a LIVE version! There's a great Wikipedia article giving all the build numbers for each iOS version here:

https://en.wikipedia.org/wiki/IOS_version_history#iOS_9

The DTXCodeBuild key uses build numbers for the relevant version of XCode being used. These can be looked up here:

https://en.wikipedia.org/wiki/Xcode

The original post is here with all the details, and credit to Paul Bedford for offering the solution:

Delphi Top Tips - Welcome to my Delphi Development Blog!

Delphi Top Tips

Welcome to my Embarcadero Delphi Blog!

I've been a Delphi developer since Delphi v1.0, and writing commercial applications in Delphi since 2000 - and still am!

The personal and business software development arena has evolved quite a lot in that time but thankfully Embarcadero have done a great job of evolving the RAD Studio product line to suit. It now supported commercial-grade apps for Windows, OS X, Android and iOS thanks to the excellent Firemonkey framework.

Why This Blog?

As popular as Delphi once was, unfortunately there are many more popular languages and tools that have appeared since it's hayday. The delphi community has had a few knocks over the years (let's not mention Delphi-through-2009) but is growing again and there are excellent articles out there.

These can be really hard to find, and so I wanted to create a blog that collated all the best ones which have helped me into a single place you can find them.

There will be some original content in here, written from my own experiences but it will also include direct links to third party articles I've found across the Internet, solving a whole range of problems.

I'd also recommend joining the Delphi Developers group on Google+ which is fantastic for getting help, and is even frequented by a lot of the Embarcadero product team and MVPs!

I'm also here to help with any issues you might be facing with Delphi, so please get in touch if you're stuck with anything!

Regards

Chris Pimlott
Managing Director of MyBuzz Technologies Ltd
Creator of MyShiftPlanner app (written with Delphi)