Recent

Author Topic: ns_url_request erroring on m1 target as Arch64  (Read 313 times)

josh

  • Hero Member
  • *****
  • Posts: 827
ns_url_request erroring on m1 target as Arch64
« on: April 03, 2021, 06:52:33 pm »
Hi

trying out my m1, and getting issue here, looking at it when arch64 I target, ns_url_request thinks its an iPhone

Code: [Select]
unit ns_url_request;

{
  TNSHTTPSendAndReceive class for use by itself as an HTTP client or with
   Web Service Toolkit (http://wiki.freepascal.org/Web_Service_Toolkit).
  Author:    Phil Hess.
  Copyright: Copyright 2011 Phil Hess.
  License:   Modified LGPL (see Free Pascal's rtl/COPYING.FPC).
             This means you can link your code to this compiled unit (statically
             in a standalone executable or dynamically in a library) without
             releasing your code. Only changes to this unit need to be made
             publicly available.
}

{$modeswitch ObjectiveC1}

interface

uses
  SysUtils,
  Classes,
  httpdefs,
{$IF DEFINED(IPHONESIM) OR DEFINED(CPUARM) OR DEFINED(CPUAARCH64)}  //iOS
 {$IFDEF NoiPhoneAll}
  Foundation,
 {$ELSE}
  iPhoneAll,
 {$ENDIF}
{$ELSE}  //macOS
 {$IFDEF NoCocoaAll}
  Foundation,       <--------
 {$ELSE}
  CocoaAll,
 {$ENDIF}
{$ENDIF}
  NSHelpers;           
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 867
Re: ns_url_request erroring on m1 target as Arch64
« Reply #1 on: April 03, 2021, 08:07:07 pm »
You can replace
Code: [Select]
{$IF DEFINED(IPHONESIM) OR DEFINED(CPUARM) OR DEFINED(CPUAARCH64)}
with
Code: [Select]
{$IF DEFINED(IPHONESIM) OR DEFINED(IOS)}

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1441
  • Former Delphi 1-7, 10.2 user
Re: ns_url_request erroring on m1 target as Arch64
« Reply #2 on: April 04, 2021, 12:59:12 am »
Also see the Wiki's Mac Portal in particular these pages:

* macOS NSURLConnection
* macOS NSURLSession
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65070 FPC 3.3.1 r49223 macOS 11.2.3 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

josh

  • Hero Member
  • *****
  • Posts: 827
Re: ns_url_request erroring on m1 target as Arch64
« Reply #3 on: April 04, 2021, 12:30:47 pm »
Hi

Jonas Maebe adjusting as suggested solved the issue, Thanks.
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(IPHONESIM) OR DEFINED(IOS)}

trev Thanks for posting the links, I visit there often, and it holds a mountain of good information.
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

 

TinyPortal © 2005-2018