Skip to content

Commit 2835110

Browse files
[NativeAOT] Improving HelloiOS sample for NativeAOT to be testable with runtime packs (#86652)
- Enabled end-to-end testing of HelloiOS with NativeAOT runtime packs - Update ILCompiler paths to handle PublishAotUsingRuntimePack=true Fixes #80911 --------- Co-authored-by: Filip Navara <navara@emclient.com>
1 parent 03f2be6 commit 2835110

File tree

8 files changed

+146
-62
lines changed

8 files changed

+146
-62
lines changed

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
Text="Add a PackageReference for '$(_hostPackageName)' to allow cross-compilation for $(_targetArchitecture)" />
7373

7474
<!-- NativeAOT runtime pack assemblies need to be defined to avoid the default CoreCLR implementations being set as compiler inputs -->
75-
<Error Condition="'@(PrivateSdkAssemblies)' == ''" Text="The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
76-
<Error Condition="'@(FrameworkAssemblies)' == ''" Text="The FrameworkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
75+
<Error Condition="'@(PrivateSdkAssemblies)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'" Text="The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
76+
<Error Condition="'@(FrameworkAssemblies)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'" Text="The FrameworkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
7777

7878
<ComputeManagedAssembliesToCompileToNative
7979
Assemblies="@(_ResolvedCopyLocalPublishAssets)"

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,40 @@ The .NET Foundation licenses this file to you under the MIT license.
126126

127127
<!-- The properties below need to be defined only after we've found the correct runtime package reference -->
128128
<Target Name="SetupProperties" DependsOnTargets="$(IlcSetupPropertiesDependsOn)" BeforeTargets="Publish">
129+
<ItemGroup>
130+
<_NETCoreAppFrameworkReference Include="@(ResolvedFrameworkReference)" Condition="'%(ResolvedFrameworkReference.RuntimePackName)' == 'Microsoft.NETCore.App.Runtime.NativeAOT.$(RuntimeIdentifier)'" />
131+
</ItemGroup>
132+
129133
<PropertyGroup>
130134
<!-- Define paths used in build targets to point to the runtime-specific ILCompiler implementation -->
131135
<IlcToolsPath Condition="'$(IlcToolsPath)' == ''">$(IlcHostPackagePath)\tools\</IlcToolsPath>
132-
<IlcSdkPath Condition="'$(IlcSdkPath)' == ''">$(RuntimePackagePath)\sdk\</IlcSdkPath>
133-
<IlcFrameworkPath Condition="'$(IlcFrameworkPath)' == ''">$(RuntimePackagePath)\framework\</IlcFrameworkPath>
134-
<IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == ''">$(RuntimePackagePath)\framework\</IlcFrameworkNativePath>
136+
<IlcFrameworkPath Condition="'$(IlcFrameworkPath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\framework\</IlcFrameworkPath>
137+
<_NETCoreAppRuntimePackPath>%(_NETCoreAppFrameworkReference.RuntimePackPath)/runtimes/$(RuntimeIdentifier)/</_NETCoreAppRuntimePackPath>
138+
<IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == '' and '$(PublishAotUsingRuntimePack)' == 'true'">$(_NETCoreAppRuntimePackPath)\native\</IlcFrameworkNativePath>
139+
<IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\framework\</IlcFrameworkNativePath>
140+
<IlcSdkPath Condition="'$(IlcSdkPath)' == '' and '$(PublishAotUsingRuntimePack)' == 'true'">$(IlcFrameworkNativePath)</IlcSdkPath>
141+
<IlcSdkPath Condition="'$(IlcSdkPath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\sdk\</IlcSdkPath>
135142
<IlcMibcPath Condition="'$(IlcMibcPath)' == ''">$(RuntimePackagePath)\mibc\</IlcMibcPath>
136143
</PropertyGroup>
137144

138-
<ItemGroup>
139-
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" />
145+
<ItemGroup Condition="'$(PublishAotUsingRuntimePack)' == 'true'">
146+
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll"/>
147+
<FrameworkAssemblies Include="@(RuntimePackAsset)" Condition="'%(Extension)' == '.dll'" />
148+
<DefaultFrameworkAssemblies Include="@(FrameworkAssemblies)" />
149+
</ItemGroup>
140150

151+
<ItemGroup Condition="'$(PublishAotUsingRuntimePack)' != 'true'">
152+
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll"/>
141153
<!-- Exclude unmanaged dlls -->
142154
<FrameworkAssemblies Include="$(IlcFrameworkPath)*.dll" Exclude="$(IlcFrameworkPath)*.Native.dll;$(IlcFrameworkPath)msquic.dll" />
143155

144-
<MibcFile Include="$(IlcMibcPath)*.mibc" Condition="'$(IlcPgoOptimize)' == 'true'" />
145-
146156
<DefaultFrameworkAssemblies Include="@(FrameworkAssemblies)" />
147157
<DefaultFrameworkAssemblies Include="@(PrivateSdkAssemblies)" />
148158
</ItemGroup>
159+
160+
<ItemGroup>
161+
<MibcFile Include="$(IlcMibcPath)*.mibc" Condition="'$(IlcPgoOptimize)' == 'true'" />
162+
</ItemGroup>
149163
</Target>
150164

151165
<Target Name="ComputeIlcCompileInputs" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)" BeforeTargets="Publish">

