What is the binary difference between IPA coming from AppStore and those from XCode?

StackOverflow https://stackoverflow.com/questions/23571134

  •  19-07-2023
  •  | 
  •  

Long story short:

How can I debug an iPhone-App directly on the hardware (iPhone) in exactly the same version/binary as it would be distributed by AppStore without the need to wait for AppStore-Preview-Process?

En detail:

I detected strong differences with the behaviour of an MKMapView between a compiled IPA running on an iPhone using Developer Profile via XCode/USB-Cable and between the Version installed directly from an AppStore after the Distribution-To-AppStore-Process.

I will attach two significant Screenshots.

This is how the App launches the MKMapView on an iPhone via XCode/USB-Cable pointing to the current users location with a special region:

enter image description here

And this is how the same App launches on the same iPhone after installing the distributed version from the AppStore without any code changes to the previous one:

enter image description here

Here i will provide some Code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.mapView removeAnnotations:[self.mapView annotations]];

    CLLocationCoordinate2D noLocation;
    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(noLocation, 6500, 6500);
    MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
    [self.mapView setRegion:adjustedRegion animated:NO];

    mapView.delegate = self;

    mapView.showsUserLocation = YES;
    mapView.mapType = MKMapTypeStandard;

}

- (void)mapView:(MKMapView *)theMapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    theMapView.centerCoordinate = userLocation.location.coordinate;
}

Btw, just for your information: here occured another difference between an IPA running directly on the iPhone launched by XCode and the distributed Archive via AppStore. Without the Line "[self.mapView removeAnnotations:[self.mapView annotations]];" the App crashed directly after launch in the installed Version from AppStore, but not when running from XCode. This issue i ran into in a previous version and is not part of this question, just an addition to the main question

The main question is:

Is it possible to debug an iPhone-App exactly the same way as it would be distributed by AppStore without the need to wait for AppStore-Preview-Process, and if yes, how?

有帮助吗?

解决方案 2

The version of the app you run on your iphone via Xcode will be in debug mode, the one on the App Store is in release mode. If you use preprocessors macro (like DEBUG), this could change the behaviour of your app.

If you think this could be the problem, go in XCode, in Product > Scheme > Edit Scheme, select your project's target and change the BuildConfiguration to Release. You will see how your app run in release mode even if you run it from Xcode. It will be easier to debug the behaviour of your app.

其他提示

The main difference here is just likely to be a release build versus a debug build. You've got:

CLLocationCoordinate2D noLocation;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(noLocation, 6500, 6500);

You don't set any initial value to noLocation. It's a raw struct so nobody else does either. It could have any value whatsoever. As a result adjustedRegion could be any region. No doubt it just happens to be something vaguely valid on your debug build and something completely nonsensical on your release build. Then probably MKMapView decides to show the entire earth if it can't make sense of the thing and when you shift the centre to the shops in your area it doesn't affect the zoom.

To fix, give noLocation a defined, valid value.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top