Xcode变量看不了

问题描述:
堆栈上一层都正常,这一层监视通通挂了,任何变量看不了

(lldb) po self
error: :1:11: error: use of undeclared type ‘$__lldb_context’
extension $__lldb_context {
^~~~~~~~~~~~~~~

error: :18:5: error: use of unresolved identifier ‘$__lldb_injected_self’
$__lldb_injected_self.$__lldb_wrapped_expr_32(
^~~~~~~~~~~~~~~~~~~~~

(lldb) po viewController
error: :3:1: error: use of unresolved identifier ‘viewController’
viewController
^~~~~~~~~~~~~~

Xcode Version 8.2 (8C38)

iOS9 Beta5的Extension下调用CoreSpotlight失败

在iOS9 beta4的Extension下调用CoreSpotlight注册spotlight成功。

而iOS9 beta5的Extension下调用失败,报如下错误:
2015-08-12 14:33:22.705 com.baidu.ime.BaiduInputMethodContainer.BaiduInputMethod[1027:70935] _BSMachError: (os/kern) invalid capability (20)
2015-08-12 14:33:22.706 com.baidu.ime.BaiduInputMethodContainer.BaiduInputMethod[1027:70935] _BSMachError: (os/kern) invalid name (15)
2015-08-12 14:33:22.735 com.baidu.ime.BaiduInputMethodContainer.BaiduInputMethod[1027:71045] [com.apple.corespotlight.log.index] Finished “index items”(2) with error:Error Domain=CSIndexErrorDomain Code=-1003 “(null)”

错误为连接不到CoreSpotlight远程进程:
CSIndexErrorCodeRemoteConnectionError = -1003, //There was an error trying to communicate with the remote process

复制目录除了.svn

问题描述
本地编译通过,而Jenkins编译不过,日志如下:
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/all-wcprops: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/entries: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/about.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/dictionary.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/fuzzySound.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/general.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/handwrite.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/keyboard.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/keyboard_tick.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/mohu.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/Root.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/shuangpin.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/prop-base/UserProtocol.html.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/about.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/dictionary.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/fuzzySound.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/general.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/handwrite.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/keyboard.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/keyboard_tick.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/mohu.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/Root.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/shuangpin.plist.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/.svn/text-base/UserProtocol.html.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/en.lproj/.svn/all-wcprops: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/en.lproj/.svn/entries: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/en.lproj/.svn/prop-base/Root.strings.svn-base: Permission denied
cp: ../SettingsKit/SettingsKit/UserDefaults.bundle/en.lproj/.svn/text-base/Root.strings.svn-base: Permission denied

问题分析
报的错是当cp命令时.svn目录没有权限。
其实.svn目录不应该copy。

问题解决
把脚本中的命令:cp -r config/ temp/
改为:rsync -rv –exclude=.svn config/ temp/

iOS9跨应用链接需要设置白名单

问题描述:今天输入法适配iOS9,发现分享都不能用了

问题分析
因为是跨应用链接,怀疑和iOS9的新安全机制有关
Log报错:2015-07-09 16:49:31.546 BaiduInputMethodContainer[339:27725] -canOpenURL: failed for URL: “sinaweibo://” – error: “(null)”

问题解决
在info.plist中,加入:

<key>LSApplicationQueriesSchemes</key>
<array>
<string>sinaweibo</string>
</array>

 

 

iOS9 beta2在iPad横屏下UITableView位置不正确

问题描述:设置项适配iOS9的时候发现UITableView的所有在iPad横屏下两边着很大的空白,如下图
TableViewDemo

问题分析
1.用UI视图看了下。UITableViewCell撑满整个屏幕是正确的。UITableViewCell的ContentView也是正确的。TextLabel不正确,你只能通过强行给TextLabel一个约束来修正。
2.设置了所有有关间距的属性,代码如下:
cell.indentationLevel=0;
cell.indentationWidth=0;
cell.separatorInset=UIEdgeInsetsZero;
cell.layoutMargins=UIEdgeInsetsZero;
cell.contentView.preservesSuperviewLayoutMargins=NO;
cell.preservesSuperviewLayoutMargins=NO;

tableView.contentInset=UIEdgeInsetsZero;
tableView.scrollIndicatorInsets=UIEdgeInsetsZero;
tableView.separatorInset=UIEdgeInsetsZero;
tableView.layoutMargins=UIEdgeInsetsZero;

[cell setNeedsLayout];
[cell setNeedsDisplay];
[cell layoutIfNeeded];

[tableView setNeedsLayout];
[tableView setNeedsDisplay];
[tableView layoutIfNeeded];
3.以上代码无效后,单独做了一个Demo:只放一个UITableView进去,问题同样存在,如下
TableViewDemo

问题结论
估计是iOS9 beta2的bug

环境:iPad Air2,iOS9 beta2,Xcode7.0 beta (7A120f)

iOS9默认网络访问都是SSL

问题描述:今天输入法适配iOS9,发现所有网络都不能访问了

问题分析
1.做了一个Demo,发现可以访问网络,访问的是http://www.baidu.com
2.调试设置项,发现所有返回的错误为“Error Domain=NSURLErrorDomain Code=-1200 “发生了 SSL 错误,无法建立与该服务器的安全连接。””
3.把访问链接复制到浏览器中访问,发现有返回数据
4.仔细研究了一下错误发现所有的访问链接都变成了https://
5.在demo中证实所有iOS9会自动以SSL的方式访问所有网络链接

问题解决
在info.plist中,加入:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!–Include to allow subdomains–>
<key>NSIncludesSubdomains</key>
<true/>
<!–Include to allow HTTP requests–>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!–Include to specify minimum TLS version–>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>

或者你希望所有都打开TLS,可以这样写:

NSAppTransportSecurity

<!–Include to allow all connections (DANGER)–>
NSAllowsArbitraryLoads

 

PS:官方文档:https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

CGColorSpaceRelease多次调用引起的问题

问题描述:在多次运行图片Blur处理后,报如下错误:

Assertion failed: (!space->is_singleton), function color_space_dealloc, file ColorSpaces/color-space.c, line 100.

问题分析:Blur的代码如下:

– (UIImage *)blurryWithLevel:(CGFloat)level

{

if (level < 0.f || level > 1.f) {

level = 0.5f;

}

int boxSize = (int)(level * 100);

boxSize = boxSize – (boxSize % 2) + 1;

 

CGImageRef img = self.CGImage;

 

vImage_Buffer inBuffer, outBuffer;

vImage_Error error;

 

void *pixelBuffer;

 

CGDataProviderRef inProvider = CGImageGetDataProvider(img);

CFDataRef inBitmapData = CGDataProviderCopyData(inProvider);

 

inBuffer.width = CGImageGetWidth(img);

inBuffer.height = CGImageGetHeight(img);

inBuffer.rowBytes = CGImageGetBytesPerRow(img);

 

inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData);

 

pixelBuffer = malloc(CGImageGetBytesPerRow(img) *

CGImageGetHeight(img));

 

if(pixelBuffer == NULL)

NSLog(@”No pixelbuffer”);

 

outBuffer.data = pixelBuffer;

outBuffer.width = CGImageGetWidth(img);

outBuffer.height = CGImageGetHeight(img);

outBuffer.rowBytes = CGImageGetBytesPerRow(img);

 

error = vImageBoxConvolve_ARGB8888(&inBuffer,

&outBuffer,

NULL,

0,

0,

boxSize,

boxSize,

NULL,

kvImageEdgeExtend);

 

 

if (error) {

NSLog(@”error from convolution %ld”, error);

}

 

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

CGContextRef ctx = CGBitmapContextCreate(

outBuffer.data,

outBuffer.width,

outBuffer.height,

8,

outBuffer.rowBytes,

colorSpace,

(CGBitmapInfo)kCGImageAlphaNoneSkipLast);

CGImageRef imageRef = CGBitmapContextCreateImage (ctx);

UIImage *returnImage = [UIImage imageWithCGImage:imageRef];

 

CGContextRelease(ctx);

CGColorSpaceRelease(colorSpace);

 

free(pixelBuffer);

CFRelease(inBitmapData);

 

CGColorSpaceRelease(colorSpace);//此句多Release了
CGImageRelease(imageRef);

 

return returnImage;

}

问题解决:CGColorSpaceRelease多Release导致的。删除如上注释这句:CGColorSpaceRelease(colorSpace);

UIVisualEffectView不支持iPad2和iPhone4S以及以下机型

问题描述:在Extension中增加Blur浮层,显示的Blur效果为透明灰色。代码如下:

UIImage *image=[UIImage imageNamed:@”Grass.jpg”];
UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
imageView.image=image;
[self.view addSubview:imageView];

UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *bluredEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[bluredEffectView setFrame:[imageView bounds]];
[self.view addSubview:bluredEffectView];

问题解决:查了下资料,UIVisualEffectView对iPad2和iPhone4S以及以下机型不支持。用第三方的FXBlurView也是得到用默认tintColor填充的色块。模糊功能需要硬件加速,早期的设备不支持。

Framework的@rpath问题

问题描述:最新的Xcode6开放了动态库支持,可以使Container和Extension共享一个Framework。最新开发通讯MC模块,也来试试看。单独运行Container,但是运行Extension时,报如下错误:

dyld: Library not loaded: @rpath/BIIPC.framework/BIIPC
Referenced from: /private/var/mobile/Containers/Bundle/Application/1548B083-7E48-4497-A8E3-0E65842F2EF4/BIIPCDemo.app/PlugIns/BIIPCKeyboard.appex/BIIPCKeyboard
Reason: image not found

问题分析:看报错信息,应该是没有找到Framework,要么是没有拷入BIIPCKeyboard目录,要么是运行目录环境参数没有设置到位。首先把Extension的Target中手动导入Framework,编译报错,提示有2个一样签名(动态库是需要签名)的资源。应该就是@rpath没有设置对。

问题解决:在Extension-Target-Building Settings中把Run path Search Paths增加一个路径:@executable_path/../../Frameworks

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

问题描述:自定义主题拍照预览出现黑屏。一次正常一次黑屏一次正常一次黑屏,黑屏时重拍后能正常预览。预览黑屏时控制台输入Log如下:

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

问题分析:iPhone5S有问题,iPad2没问题。看了iPhone5S中系统的拍照也是有同样问题,判断为系统bug。

官方UIImagePickerController的例子,自己实现拍照按钮,在iPhone5S上正常。
https://developer.apple.com/LIBRARY/IOS/samplecode/PhotoPicker/Listings/PhotoPicker_APLViewController_m.html#//apple_ref/doc/uid/DTS40010196-PhotoPicker_APLViewController_m-DontLinkElementID_6

这是一个老外写的UIImagePickerController的例子,简单使用,在iPhone5S上黑屏。
https://github.com/bartvandeweerdt/CameraTest

看了黑屏时,View的层级,有一个黑色的CAMBlurredSnapshotView覆盖在上面。手动把其removeFromSuperView,预览只有一帧,并不会更新。

问题解决:此bug为系统bug。从iOS8.0到iOS8.1都有,苹果并没有修复。并不是每台都有这个问题,但是一旦有这个问题,就会一直存在,除非重装系统。

现在的解决办法只有参考官方例子自己实现拍照按钮。

 

PS:系统都为iOS8.1