src/installer/pkg/projects/nativeaot-packages.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<ItemGroup>
55
<Project Include="Microsoft.DotNet.ILCompiler\Microsoft.DotNet.ILCompiler.pkgproj" />
6-
<ProjectReference Include="@(Project)" />
6+
<ProjectReference Condition="'$(BuildNativeAOTRuntimePack)' != 'true'" Include="@(Project)" />
77
<ProjectReference Include="@(Project)" AdditionalProperties="PackageTargetRuntime=$(OutputRID)" />
88
</ItemGroup>
99

src/mono/sample/iOS-NativeAOT/Makefile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,41 @@ TARGET_ARCH?=$(shell . $(TOP)eng/native/init-os-and-arch.sh && echo $${arch})
77
TARGET_OS?=iossimulator
88
DEPLOY_AND_RUN?=false
99
STRIP_DEBUG_SYMBOLS?=false
10+
USE_RUNTIME_PACKS?=false
1011

1112
REPO_DIR=$(realpath $(TOP))
1213
TASKS_DIR=$(REPO_DIR)/src/tasks
1314
DOTNET=$(REPO_DIR)/dotnet.sh
1415
BUILD_SCRIPT=$(REPO_DIR)/build.sh
16+
ifeq ($(USE_RUNTIME_PACKS),false)
17+
LOCAL_NUGET_RESTORE_DIR=
18+
else
19+
LOCAL_NUGET_RESTORE_DIR=$(realpath .)/packages
20+
endif
1521

1622
world: build-deps all
1723

1824
# build all dependencies: runtime, nativeAot and all the libs
25+
ifeq ($(USE_RUNTIME_PACKS),false)
1926
build-deps: build-runtime-ilc build-libs-all
27+
else
28+
build-deps: build-runtime-ilc-packs build-libs-all-packs
29+
endif
2030

2131
# building for host
2232
build-runtime-ilc:
2333
$(BUILD_SCRIPT) clr+clr.aot -c $(BUILD_CONFIG)
2434

25-
build-ilc:
26-
$(BUILD_SCRIPT) clr.aot -c $(BUILD_CONFIG)
35+
build-runtime-ilc-packs:
36+
$(BUILD_SCRIPT) clr+clr.aot+libs+packs -c $(BUILD_CONFIG)
2737

2838
# building for target platform
2939
build-libs-all:
3040
$(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs+libs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH)
3141

42+
build-libs-all-packs:
43+
$(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs+libs+packs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH) /p:BuildNativeAOTRuntimePack=true
44+
3245
build-libs-nativeaot:
3346
$(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH)
3447

@@ -37,14 +50,19 @@ all: appbuilder hello-app
3750
appbuilder:
3851
$(DOTNET) build -c $(BUILD_CONFIG) $(TASKS_DIR)/AppleAppBuilder/AppleAppBuilder.csproj
3952

