Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT] Improving HelloiOS sample for NativeAOT to be testable with runtime packs #86652

Merged
merged 21 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
478e01f
HelloiOS sample improvements and sync with main branch
ivanpovazan May 23, 2023
9ca9c3f
Fix the way we are passing extra linker arguments from AppleAppBuilder
ivanpovazan May 23, 2023
daa1c0c
Use ILC collected linker arguments for bundling the application
ivanpovazan May 23, 2023
37b1550
Use better naming in the Makefile
ivanpovazan May 23, 2023
c94e9f0
Prepare grounds for PublishAotUsingRuntimePack = true
ivanpovazan May 23, 2023
9afd5fb
Update ILCompiler paths to handle PublishAotUsingRuntimePack=true
filipnavara May 9, 2023
5f2fe86
Enable using runtime pack from NuGet
ivanpovazan May 23, 2023
08126df
Use publish instead
ivanpovazan May 25, 2023
a8665ce
FIXME: revert once testing is finished
ivanpovazan May 23, 2023
c2eeead
Cleaning up the code
ivanpovazan May 25, 2023
2e6c29c
Fix for using publish targets
ivanpovazan May 29, 2023
65de62f
Prevent building invalid Microsoft.DotNet.ILCompiler package
ivanpovazan May 31, 2023
ae968cf
Updating README.md to reflect the changes
ivanpovazan Jun 1, 2023
ce1c9c4
PR feedback
ivanpovazan Jun 1, 2023
d4da903
Merge remote-tracking branch 'upstream/main' into hellios-packs
ivanpovazan Jun 1, 2023
808b121
Fix markdownlint errors
ivanpovazan Jun 1, 2023
5693fd3
Escape NativeAOT bundling targets
ivanpovazan Jun 2, 2023
a221b5a
Use local folder for restore packages
ivanpovazan Jun 2, 2023
6514512
PR feedback on documentation
ivanpovazan Jun 2, 2023
7c0fd97
Use IlcSdkPath instead of IlcPrivateSdkPath
filipnavara Jun 3, 2023
c9d5543
Revert "FIXME: revert once testing is finished"
ivanpovazan Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"sdk": {
"version": "8.0.100-preview.4.23260.5",
"version": "8.0.100-preview.5.23267.7",
ivanpovazan marked this conversation as resolved.
Show resolved Hide resolved
"allowPrerelease": true,
"rollForward": "major"
},
"tools": {
"dotnet": "8.0.100-preview.4.23260.5"
"dotnet": "8.0.100-preview.5.23267.7"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23280.3",
Expand All @@ -15,4 +15,4 @@
"Microsoft.Build.Traversal": "3.4.0",
"Microsoft.NET.Sdk.IL": "8.0.0-preview.5.23279.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
Text="Add a PackageReference for '$(_hostPackageName)' to allow cross-compilation for $(_targetArchitecture)" />

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

<ComputeManagedAssembliesToCompileToNative
Assemblies="@(_ResolvedCopyLocalPublishAssets)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup>
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
<NativeLibrary Condition="'$(NativeLib)' == '' and '$(CustomNativeMain)' != 'true'" Include="$(IlcSdkPath)libbootstrapper.a" />
<NativeLibrary Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'" Include="$(IlcSdkPath)libbootstrapperdll.a" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName).a" />
<NativeLibrary Include="$(IlcSdkPath)$(EventPipeName)$(LibFileExt)" />
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
<NativeLibrary Condition="'$(NativeLib)' == '' and '$(CustomNativeMain)' != 'true'" Include="$(IlcPrivateSdkPath)libbootstrapper.a" />
<NativeLibrary Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'" Include="$(IlcPrivateSdkPath)libbootstrapperdll.a" />
<NativeLibrary Include="$(IlcPrivateSdkPath)$(FullRuntimeName).a" />
<NativeLibrary Include="$(IlcPrivateSdkPath)$(EventPipeName)$(LibFileExt)" />
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcPrivateSdkPath)libstdc++compat.a" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,41 @@ The .NET Foundation licenses this file to you under the MIT license.

