I have just got rejected by Apple with the following reason:
We were unable to review your app, as it crashed on launch on the following device(s): - iPhone 5S running iOS 8.1- iPhone 6 running iOS 8.1- iPhone 6 Plus running iOS 8.1
Here is what I did:
I did test it with the devices in simulator ios 8.1,8.2. I also tested it with read devices: iphone 4 running ios 7.1, ipad running ios 8.3. There were no crash at all.
With the crash log that they sent, I use Symbolicator to generated the following symbolicated log:
Process: Meety [1125]
Path: /private/var/mobile/Containers/Bundle/Application/12CA9A59-184C-4B7E-9D2A-0B4703363AA2/Meety.app/Meety
Identifier: com.cungcode.Meety
Version: 1 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd.development [1]
Date/Time: 2015-05-16 05:34:46.952 -0700
Launch Time: 2015-05-16 05:34:46.165 -0700
OS Version: iOS 8.1 (12B411)
UDID: d1c1574d0e021ab0d30ce26e69978227c7080d3c
Report Version: 105
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010016bdf8
Triggered by Thread: 0
Filtered syslog:
2015-05-16 05:34:46.535 Meety[1125]: <Error> assertion failed: 12B411: libxpc.dylib + 71820 [AD580443-238D-3997-8D09-004C210D0C18]: 0x7d
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
__TFC5Meety20MainTabBarController24addCenterButtonWithImagefS0_FTCSo7UIImage14highlightImageGSqS1___T_ MainTabBarController.swift:227
__TFC5Meety20MainTabBarController11viewDidLoadfS0_FT_T_ MainTabBarController.swift:57
2 UIKit 0x000000018a72ce80 0x18a71c000 + 69248
3 UIKit 0x000000018a72cb90 0x18a71c000 + 68496
4 UIKit 0x000000018a733258 0x18a71c000 + 94808
5 UIKit 0x000000018a7309d8 0x18a71c000 + 84440
6 UIKit 0x000000018a7a1a00 0x18a71c000 + 547328
7 UIKit 0x000000018a9b5434 0x18a71c000 + 2724916
8 UIKit 0x000000018a9b79ac 0x18a71c000 + 2734508
9 UIKit 0x000000018a9b6044 0x18a71c000 + 2728004
10 FrontBoardServices 0x000000018e2c163c 0x18e2a8000 + 103996
11 CoreFoundation 0x0000000185f36120 0x185e58000 + 909600
12 CoreFoundation 0x0000000185f35228 0x185e58000 + 905768
13 CoreFoundation 0x0000000185f3384c 0x185e58000 + 899148
14 CoreFoundation 0x0000000185e611f0 0x185e58000 + 37360
15 UIKit 0x000000018a797788 0x18a71c000 + 505736
16 UIKit 0x000000018a792780 0x18a71c000 + 485248
_main AppDelegate.swift:16
18 libdyld.dylib 0x0000000196dc6a04 0x196dc4000 + 10756
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x0000000196ec4c94 0x196ec4000 + 3220
1 libdispatch.dylib 0x0000000196dac97c 0x196d9c000 + 67964
2 libdispatch.dylib 0x0000000196d9f3b0 0x196d9c000 + 13232
Thread 2:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 3:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 4:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 5:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 6:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 7:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 8:
0 libsystem_kernel.dylib 0x0000000196edfc78 0x196ec4000 + 113784
1 libsystem_pthread.dylib 0x0000000196f79390 0x196f78000 + 5008
2 libsystem_pthread.dylib 0x0000000196f78fa4 0x196f78000 + 4004
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000196f71958 x2: 0x000000015fd233e0 x3: 0x000000000000001e
x4: 0x0000000000000010 x5: 0x0000000000000001 x6: 0x0000000000000000 x7: 0x0000000000000000
x8: 0x0000000000000000 x9: 0x000000015fe0c850 x10: 0x0000000000000000 x11: 0x000000000000005e
x12: 0x0000000000000001 x13: 0x000000000017a17c x14: 0x0000000000000015 x15: 0x0000000000000000
x16: 0x0000000100a8217c x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x00000001740995a0
x20: 0x00000001700997d0 x21: 0x000000015fe0c850 x22: 0x0000000000000000 x23: 0x000000015fd233e0
x24: 0x0000000100ab30c8 x25: 0x0000000100856dd0 x26: 0x0000000100856dd0 x27: 0x000000019aa4a0a8
x28: 0x0000000000000001 fp: 0x000000016fd1e160 lr: 0x000000010016b8c0
sp: 0x000000016fd1e100 pc: 0x000000010016bdf8 cpsr: 0x80000000
So it appears to me that the bugs must be in the following code:
(In MainTabBarController)
@IBOutlet weak var mapButton: UIButton!
override func viewDidLoad()
{
super.viewDidLoad()
self.delegate = self
var middleImage:UIImage = UIImage(named:"MapButton")!
var highlightedMiddleImage:UIImage = UIImage(named:"MapButtonHighlighted")!
addCenterButtonWithImage(middleImage, highlightImage: highlightedMiddleImage) //Line 57 --> Correct!!
self.tabBar.barTintColor = UIColor.blackColor()
}
func addCenterButtonWithImage(buttonImage: UIImage, highlightImage:UIImage?)
{
mapButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton //UPDATE 1: LINE 206 --> CRASH HERE
mapButton.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin|UIViewAutoresizing.FlexibleTopMargin
mapButton.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
mapButton.setBackgroundImage(buttonImage, forState: UIControlState.Normal)
mapButton.setBackgroundImage(highlightImage, forState: UIControlState.Highlighted)
//Center the button on tabbar
var heightDifference:CGFloat = buttonImage.size.height - self.tabBar.frame.size.height;
if heightDifference < 0 {
mapButton.center = self.tabBar.center;
}
else
{
var center:CGPoint = self.tabBar.center;
center.y = center.y - heightDifference/2.0;
mapButton.center = center;
}
mapButton.addTarget(self, action: "changeSelectedTabToMapTabController:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(mapButton)
} //LINE 227: PROBABLY CRASH HERE, BUT I THINK IT CRASH ON LINE 206
The meaning of the above code is that, I want to create an Instagram-like tab bar. So I add a button in front of the 3 tab in a 5-item tab bar. In the simulator ios 8.1 it looks like below:
1) The code was simple and I cannot find out why it crash in ios 8.1. Right now I do not have a real device running ios 8.1 to test it so I'm asking if you could find abnormal things in the code.
2) Is it possible that the app crash because of something wrong with provisioning profile? But I think it is not my case because I archive with distribution profile, and install the ipa via iTunes and TestFlight to my ipad that it can run ok.
Sorry for very long question. Any help would be much appreciated!
UPDATE 1: I symbolicate by command line to confirm again about the crash, as described by Sea Coast of Tibet's answer in here. Then I got the crash must be in line 206 of the code:
mapButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
There must be something wrong with this kind of initiation. I don't use Storyboard for this button, but I create programmatically. My friend who uses XCode 6.3 (I'm using 6.2), when opening my project sees a lot of compile error relating to "as", "!" and "?". I think I'm going to update my XCode to 6.3 to see if I have compile error with "as" in line 206.
Finally I managed to get a real device for testing. It crashed at the following line:
mapButton.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin|UIViewAutoresizing.FlexibleTopMargin
Reason: mapButton is nil. It is so strange because this line is right above:
mapButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
So in face this initialiser do not initialise my button. So I might agree with Chandan005 about the compiler issue. I change the code to:
let frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height)
button = UIButton(frame: frame)
Now it works on iPhone 6, ios 8.1. I have submitted my app again, hopefully it will pass this time. I wrote about this bug here in my blog.