53+
ifeq ($(USE_RUNTIME_PACKS),true)
54+
hello-app: export NUGET_PACKAGES = $(LOCAL_NUGET_RESTORE_DIR)
55+
endif
56+
4057
hello-app: clean
4158
$(DOTNET) \
42-
build -c $(BUILD_CONFIG) \
59+
publish -c $(BUILD_CONFIG) \
4360
-p:TargetOS=$(TARGET_OS) \
4461
-p:TargetArchitecture=$(TARGET_ARCH) \
4562
-p:DeployAndRun=$(DEPLOY_AND_RUN) \
4663
-p:StripDebugSymbols=$(STRIP_DEBUG_SYMBOLS) \
64+
-p:PublishAotUsingRuntimePack=$(USE_RUNTIME_PACKS) \
4765
-bl
4866

4967
clean:
50-
rm -rf obj bin
68+
rm -rf obj bin *.binlog $(LOCAL_NUGET_RESTORE_DIR)

src/mono/sample/iOS-NativeAOT/Program.csproj

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,48 @@
44
<OutputPath>bin</OutputPath>
55
<IntermediateOutputPath>$(MSBuildThisFileDirectory)/obj/</IntermediateOutputPath>
66
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
7-
<TargetOS Condition="'$(TargetOS)' == ''">ios</TargetOS>
8-
<TargetOS Condition="'$(TargetsiOSSimulator)' == 'true'">iossimulator</TargetOS>
7+
<TargetOS Condition="'$(TargetOS)' == ''">iossimulator</TargetOS>
98
<DeployAndRun Condition="'$(DeployAndRun)' == ''">true</DeployAndRun>
109
<RuntimeIdentifier>$(TargetOS)-$(TargetArchitecture)</RuntimeIdentifier>
1110
<AppName>HelloiOS</AppName>
12-
<StripDebugSymbols Condition="'$(StripDebugSymbols)' == ''">false</StripDebugSymbols>
13-
<!-- NativeAOT-specific props -->
14-
<NativeLib>static</NativeLib>
15-
<CustomNativeMain>true</CustomNativeMain>
1611
<UseNativeAOTRuntime Condition="'$(UseNativeAOTRuntime)' == ''">true</UseNativeAOTRuntime>
17-
<!-- FIXME: Once we support building System.Globalization.Native and icu, should be removed -->
18-
<InvariantGlobalization>true</InvariantGlobalization>
19-
<!-- FIXME: We do not use publish targets yet, but we need to create a publish directory -->
2012
<PublishDir Condition="'$(PublishDir)' == ''">$(OutputPath)/publish</PublishDir>
13+
<NativeLib>static</NativeLib>
14+
<CustomNativeMain>true</CustomNativeMain>
15+
<!-- Escape NativeAOT bundling targets -->
16+
<NativeCompilationDuringPublish>false</NativeCompilationDuringPublish>
17+
<IlcCompileDependsOn>Compile;ComputeIlcCompileInputs;SetupOSSpecificProps;PrepareForILLink</IlcCompileDependsOn>
18+
</PropertyGroup>
19+
20+
<PropertyGroup Condition="'$(PublishAotUsingRuntimePack)' == 'true'">
21+
<PublishAot>true</PublishAot>
22+
<MSBuildWarningsAsErrors>$(MSBuildWarningsAsErrors);NU1603</MSBuildWarningsAsErrors>
23+
<UseLocalTargetingRuntimePack>false</UseLocalTargetingRuntimePack>
24+
<RestoreAdditionalProjectSources>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'packages', '$(CoreCLRConfiguration)', 'Shipping'))</RestoreAdditionalProjectSources>
2125
</PropertyGroup>
2226

2327
<ItemGroup>
2428
<Compile Include="..\iOS\Program.cs" Link="Program.cs" />
2529
<DirectPInvoke Include="__Internal" />
2630
</ItemGroup>
2731