<!-- The properties below need to be defined only after we've found the correct runtime package reference -->
<Target Name="SetupProperties" DependsOnTargets="$(IlcSetupPropertiesDependsOn)" BeforeTargets="Publish">
<ItemGroup>
<_NETCoreAppFrameworkReference Include="@(ResolvedFrameworkReference)" Condition="'%(ResolvedFrameworkReference.RuntimePackName)' == 'Microsoft.NETCore.App.Runtime.NativeAOT.$(RuntimeIdentifier)'" />
</ItemGroup>

<PropertyGroup>
<!-- Define paths used in build targets to point to the runtime-specific ILCompiler implementation -->
<IlcToolsPath Condition="'$(IlcToolsPath)' == ''">$(IlcHostPackagePath)\tools\</IlcToolsPath>
<IlcSdkPath Condition="'$(IlcSdkPath)' == ''">$(RuntimePackagePath)\sdk\</IlcSdkPath>
ivanpovazan marked this conversation as resolved.
Show resolved Hide resolved
<IlcFrameworkPath Condition="'$(IlcFrameworkPath)' == ''">$(RuntimePackagePath)\framework\</IlcFrameworkPath>
<IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == ''">$(RuntimePackagePath)\framework\</IlcFrameworkNativePath>
<IlcFrameworkPath Condition="'$(IlcFrameworkPath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\framework\</IlcFrameworkPath>
<_NETCoreAppRuntimePackPath>%(_NETCoreAppFrameworkReference.RuntimePackPath)/runtimes/$(RuntimeIdentifier)/</_NETCoreAppRuntimePackPath>
<IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == '' and '$(PublishAotUsingRuntimePack)' == 'true'">$(_NETCoreAppRuntimePackPath)\native\</IlcFrameworkNativePath>
<IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\framework\</IlcFrameworkNativePath>
<IlcPrivateSdkPath Condition="'$(IlcPrivateSdkPath)' == '' and '$(PublishAotUsingRuntimePack)' == 'true'">$(IlcFrameworkNativePath)</IlcPrivateSdkPath>
<IlcPrivateSdkPath Condition="'$(IlcPrivateSdkPath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(IlcSdkPath)</IlcPrivateSdkPath>
<IlcMibcPath Condition="'$(IlcMibcPath)' == ''">$(RuntimePackagePath)\mibc\</IlcMibcPath>
</PropertyGroup>

<ItemGroup>
<PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" />
<ItemGroup Condition="'$(PublishAotUsingRuntimePack)' == 'true'">
<PrivateSdkAssemblies Include="$(IlcPrivateSdkPath)*.dll"/>
<FrameworkAssemblies Include="@(RuntimePackAsset)" Condition="'%(Extension)' == '.dll'" />
<DefaultFrameworkAssemblies Include="@(FrameworkAssemblies)" />
</ItemGroup>

<ItemGroup Condition="'$(PublishAotUsingRuntimePack)' != 'true'">
<PrivateSdkAssemblies Include="$(IlcPrivateSdkPath)*.dll"/>
<!-- Exclude unmanaged dlls -->
<FrameworkAssemblies Include="$(IlcFrameworkPath)*.dll" Exclude="$(IlcFrameworkPath)*.Native.dll;$(IlcFrameworkPath)msquic.dll" />

<MibcFile Include="$(IlcMibcPath)*.mibc" Condition="'$(IlcPgoOptimize)' == 'true'" />

<DefaultFrameworkAssemblies Include="@(FrameworkAssemblies)" />
<DefaultFrameworkAssemblies Include="@(PrivateSdkAssemblies)" />
</ItemGroup>

<ItemGroup>
<MibcFile Include="$(IlcMibcPath)*.mibc" Condition="'$(IlcPgoOptimize)' == 'true'" />
</ItemGroup>
</Target>

<Target Name="ComputeIlcCompileInputs" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)" BeforeTargets="Publish">
Expand Down
2 changes: 1 addition & 1 deletion src/installer/pkg/projects/nativeaot-packages.proj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<ItemGroup>
<Project Include="Microsoft.DotNet.ILCompiler\Microsoft.DotNet.ILCompiler.pkgproj" />
<ProjectReference Include="@(Project)" />
<ProjectReference Condition="'$(BuildNativeAOTRuntimePack)' != 'true'" Include="@(Project)" />
<ProjectReference Include="@(Project)" AdditionalProperties="PackageTargetRuntime=$(OutputRID)" />
</ItemGroup>

