问题描述
我无法将iOS应用发布到AppStore.
I can't to publish my iOS app to AppStore.
Delphi 10.1.2 Berlin,iOS64,Win 8.1.
Delphi 10.1.2 Berlin, iOS64, Win 8.1.
我从苹果那里收到了下一条信息:
I received the next info from apple:
请确保您的应用与IPv6网络兼容.
Please ensure that your app is compatible with IPv6 networks.
测试应用程序的IPv6兼容性的最简单方法是在Mac上设置本地IPv6网络.然后,您可以从iOS设备连接到网络以测试IPv6兼容性.
The easiest way to test your app for IPv6 compatibility is to set up a local IPv6 network on your Mac. You can then connect to the network from your iOS devices to test IPv6 compatibility.
请按照支持IPv6 DNS64/NAT64网络中提供的分步说明进行操作.
Please follow the step-by-step instructions provided in Supporting IPv6 DNS64/NAT64 Networks.
有关支持IPv6网络的其他信息,请参阅支持仅IPv6网络.
For additional information about supporting IPv6 networks, please review Supporting IPv6-only Networks.
是连接代码.
It's connection code.
if (FSocket<>nil) then
begin
if not FSocket.Connected then
begin
SetState(mwtrstDisConnected);
FSocket.Free;
FSocket:=nil;
end
else
exit;
end;
FSocket:=TIdTCPClient.Create(nil);
FSocket.Host:=FHost;
FSocket.Port:=FPort;
//CheckCode
{$ifdef KBMMW_USING_INDY_9_OR_NEWER}
FSocket.BoundPortMin:=FMinClientPort;
FSocket.BoundPortMax:=FMaxClientPort;
{$endif}
{$IFDEF KBMMW_USING_INDY_10}
FSocket.ReadTimeout:=RequestTimeout*1000;
FSocket.ConnectTimeout:=ConnectTimeout*1000;
{$ENDIF}
{$IFDEF KBMMW_USING_INDY_8_00_23}
FSocket.Connect;
{$ELSE}
{$IFDEF KBMMW_USING_INDY_9}
FSocket.Connect(ConnectTimeout*1000);
{$ELSE}
FSocket.Connect;
{$ENDIF}
{$ENDIF}
DoConnected(Info);
我认为我必须在//CheckCode位置插入下一个代码.
In my opinion I have to insert the next code in //CheckCode place.
TIdStack.IncUsage;
IdURI := TIdURI.Create('195.34.x.x');
try
try
ss := GStack.ResolveHost(IdURI.Host, TIdIPVersion.Id_IPv6);
IdURI.IPVersion := TIdIPVersion.Id_IPv6;
except
IdURI.IPVersion := TIdIPVersion.Id_IPv4; // Just in case.
end;
//ShowMessage(ss);
finally
FreeAndNil(IdURI);
TIdStack.DecUsage;
end;
但是此代码(GStack.ResolveHost)在iOS上不起作用.
But this code (GStack.ResolveHost) doesn't work on iOS.
如何解决?
推荐答案
尝试其他类似方法:
FSocket := TIdTCPClient.Create(nil);
FSocket.Host := FHost;
FSocket.Port := FPort;
{$IFDEF KBMMW_USING_INDY_9_OR_NEWER}
FSocket.BoundPortMin := FMinClientPort;
FSocket.BoundPortMax := FMaxClientPort;
{$ENDIF}
{$IFDEF KBMMW_USING_INDY_10}
FSocket.ReadTimeout := RequestTimeout*1000;
FSocket.ConnectTimeout := ConnectTimeout*1000;
// check if connecting to an IPv4/IPv6 address directly...
if GStack.IsIP(FHost) then // only checks for IPv4 right now
begin
FSocket.IPVersion := Id_IPv4;
FSocket.Connect;
end
else if MakeCanonicalIPv6Address(FHost) <> '' then
begin
FSocket.IPVersion := Id_IPv6;
FSocket.Connect;
end
else begin
// connecting to a hostname, try IPv6 first, then fallback to IPv4...
try
FSocket.IPVersion := Id_IPv6;
FSocket.Connect;
except
FSocket.IPVersion := Id_IPv4;
FSocket.Connect;
end;
end;
{$ELSE}
// only IPv4 is supported...
{$IFDEF KBMMW_USING_INDY_9}
FSocket.Connect(ConnectTimeout*1000);
{$ELSE}
FSocket.Connect;
{$ENDIF}
{$ENDIF}
DoConnected(Info);
或者:
var
LIPAddress: TIdIPAddress;
LLocalIPs: TIdStackLocalAddressList;
TryIPv4, TryIPv6: Boolean;
I: Integer;
...
FSocket := TIdTCPClient.Create(nil);
FSocket.Host := FHost;
FSocket.Port := FPort;
{$IFDEF KBMMW_USING_INDY_9_OR_NEWER}
FSocket.BoundPortMin := FMinClientPort;
FSocket.BoundPortMax := FMaxClientPort;
{$ENDIF}
{$IFDEF KBMMW_USING_INDY_10}
FSocket.ReadTimeout := RequestTimeout*1000;
FSocket.ConnectTimeout := ConnectTimeout*1000;
LIPAddress := TIdIPAddress.MakeAddressObject(FHost);
if LIPAddress <> nil then
begin
// connecting to an IPv4/IPv6 address...
FSocket.IPVersion := LIPAddress.AddrType;
LIPAddress.Free;
FSocket.Connect;
end else
begin
// connecting to a hostname...
TryIPv4 := False;
TryIPv6 := False;
LLocalIPs := TIdStackLocalAddressList.Create;
try
GStack.GetLocalAddressList(LLocalIPs);
for I := 0 to LLocalIPs.Count-1 do
begin
case LLocalIPs[I].IPVersion of
Id_IPv4: TryIPv4 := True;
Id_IPv6: TryIPv6 := True;
end;
end;
finally
List.Free;
end;
if TryIPv6 then
begin
try
FSocket.IPVersion := Id_IPv6;
FSocket.Connect;
TryIPv4 := False;
except
if not TryIPv4 then
raise;
end;
end;
if TryIPv4 then
begin
FSocket.IPVersion := Id_IPv4;
FSocket.Connect;
end;
if not (TryIPv4 or TryIPv6) then
raise Exception.Create('Not connected to an IPv4 or IPv6 network');
end;
{$ELSE}
// only IPv4 is supported...
{$IFDEF KBMMW_USING_INDY_9}
FSocket.Connect(ConnectTimeout*1000);
{$ELSE}
FSocket.Connect;
{$ENDIF}
{$ENDIF}
DoConnected(Info);
请注意,一旦Indy实现以下功能,这种情况将变得更容易处理,但是我认为这是可以解决的:
Note that this situation would become much simpler to handle once Indy implements the following feature, but that is a ways off, I think:
这篇关于Delphi iOS的IPv6麻烦.请确保您的应用与IPv6网络兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!