28-
<PropertyGroup Condition="'$(TargetOS)' == 'maccatalyst'">
29-
<DevTeamProvisioning Condition="'$(DevTeamProvisioning)' == ''">adhoc</DevTeamProvisioning>
30-
<EnableAppSandbox Condition="'$(EnableAppSandbox)' == ''">false</EnableAppSandbox>
31-
</PropertyGroup>
32-
<!-- Fix temporary regression, will be fixed on the main in a separate PR: https://github.com/dotnet/runtime/issues/80911 -->
33-
<Import Project="$(CoreClrProjectRoot)nativeaot\BuildIntegration\Microsoft.DotNet.ILCompiler.SingleEntry.targets" />
32+
<Import Condition="'$(PublishAotUsingRuntimePack)' != 'true'" Project="$(CoreClrProjectRoot)nativeaot\BuildIntegration\Microsoft.DotNet.ILCompiler.SingleEntry.targets" />
3433
<UsingTask TaskName="AppleAppBuilderTask"
3534
AssemblyFile="$(AppleAppBuilderTasksAssemblyPath)" />
3635

37-
<!-- FIXME: Once we set up builing appropriate runtime package for iOS-like platforms the following properties should be removed -->
38-
<Target Name="ConfigureIlcPathsForiOSCrossCompilation">
36+
<!-- Use locally built runtime and ilcompiler packages -->
37+
<Target Name="UpdateRuntimePackVersion" Condition="'$(PublishAotUsingRuntimePack)' == 'true'" BeforeTargets="ProcessFrameworkReferences">
38+
<ItemGroup>
39+
<KnownRuntimePack Condition="%(RuntimePackLabels) == 'NativeAOT'" LatestRuntimeFrameworkVersion="8.0.0-dev" />
40+
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler">
41+
<ILCompilerPackVersion>8.0.0-dev</ILCompilerPackVersion>
42+
</KnownILCompilerPack>
43+
</ItemGroup>
44+
</Target>
45+
46+
<!-- Run before ILC setup -->
47+
<Target Name="ConfigureIlcPathsForiOSCrossCompilation" Condition="'$(PublishAotUsingRuntimePack)' != 'true'"
48+
BeforeTargets="SetupProperties">
3949
<PropertyGroup>
4050
<IlcPath>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(CoreCLRConfiguration)', 'ilc'))</IlcPath>
4151
<IlcToolsPath>$(IlcPath)</IlcToolsPath>
@@ -47,23 +57,29 @@
4757

4858
<Target Name="BuildAppBundle"
4959
AfterTargets="Build"
50-
DependsOnTargets="ConfigureIlcPathsForiOSCrossCompilation;SetupProperties;ComputeIlcCompileInputs;IlcCompile">
60+
DependsOnTargets="IlcCompile;CopyFilesToPublishDirectory">
5161

5262
<PropertyGroup>
5363
<AppDir>$(MSBuildThisFileDirectory)$(PublishDir)\app</AppDir>
54-
<IosSimulator Condition="'$(TargetsiOSSimulator)' == 'true'">iPhone 11</IosSimulator>
5564
<Optimized Condition="'$(Configuration)' == 'Release'">True</Optimized>
65+
<StripDebugSymbols Condition="'$(StripDebugSymbols)' == ''">false</StripDebugSymbols>
66+
<DevTeamProvisioning Condition="'$(TargetOS)' == 'maccatalyst' and '$(DevTeamProvisioning)' == ''">adhoc</DevTeamProvisioning>
67+
<EnableAppSandbox Condition="'$(TargetOS)' == 'maccatalyst' and '$(EnableAppSandbox)' == ''">false</EnableAppSandbox>
5668
</PropertyGroup>
5769

5870
<ItemGroup>
59-
<NativeLibrary Include="%(ManagedBinary.IlcOutputFile)" />
71+
<_LinkerFlagsToDrop Include="@(NativeFramework->'-framework %(Identity)')" />
72+
<_LinkerFlagsToDrop Include="@(LinkerArg)" Condition="$([System.String]::new('%(Identity)').Contains('swift'))" />
73+
<LinkerArg Remove="@(_LinkerFlagsToDrop)" />
74+
<ExtraLinkerArguments Include="@(LinkerArg)" />
75+
<_NativeDependencies Include="%(ManagedBinary.IlcOutputFile)" />
6076
</ItemGroup>
6177

6278
<RemoveDir Directories="$(AppDir)" />
6379