Expand Down
17 changes: 13 additions & 4 deletions src/mono/sample/iOS-NativeAOT/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ TARGET_ARCH?=$(shell . $(TOP)eng/native/init-os-and-arch.sh && echo $${arch})
TARGET_OS?=iossimulator
DEPLOY_AND_RUN?=false
STRIP_DEBUG_SYMBOLS?=false
USE_RUNTIME_PACKS?=false

REPO_DIR=$(realpath $(TOP))
TASKS_DIR=$(REPO_DIR)/src/tasks
Expand All @@ -16,19 +17,26 @@ BUILD_SCRIPT=$(REPO_DIR)/build.sh
world: build-deps all

# build all dependencies: runtime, nativeAot and all the libs
ifeq ($(USE_RUNTIME_PACKS),false)
build-deps: build-runtime-ilc build-libs-all
else
build-deps: build-runtime-ilc-packs build-libs-all-packs
endif

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

build-ilc:
$(BUILD_SCRIPT) clr.aot -c $(BUILD_CONFIG)
build-runtime-ilc-packs:
$(BUILD_SCRIPT) clr+clr.aot+libs+packs -c $(BUILD_CONFIG)

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

build-libs-all-packs:
$(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs+libs+packs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH) /p:BuildNativeAOTRuntimePack=true

build-libs-nativeaot:
$(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH)

Expand All @@ -39,12 +47,13 @@ appbuilder:

hello-app: clean
$(DOTNET) \
build -c $(BUILD_CONFIG) \
publish -c $(BUILD_CONFIG) \
-p:TargetOS=$(TARGET_OS) \
-p:TargetArchitecture=$(TARGET_ARCH) \
-p:DeployAndRun=$(DEPLOY_AND_RUN) \
-p:StripDebugSymbols=$(STRIP_DEBUG_SYMBOLS) \
-p:PublishAotUsingRuntimePack=$(USE_RUNTIME_PACKS) \
-bl

clean:
rm -rf obj bin
rm -rf obj bin *.binlog
64 changes: 42 additions & 22 deletions src/mono/sample/iOS-NativeAOT/Program.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,50 @@
<OutputPath>bin</OutputPath>
<IntermediateOutputPath>$(MSBuildThisFileDirectory)/obj/</IntermediateOutputPath>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<TargetOS Condition="'$(TargetOS)' == ''">ios</TargetOS>
<TargetOS Condition="'$(TargetsiOSSimulator)' == 'true'">iossimulator</TargetOS>
<TargetOS Condition="'$(TargetOS)' == ''">iossimulator</TargetOS>
<DeployAndRun Condition="'$(DeployAndRun)' == ''">true</DeployAndRun>
<RuntimeIdentifier>$(TargetOS)-$(TargetArchitecture)</RuntimeIdentifier>
<AppName>HelloiOS</AppName>
<StripDebugSymbols Condition="'$(StripDebugSymbols)' == ''">false</StripDebugSymbols>
<!-- NativeAOT-specific props -->
<NativeLib>static</NativeLib>
<CustomNativeMain>true</CustomNativeMain>
<UseNativeAOTRuntime Condition="'$(UseNativeAOTRuntime)' == ''">true</UseNativeAOTRuntime>
<!-- FIXME: Once we support building System.Globalization.Native and icu, should be removed -->
<InvariantGlobalization>true</InvariantGlobalization>
<!-- FIXME: We do not use publish targets yet, but we need to create a publish directory -->
<PublishDir Condition="'$(PublishDir)' == ''">$(OutputPath)/publish</PublishDir>
<NativeLib>static</NativeLib>
<CustomNativeMain>true</CustomNativeMain>
</PropertyGroup>

<PropertyGroup Condition="'$(PublishAotUsingRuntimePack)' == 'true'">
<PublishAot>true</PublishAot>
<MSBuildWarningsAsErrors>$(MSBuildWarningsAsErrors);NU1603</MSBuildWarningsAsErrors>
<UseLocalTargetingRuntimePack>false</UseLocalTargetingRuntimePack>
<RestoreAdditionalProjectSources>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'packages', '$(CoreCLRConfiguration)', 'Shipping'))</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\iOS\Program.cs" Link="Program.cs" />
<DirectPInvoke Include="__Internal" />
</ItemGroup>

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

