iOS App 开发问题汇总(三)

1.Checking the Entitlements for an iOS app Submission to the App Store

Making an Inspectable .ipa file
In the Xcode Organizer, instead of Submit to the iOS App Store, do Save for Enterprise or Ad-Hoc Deployment. This will create a local copy of the .ipa file that would be submitted to the App Store.
When asked to choose the provisioning profile to sign with, select the same distribution profile you use when submitting to the App Store. Take a screenshot of your choice (command-shift-3) so you can verify this step later. During submission, this screenshot will be the only record you have identifying which profile was used to sign the app.
When asked to save the package, uncheck Save for Enterprise Distribution, then save the .ipa file.
Checking the Entitlements of an .ipa file
Find the .ipa file and change its the extension to .zip.
Expand the .zip file. This will produce a Payload folder containing your .app bundle.
Use the codesign tool to check the entitlements on the .app bundle like this: $ codesign -d –entitlements :- “Payload/YourApp.app” where YourApp.app is the actual name of your .app bundle.
Use the security tool to check the entitlements of the app’s embedded provisioning profile: // should add cms, Apple may be a typo $ security cms -D -i “Payload/YourApp.app/embedded.mobileprovision”

where YourApp.app is the actual name of your .app bundle.

2.

1
`<PBXGroup path=`Vendors` UUID=`4931326E1B4A0EBF00741B49`>` attempted to initialize an object with an unknown UUID. `4920B77E1B58900100C9789C` for attribute: `children`. This can be the result of a merge and  the unknown UUID is being discarded.

解决办法: 1. I opened the .pbxproj file in a text editor.
a. Go to your .xcodeproj
b. Right click -> Show package contents
c. Open .pbxproj with a text editor.
2. I searched for the UUID.
3. Turns out that is a static library folder already removed from reference.
4. I readd folder that contain the static library.
5. Rerun pod installation.
6. Issue not happening anymore! :D

Reference:Pod install result in initialize an object with an unknown UUID

3.How do I return to an older version of our code in Subversion?

解决办法:

1
2
3
svn update
svn merge -r 150:140 .
svn commit -m "Rolled back to r140"

Reference:How do I return to an older version of our code in Subversion?

4. Add top layout guide in NIB file

解决办法:

1
2
3
4
-(void)viewDidLoad {
      if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
         self.edgesForExtendedLayout = UIRectEdgeNone;
}

Reference:Status bar and navigation bar appear over my view’s bounds in iOS 7

5. How do I set the height of tableHeaderView (UITableView) with autolayout?

Reference:How do I set the height of tableHeaderView (UITableView) with autolayout?

6. How to resize superview to fit all subviews with autolayout?

Reference:How to resize superview to fit all subviews with autolayout?

7.How to use c++ and objective-c together in XCode 4.2

1
2
1. Rename any .m file to .mm file;
2. If you look at the "Build Settings" there is a place written "Compile Sources As". There is a dropdown menu there where you can select Objective-C++. In the clang/gcc commandline I think it is "-x objective-c++".

Reference:How to use c++ and objective-c together in XCode 4.2

8.How do I change the status bar content to white?

A:In iOS 7 and later, status bar behavior is determined by view controllers. We can set the disired style via overriding property preferredStatusBarStyle.

1
2
3
override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

Apple note childViewControllerForStatusBarStyle method can override the preferred status bar style for a view controller, so when a view controller is a child of UINavigationController thing changed, we have to adjust UINavigationController’s default childViewControllerForStatusBarStyle implement as follow:

1
2
3
4
5
6
7
8
9
extension UINavigationController {
    override open var preferredStatusBarStyle: UIStatusBarStyle {
        if let lastVC = self.viewControllers.last {
            return lastVC.preferredStatusBarStyle
        }

        return .default
    }
}

Reference:UIStatusBarStyle not working in Swift

9.Expression

1
2
3
4
5
(lldb) expr NSString *$str = (NSString *)[[NSString alloc] initWithData:data encoding:4]
(lldb) po $str

(lldb) e NSArray *$array = @[ @"Saturday", @"Sunday", @"Monday" ]
(lldb) p [$array count]

10.fastlane add Slack Notifications

Create an Incoming WebHook and export this as SLACK_URL. Can send a message to #channel (by default), a direct message to @username or a message to a private group group with success (green) or failure (red) status.

Slack > Menu > API > Incoming Webhooks > Set up an incoming webhook integration in your Slack team to try it out.

11.

1
directory not found for option '-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/Developer/Library/Frameworks' "

Solution:Further to a migration of my Xcode project, from Xcode 6.4 to Xcode 7, I get the warning message below (after compilation) for the Test target :

directory not found for option ‘-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks’ Actually I found something when comparing a new project vs an older one…

In the old project, the warning was only being produced by the test target of my projects. Under ‘Search Paths’, I found it was including two items under ‘Framework Search Paths’:

$(SDKROOT)/Developer/Library/Frameworks $(inherited) The new project kept the ‘Framework Search Paths’ empty.

Deleting those entries in my older project then removed the warning.

Reference:Xcode 7 Library search path warning

12.

1
ld: '/Users/dongmeiliang/Documents/ZHYJApp/ZHYJApp/ZHYJApp/Vendors/baiduMap/Release-iphoneos/BaiduMapAPI.framework/BaiduMapAPI(BMAddrList.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

Solution:disable bitcode for this target. App target > Build Settings > Enable Bitcode > NO

Reference:New warnings in iOS 9

13.

1
2
*** Assertion failure in +[AAPLListUtilities sharedApplicationGroupContainer], /Users/dongmeiliang/Downloads/ListerforwatchOSiOSandOSX/Objective-C/ListerKit/AAPLListUtilities.m:33
2015-09-22 15:31:20.966 Lister[84089:1396115] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The shared application group container is unavailable. Check your entitlements and provisioning profiles for this target. Details on proper setup can be found in the PDFs referenced from the README.'

Solution:Target > Lister > iCloud > Fix issue Target > App Group > Fix issue

Reference:New Lister app error “The shared application group container is unavailable. Check your entitlements and provisioning profiles for this target…”

14.How can I conditionally include a file based on build configuration in Xcode?

For each target for which you want to conditionally include the settings bundle, choose its Project from the source list, choose the target, and switch to the “Build Phases” tab.

Click the “Add Build Phase” button and choose “Add Run Script”.

Then enter the following for the script:

1
2
3
if [ "${CONFIGURATION}" == "Debug" ]; then
    cp -r "${PROJECT_DIR}/Settings.bundle" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"
fi

Reference:How can I conditionally include a file based on build configuration in Xcode?

15.Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

Solution: 1. Go to Issue Navigator (CMD+8) and Select latest built with the warning
2. Locate the warning(s) (search for “Automatic Preferred Max Layout”) and press expand button on the right
3. Find the Object ID of the UILabel
4. Open the Storyboard and SEARCH (CMD+f) for the object. It will SELECT AND HIGHLIGHT the UILabel
5. Explictit set preferred layout width

Reference:Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0