6480
<AppleAppBuilderTask
6581
UseNativeAOTRuntime="$(UseNativeAOTRuntime)"
66-
NativeDependencies="@(NativeLibrary)"
82+
NativeDependencies="@(_NativeDependencies)"
6783
TargetOS="$(TargetOS)"
6884
Arch="$(TargetArchitecture)"
6985
ProjectName="$(AppName)"
@@ -74,8 +90,10 @@
7490
OutputDirectory="$(AppDir)"
7591
Optimized="$(Optimized)"
7692
InvariantGlobalization="$(InvariantGlobalization)"
93+
EnableAppSandbox="$(EnableAppSandbox)"
7794
StripSymbolTable="$(StripDebugSymbols)"
78-
AppDir="$(MSBuildThisFileDirectory)$(PublishDir)" >
95+
AppDir="$(MSBuildThisFileDirectory)$(PublishDir)"
96+
ExtraLinkerArguments="@(ExtraLinkerArguments)" >
7997
<Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
8098
<Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
8199
</AppleAppBuilderTask>

src/mono/sample/iOS-NativeAOT/README.md

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,61 @@ This sample application is intended to be used by developers who work on enablin
1111

1212
The sample shares the source code with the Mono sample specified at: `../iOS/Program.cs` and in general should have the same behavior as MonoAOT.
1313

14-
## Limitations
14+
## Scenarios
1515

16-
The application is **_currently_** relying on the following:
17-
1. Internal dependencies - locally building the internals is required as runtime and tools nuget packages are still not being produced
18-
2. Invariant globalization - `System.Globalization.Native` is currently not being built as part of NativeAOT framework for iOS-like platforms
19-
3. No publish targets - the SDK and MSBuild integration is still not complete
16+
There are two scenarios for building and testing the NativeAOT support for iOS:
17+
1. Testing against locally built internals
18+
- Uses locally built ILCompiler, build integration targets, framework and runtime libraries
19+
- Should be used in CI testing
20+
2. Testing against locally built packages - **end-to-end** testing
21+
- References locally built ILCompiler and runtime packages
22+
- Should be used by developers performing end-to-end validation
2023

2124
## How to build and test
2225

23-
### Building for the first time
26+
### 1. Testing against locally built internals
2427

2528
When building for the first time (on a clean checkout) run from this directory the following `make` command:
2629
``` bash
2730
make world
2831
```
29-
This will first build all required runtime components and dependencies, after which it will build the sample app and bundle it into an application bundle.
32+
33+
The command performs the following:
34+
1. Build all required runtime components and dependencies
35+
2. Build the sample app and bundle it into an application bundle
36+
3037
By default the build will use `Debug` build configuration and target `iossimulator`.
3138
To change this behavior, specify the desired setting in the following way:
3239
``` bash
3340
make world BUILD_CONFIG=Release TARGET_OS=ios
3441
```
3542

43+
### 2. Testing against locally built packages - end-to-end testing
44+
45+
When building for the first time (on a clean checkout) run from this directory the following `make` command:
46+
``` bash
47+
make world USE_RUNTIME_PACKS=true
48+
```
49+
50+
The command performs the following:
51+
1. Builds ILCompiler and runtime packages:
52+
- `Microsoft.DotNet.ILCompiler.8.0.0-dev` (host)
53+
- `runtime.<host_os>-<host_arch>.Microsoft.DotNet.ILCompiler.8.0.0-dev` (host)
54+
- `Microsoft.NETCore.App.Runtime.NativeAOT.<target_os>-<target_arch>.8.0.0-dev` (target)
55+
56+
NOTE:
57+
- The packages can be found at: `artifacts/packages/<config>/Shipping/*.8.0.0-dev.nupkg`
58+
- During the build of the application NuGet is instructed to use the local `./packages` folder (in the current directory) as the folder for restored packages, which should be deleted when testing incremental changes. This is required as the packages built locally always have the same version - `8.0.0-dev`. For convenience, targets in the `Makefile` are automatically removing this folder on a rebuild.
59+
2. Build the sample app using locally built packages 1) and bundle it into an application bundle
60+
61+
By default the build will use `Debug` build configuration and target `iossimulator`.
62+
To change this behavior, specify the desired setting in the following way:
63+
``` bash
64+
make world USE_RUNTIME_PACKS=true BUILD_CONFIG=Release TARGET_OS=ios
65+
```
66+
67+
NOTE: In general, the make variable `USE_RUNTIME_PACKS` controls which scenario will be used during the build (the default value is `false`)
68+
3669
### To avoid building all the dependencies
3770