<!-- FIXME: Once we set up builing appropriate runtime package for iOS-like platforms the following properties should be removed -->
<Target Name="ConfigureIlcPathsForiOSCrossCompilation">
<!-- Escape publish-related targets from NativeAOT -->
<Target Name="_ComputeAssembliesToCompileToNative" />
<Target Name="ComputeLinkedFilesToPublish" />
<Target Name="CopyNativeBinary" />

<!-- Use locally built runtime and ilcompiler packages -->
<Target Name="UpdateRuntimePackVersion" Condition="'$(PublishAotUsingRuntimePack)' == 'true'" BeforeTargets="ProcessFrameworkReferences">
<ItemGroup>
<KnownRuntimePack Condition="%(RuntimePackLabels) == 'NativeAOT'" LatestRuntimeFrameworkVersion="8.0.0-dev" />
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler">
<ILCompilerPackVersion>8.0.0-dev</ILCompilerPackVersion>
</KnownILCompilerPack>
</ItemGroup>
</Target>

<!-- Run before ILC setup -->
<Target Name="ConfigureIlcPathsForiOSCrossCompilation" Condition="'$(PublishAotUsingRuntimePack)' != 'true'"
BeforeTargets="SetupProperties">
<PropertyGroup>
<IlcPath>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(CoreCLRConfiguration)', 'ilc'))</IlcPath>
<IlcToolsPath>$(IlcPath)</IlcToolsPath>
Expand All @@ -47,23 +59,29 @@

<Target Name="BuildAppBundle"
AfterTargets="Build"
DependsOnTargets="ConfigureIlcPathsForiOSCrossCompilation;SetupProperties;ComputeIlcCompileInputs;IlcCompile">
DependsOnTargets="IlcCompile;CopyFilesToPublishDirectory">

<PropertyGroup>
<AppDir>$(MSBuildThisFileDirectory)$(PublishDir)\app</AppDir>
<IosSimulator Condition="'$(TargetsiOSSimulator)' == 'true'">iPhone 11</IosSimulator>
<Optimized Condition="'$(Configuration)' == 'Release'">True</Optimized>
<StripDebugSymbols Condition="'$(StripDebugSymbols)' == ''">false</StripDebugSymbols>
<DevTeamProvisioning Condition="'$(TargetOS)' == 'maccatalyst' and '$(DevTeamProvisioning)' == ''">adhoc</DevTeamProvisioning>
<EnableAppSandbox Condition="'$(TargetOS)' == 'maccatalyst' and '$(EnableAppSandbox)' == ''">false</EnableAppSandbox>
</PropertyGroup>

<ItemGroup>
<NativeLibrary Include="%(ManagedBinary.IlcOutputFile)" />
<_LinkerFlagsToDrop Include="@(NativeFramework->'-framework %(Identity)')" />
<_LinkerFlagsToDrop Include="@(LinkerArg)" Condition="$([System.String]::new('%(Identity)').Contains('swift'))" />
<LinkerArg Remove="@(_LinkerFlagsToDrop)" />
<ExtraLinkerArguments Include="@(LinkerArg)" />
<_NativeDependencies Include="%(ManagedBinary.IlcOutputFile)" />
</ItemGroup>

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

<AppleAppBuilderTask
UseNativeAOTRuntime="$(UseNativeAOTRuntime)"
NativeDependencies="@(NativeLibrary)"
NativeDependencies="@(_NativeDependencies)"
TargetOS="$(TargetOS)"
Arch="$(TargetArchitecture)"
ProjectName="$(AppName)"
Expand All @@ -74,8 +92,10 @@
OutputDirectory="$(AppDir)"
Optimized="$(Optimized)"
InvariantGlobalization="$(InvariantGlobalization)"
EnableAppSandbox="$(EnableAppSandbox)"
StripSymbolTable="$(StripDebugSymbols)"
AppDir="$(MSBuildThisFileDirectory)$(PublishDir)" >
AppDir="$(MSBuildThisFileDirectory)$(PublishDir)"
ExtraLinkerArguments="@(ExtraLinkerArguments)" >
<Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
<Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
</AppleAppBuilderTask>
Expand Down
62 changes: 51 additions & 11 deletions src/mono/sample/iOS-NativeAOT/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,67 @@ This sample application is intended to be used by developers who work on enablin

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.

