Closed hadiz closed 5 years ago
Hi @hadiz,
Would you mind adding your C# code? Might make it a little easier for us to diagnose your issue. Also do you get any stack trace or relevant message in your application output pad?
@merckxite Thanks for your reply. unfortunately, there is no stack trace when running the app in the simulator. The C# code is:
public class MainPageRenderer : PageRenderer
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
var subView = new LineChartView();
this.View.AddSubview(subView);
subView.TranslatesAutoresizingMaskIntoConstraints = false;
subView.BackgroundColor = UIColor.Red;
this.View.BackgroundColor = UIColor.Green;
NSLayoutConstraint.ActivateConstraints(constraints: new NSLayoutConstraint[] {
NSLayoutConstraint.Create(subView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View.SafeAreaLayoutGuide, NSLayoutAttribute.Top, 1.0f, 0.0f),
NSLayoutConstraint.Create(subView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this.View.SafeAreaLayoutGuide, NSLayoutAttribute.Leading, 1.0f, 0.0f),
NSLayoutConstraint.Create(subView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this.View.SafeAreaLayoutGuide, NSLayoutAttribute.Trailing, 1.0f, 0.0f),
NSLayoutConstraint.Create(subView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.View.SafeAreaLayoutGuide, NSLayoutAttribute.Bottom, 1.0f, 0.0f) });
double[] numbers = new double[] { 10, 20, 30, 40, 50 };
ChartDataEntry[] lineChartEntry = new ChartDataEntry[numbers.Length];
for (int i = 0; i < numbers.Length; i++)
{
var value = new ChartDataEntry(x: i, y: numbers[i]);
lineChartEntry[i] = value;
}
var line1 = new LineChartDataSet(values: lineChartEntry, label: "Number");
if (line1 != null)
line1.Colors = new UIColor[] { UIColor.Blue };
var data = new LineChartData();
data.AddDataSet(line1);
subView.Data = data;
subView.ChartDescription.Text = "My awesome chart";
}
}
same issue, and found the libswiftcore.dylib do not contain libswiftCore_simulator.x64 there only include three file:
libswiftCore.arm-9
libswiftCore.arm-11
libswiftCore.cpu16777228
that look like missing the libswiftcore for simulator ?
need more help.
I am using iOSChart 3.2.1, Visual Studio for mac 7.7.2, Xcode 10.1 and iOS 12.1.
and i found the trace log here:
Termination Reason: DYLD, [0x2] Wrong architecture
Application Specific Information:
dyld: launch, loading dependent libraries
DYLD_FALLBACK_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks
Dyld Error Message:
Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/D0C29721-C832-41D3-8778-27159A892C22/data/Containers/Bundle/Application/540A9174-A046-46E3-B2EA-E0C346D7E659/AFORS.APP.iOS.app/Frameworks/Charts.framework/Charts
Reason: no suitable image found. Did find:
/Users/rocky/Library/Developer/CoreSimulator/Devices/D0C29721-C832-41D3-8778-27159A892C22/data/Containers/Bundle/Application/540A9174-A046-46E3-B2EA-E0C346D7E659/AFORS.APP.iOS.app/Frameworks/libswiftCore.dylib: no matching architecture in universal wrapper
then i replay those files in /Users/rocky/Library/Developer/CoreSimulator/Devices/D0C29721-C832-41D3-8778-27159A892C22/data/Containers/Bundle/Application/540A9174-A046-46E3-B2EA-E0C346D7E659/AFORS.APP.iOS.app/Frameworks/
with the dylib files for simulator from Xamarin.Swift3.Support source code then my app run in simulator normally.
can u place those files for simulator into the nuget package?
@alisterk The architectures for simulator are included in the Nuget packages. They are included in a different folder called SwiftSimulator. When you build your app for Debug|Simulator
a script (https://github.com/Flash3001/Xamarin.Swift3.Support/blob/master/Swift4/Xamarin.Swift4/build/Xamarin.Swift4.targets) runs and copy these files to the Frameworks folder.
@hadiz, @alisterk Please check your .csproj to see if this line is included
<Import Project="..\packages\Xamarin.Swift4.4.0.0.1\build\Xamarin.Swift4.targets" Condition="Exists('..\packages\Xamarin.Swift4.4.0.0.1\build\Xamarin.Swift4.targets')" />
It is added when you install the nuget package. Also check if the file exists.
The project uses PackageReference, so the .csproj has the following lines:
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.4.0.1008975" />
<PackageReference Include="iOSCharts">
<Version>3.2.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Swift4.CoreFoundation">
<Version>4.2.1.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Swift4">
<Version>4.0.0.1</Version>
</PackageReference>
</ItemGroup>
@Flash3001 thanks for reply. and i add the line into .csproj. but not work. then i found my nuget global cache path is
c:\users\xxxx.nuget\packages\xamarin.swift4\4.0.0.1\build
and it's still crash as the same error.
i'm using vs2017 15.9.4 ,xamarin.ios 12.2.1.12
updated: and then i tried on macos with vs for mac 7.2.2, the build log shown the *.dylib copied . but the same issue:
Process: AFORS.APP.iOS [21936]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/EBCFAE01-19B3-4C84-8C8A-28D8A174DC01/data/Containers/Bundle/Application/ED1EA3A0-6883-4472-B8CC-9163EB82F5A8/AFORS.APP.iOS.app/AFORS.APP.iOS
Identifier: AFORS.APP.iOS
Responsible: AFORS.APP.iOS [21936]
Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/EBCFAE01-19B3-4C84-8C8A-28D8A174DC01/data/Containers/Bundle/Application/ED1EA3A0-6883-4472-B8CC-9163EB82F5A8/AFORS.APP.iOS.app/Frameworks/Charts.framework/Charts
/Users/rocky/Library/Developer/CoreSimulator/Devices/EBCFAE01-19B3-4C84-8C8A-28D8A174DC01/data/Containers/Bundle/Application/ED1EA3A0-6883-4472-B8CC-9163EB82F5A8/AFORS.APP.iOS.app/Frameworks/libswiftCore.dylib: no matching architecture in universal wrapper
0x1000a9000 - 0x1004c0ff7 +com.castc.afors (1.8 - 1.8) <115C480C-BC8B-3200-8678-85707B634883> /Users/USER/Library/Developer/CoreSimulator/Devices/EBCFAE01-19B3-4C84-8C8A-28D8A174DC01/data/Containers/Bundle/Application/ED1EA3A0-6883-4472-B8CC-9163EB82F5A8/AFORS.APP.iOS.app/AFORS.APP.iOS
0x1038f7000 - 0x103a4ffff +com.dcg.Charts (3.2.0 - 1) <F2BFF26A-0060-3AA7-A2C2-5F91604474E2> /Users/USER/Library/Developer/CoreSimulator/Devices/EBCFAE01-19B3-4C84-8C8A-28D8A174DC01/data/Containers/Bundle/Application/ED1EA3A0-6883-4472-B8CC-9163EB82F5A8/AFORS.APP.iOS.app/Frameworks/Charts.framework/Charts
@alisterk @hadiz I've never used PackageReference myself, but after some investigation, it seems the order that the .target files are imported has changed and it broke things.
Xamarin.Swift4.targets change the behavior for Xamarin.iOS.Common.targets a bit to: 1 - Delete the SwiftFrameworksSimulator folder when building for iPhone. 2 - Copy the contents of SwiftFrameworksSimulator into Frameworks when building for Simulator.
One of the properties defined in there is
<CreateAppBundleDependsOn>
$(CreateAppBundleDependsOn);
_CopySwiftLibsSimulator;
</CreateAppBundleDependsOn>
</PropertyGroup>
But when checking CreateAppBundleDependsOn on a build using PackageReferences the _CopySwiftLibsSimulator dependency was not in there as expected.
The only thing I can imagine could cause this difference was Xamarin.iOS.Common.targets being imported after Xamarin.Swift4.targets and overwriting the properties.
I manually changed Xamarin.iOS.Common.targets to include $(CreateAppBundleDependsOn); (and other 2 requirements) so it wouldn't replace, but add. It did the trick, but it is not a good idea to change that file manually.
The long term solution might be to do a PR on Xamarin applying the changes, but even if it is accepted it will take some time to be released.
The best short term solution is to copy the Xamarin.Swift4.targets file and add it to your project root and add the following line to your .csproj, right after ...Xamarin.iOS.CSharp.targets" />
<Import Project="Xamarin.Swift4.targets" />
My test project looks like this:
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="Xamarin.Swift4.targets" />
@Flash3001 The solution worked for me. Thank you so much.
@Flash3001 thanks for help!! i got it.
Hello, I am trying to run this chart in Xamarin: https://github.com/osianSmith/LineChartExample/blob/master/LineChartExample/ViewController.swift
My problem is that it's working fine in device but fails to run at early stage in simulator. I record a video of the simulator's behaviour: https://www.dropbox.com/s/yehoz1rkrn9cqyy/ChartInSimulator.mov?dl=0
If I remove Chart's related codes, it works fine in simulator too. I am using iOSChart 3.2.1, Visual Studio for mac 7.7.1, Xcode 10.1 and iOS 12.1.
Do you have any idea what the problem is? Thanks!