3871
For future builds, you can run just:
@@ -46,6 +79,8 @@ For convenience, it is also possible to rebuild only the application it self wit
4679
make hello-app
4780
```
4881

82+
NOTE: Pay attention to the scenario you are testing `USE_RUNTIME_PACKS=true or false`
83+
4984
### Deploy and run
5085

5186
#### Simulator
@@ -64,16 +99,22 @@ export DevTeamProvisioning=A1B2C3D4E5; make hello-app TARGET_OS=ios DEPLOY_AND_R
6499
```
65100
Assuming `A1B2C3D4E5` is a valid team ID.
66101

67-
#### One-liner
102+
### One-liners
68103

69104
On a clean dotnet/runtime checkout, from this directory, run:
70105

71106
``` bash
72107
export DevTeamProvisioning=A1B2C3D4E5; make world BUILD_CONFIG=Release TARGET_OS=ios DEPLOY_AND_RUN=true
73108
```
74109

75-
This command will build everything necessary to run and deploy the application on an iOS device.
110+
- This command will build everything necessary to run and deploy the application on an iOS device using the locally built internals.
111+
112+
``` bash
113+
export DevTeamProvisioning=A1B2C3D4E5; make world BUILD_CONFIG=Release TARGET_OS=ios DEPLOY_AND_RUN=true USE_RUNTIME_PACKS=true
114+
```
115+
116+
- This command will build everything necessary to run and deploy the application on an iOS device using the locally built packages.
76117

77118
### Custom builds
78119

79-
Check the `Makefile` for individual list of targets and variables to customize the build.
120+
Check the `Makefile` for individual list of targets and variables to further customize your builds.

src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,11 @@ target_link_libraries(
7676
"-lc++"
7777
"-liconv"
7878
%NativeLibrariesToLink%
79-
%APP_LINKER_ARGS%
79+
%APP_LINK_LIBRARIES%
8080
)
8181

82-
if(%UseNativeAOTRuntime%)
83-
target_link_libraries(
84-
%ProjectName%
85-
PRIVATE
86-
"-Wl,-u,_NativeAOT_StaticInitialization"
87-
"-Wl,-segprot,__THUNKS,rx,rx"
82+
set_target_properties(
83+
%ProjectName%
84+
PROPERTIES LINK_FLAGS
85+
%EXTRA_LINKER_ARGS%
8886
)
89-
endif()

src/tasks/AppleAppBuilder/Xcode.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,12 @@ public string GenerateCMake(
411411
frameworks = "\"-framework GSS\"";
412412
}
413413

414-
string appLinkerArgs = "";
415-
foreach(string linkerArg in extraLinkerArgs)
416-
{
417-
appLinkerArgs += $" \"{linkerArg}\"{Environment.NewLine}";
418-
}
419-
420-
appLinkerArgs += $" {frameworks}{Environment.NewLine}";
414+
string appLinkLibraries = $" {frameworks}{Environment.NewLine}";
415+
string extraLinkerArgsConcat = $"\"{string.Join('\n', extraLinkerArgs)}\"";
421416

422417
cmakeLists = cmakeLists.Replace("%NativeLibrariesToLink%", toLink);
423-
cmakeLists = cmakeLists.Replace("%APP_LINKER_ARGS%", appLinkerArgs);
418+
cmakeLists = cmakeLists.Replace("%APP_LINK_LIBRARIES%", appLinkLibraries);
419+
cmakeLists = cmakeLists.Replace("%EXTRA_LINKER_ARGS%", extraLinkerArgsConcat);
424420
cmakeLists = cmakeLists.Replace("%AotSources%", aotSources);
425421
cmakeLists = cmakeLists.Replace("%AotTargetsList%", aotList);
426422
cmakeLists = cmakeLists.Replace("%AotModulesSource%", string.IsNullOrEmpty(aotSources) ? "" : "modules.m");

0 commit comments

Comments
 (0)