## Limitations
## Scenarios

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

## How to build and test

### Building for the first time
### 1. Testing against locally built internals

When building for the first time (on a clean checkout) run from this directory the following `make` command:
``` bash
make world
```
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.

The command performs the following:
1. Build all required runtime components and dependencies
2. Build the sample app and bundle it into an application bundle

By default the build will use `Debug` build configuration and target `iossimulator`.
To change this behavior, specify the desired setting in the following way:
``` bash
make world BUILD_CONFIG=Release TARGET_OS=ios
```

### To avoid building all the dependencies
### 2. Testing against locally built packages - end-to-end testing

When building for the first time (on a clean checkout) run from this directory the following `make` command:
``` bash
make world USE_RUNTIME_PACKS=true
```

The command performs the following:
1. Builds ILCompiler and runtime packages:
- `Microsoft.DotNet.ILCompiler.8.0.0-dev` (host)
- `runtime.<host_os>-<host_arch>.Microsoft.DotNet.ILCompiler.8.0.0-dev` (host)
- `Microsoft.NETCore.App.Runtime.NativeAOT.<target_os>-<target_arch>.8.0.0-dev` (target)

NOTE:
- The packages can be found at: `artifacts/packages/<config>/Shipping/*.8.0.0-dev.nupkg`
- For testing incremental changes make sure to remove the **restored** nuget packages listed above with `8.0.0-dev` from your nuget restore directory (usually `~/.nuget/packages`). Failing to do so, can lead to unexpected behavior, as nuget will refuse to install newly generate package with a same version - `8.0.0-dev`. Something like:
ivanpovazan marked this conversation as resolved.
Show resolved Hide resolved
```
rm -rf ~/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0-dev
rm -rf ~/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-dev
rm -rf ~/.nuget/packages/microsoft.netcore.app.runtime.nativeaot.ios-arm64/8.0.0-dev
```
2. Build the sample app using locally built packages 1) and bundle it into an application bundle

By default the build will use `Debug` build configuration and target `iossimulator`.
To change this behavior, specify the desired setting in the following way:
``` bash
make world USE_RUNTIME_PACKS=true BUILD_CONFIG=Release TARGET_OS=ios
```

NOTE: In general, the make variable `USE_RUNTIME_PACKS` controls which scenario will be used during the build (the default value is `false`)

#### To avoid building all the dependencies
ivanpovazan marked this conversation as resolved.
Show resolved Hide resolved

For future builds, you can run just:
``` bash
Expand All @@ -46,16 +84,18 @@ For convenience, it is also possible to rebuild only the application it self wit
make hello-app
```

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

#### Deploy and run

#### Simulator
##### Simulator

To test the application on a simulator include the following in your make command `DEPLOY_AND_RUN=true` e.g.,:
``` bash
make hello-app DEPLOY_AND_RUN=true
```

#### Device
##### Device

To test the application on a device, a provisioning profile needs to be specified.
This can be achieved by defining `DevTeamProvisioning` environment variable with a valid team ID (see [developer.apple.com/account/#/membership](https://developer.apple.com/account/#/membership), scroll down to `Team ID`) for example:
Expand Down
13 changes: 5 additions & 8 deletions src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ target_link_libraries(
"-lc++"
"-liconv"
%NativeLibrariesToLink%
%APP_LINKER_ARGS%
%APP_LINK_LIBRARIES%
)

if(%UseNativeAOTRuntime%)
target_link_libraries(
%ProjectName%
PRIVATE
"-Wl,-u,_NativeAOT_StaticInitialization"
"-Wl,-segprot,__THUNKS,rx,rx"
set_target_properties(
%ProjectName%
PROPERTIES LINK_FLAGS
%EXTRA_LINKER_ARGS%
)
endif()