Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app with Objective-C and swift code crash at launch in release mode, debug mode fine

My project is Objective-C based, and have some third party swift code.

The app runs fine at debug mode, however, when I archive the app as release mode, the app will crash at launch screen.

Set swift optimization level to None still has the same issue. I have crashlytics 3.7 installed, but it crashes at launch, it didn't have a chance to upload the crash. I am very desperate. Any ideas?

Update:

I tried to remove all swift stuff and archive, everything is as usual now. However, once I drag the swift files into my Objective-C based project, Run(debug) the app is fine. But if archive(release) and install it on iPhone, immediate crash at launch. Anything what I am missing?

like image 361
Wingzero Avatar asked Jun 16 '15 12:06

Wingzero


2 Answers

Alright, after thousands of archiving and testing, I found it's being caused by the in-house distribution.

It is mssing one attribute 'OU' in the certificate. I had to re-create a new cert, and now it has 'OU' there. Looks like Apple does not mention it at all when dealing with old projects adopting swift code.

Quote from Enterprise Distribution not playing nice with iOS8 in Swift App

All explained in details in this article :

https://www.airsignapp.com/ios-apps-using-swift-crash-when-signed-with-inhouse-certificate/

We can confirm that after create a new cert and .mobileprovision, no more issues.

We found origins that caused this issue, related to a missing attribute in “Subject” field InHouse Certificates :

BEFORE Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, O=Company Name, C=FR

AFTER Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, OU=269J2W3P2L, O=Company Name, C=FR
like image 112
Wingzero Avatar answered Nov 11 '22 09:11

Wingzero


I'll post this is an answer, because I don't have the rep to post comments. I've had similar problem, although not related to Swift. Could be worth checking out though.

For me the problem had to do with file deletion in Xcode. I had removed some files from the Xcode project, but they were still present in the folder on my hard drive. When running the project through Xcode it would load these files as if they were part of the project, but when archiving it would not include them. This made the app work perfectly when run through Xcode, but crash when running the archived version, as it tried to load something that didn't exist.

So, one thing to check is that the files that should be loaded when starting the app are visible in the project navigator in Xcode. Hope it can be of help!

like image 39
Anton Avatar answered Nov 11 '22 11:11

Anton