通知中心推送问题

问题描述:输入法终于转正了,原来通过越狱方式(CFMessagePort)弹通知中心,现在改为App Store版本。这今天试用Baidu Push,遇到如下问题:
2014-06-11 15:35:22.586 PushDemo[756:60b] error:Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用程序的“aps-environment”的权利字符串" UserInfo=0x15d74ea0 {NSLocalizedDescription=未找到应用程序的“aps-environment”的权利字符串}

问题分析:原因是设备上没有.mobileprovision文件有如下许可的字段:
aps-environment

问题解决:重新生成新的.mobileprovision并安装到设备上

__weak不能使用问题

问题描述:输入法加了一个新类库,报如下错误:

The current deployment target does not support automated __weak references

问题解决

ARC是从4.2以上版本开始支持的,但是不能使用__weak。

从5.0开始支持所有ARC。

在project->info->ios Deployment Target 将target版本改为5.0或者5.0以上。

copy file from iOS(like iFunBox)

昨天浏览器组的同事跑来问了一个没有细想过的问题:没有越狱过的机器怎么通过USB使用脚本批处理iOS设备上的数据。

没有越狱意味着习惯使用的SSH不能用了。
只有使用libimobiledevice了,如下:

1.安装libimobiledevice,ifuse,ifuse依赖与libimobiledevice,
可以选择airport或brew安装
sudo brew update
sudo brew install libimobiledevice
sudo brew install ifuse

2.拷贝osxfusefs.fs 到/Library/Filesystems,并添加执行权限
sudo /bin/cp -RfX /usr/local/Cellar/osxfuse/2.6.2/Library/Filesystems/osxfusefs.fs /Library/Filesystems
sudo chmod +s /Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs

3.终端输入ifuse -h,会打印出详细使用说明
挂载某个应用的沙盒到~/myapp:
app_bundleId=com.my.app
udid=xxxxxxxxxxxx
ifuse -u ${udid} --container ${app_bundleId} ~/myapp

4.关闭挂载:
umount ~/myapp

PS:itoos与iexploer等工具都是基于libimobiledevice库进行开发的,iOS 6.x的越狱也用到了此库,更为重要的是appium也依赖于它,如果大家有安装过appium环境那么可以查看下build/libimobiledevice-macosx/,有许多可执行的unix文件
idevice_id
idevicebackup
idevicebackup2
idevicedate
idevicedebugserverproxy
idevicediagnostics
ideviceenterrecovery
ideviceimagemounter
ideviceinfo
idevicepair
ideviceprovision
idevicescreenshot
idevicesyslog
可以直接使用这些命令行工具,例如:
idevice_id -l 可直接查看手机id
idevicediagnostics 可让iPhone进行重启,关机,睡眠等。

我们可以利用libimobiledevice与ifuse进行shell封装,辅助实现自动化的测试过程。

另附上git地址:
https://github.com/libimobiledevice/libimobiledevice‎
https://github.com/libimobiledevice/ifuse

AFJSONRequestOperation不支持”text/html”问题

问题描述:输入法用AFJSONRequestOperation获取服务器更新消息。发现AFNetworking示例可以使用,换了服务器访问地址就不行了。

问题分析:打印出错误消息,如下:

Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/json",
"application/json",
"text/javascript"
)}, got text/html"

看来是AFJSONRequestOperation只支持3种META,而服务器返回的是"text/html"。

问题解决:增加如下代码,让AFJSONRequestOperation支持"text/html"。

[AFJSONRequestOperationaddAcceptableContentTypes:[NSSetsetWithObjects:@"text/html", nil]];

UITableView的insert和delete操作与numberOfRowsInSection同步问题

问题描述:通过CrashRepoter得到如下报错信息:
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (0) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 3 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

问题解决:在[self.tableView insertRowsAtIndexPaths:withRowAnimation:]和[tableView deleteRowsAtIndexPaths:withRowAnimation:]进行修改的操作前后加保护:
[tableView beginUpdates]和[self.tableView endUpdates]

Xcode升级导致插件失效

问题描述:Xcode升级后有些插件失效

问题分析:在控制台中查看log,显示是白名单问题

问题解决:把Xcode的UUID加入插件plist中:
XCODEUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
defaults write ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/HOStringSense.xcplugin/Contents/Info DVTPlugInCompatibilityUUIDs -array-add $XCODEUUID

Mac App Store 下载更新错误

问题描述:使用Mac App Store更新Xcode时一直重复出现如下错误:

使用“已购”页面再试一次

问题解决

1、点击下载
2、在出现去已购项目重试的提示之前,打开launchpad,找到正在连接的app图标。
3、鼠标长按,图标左上角的叉叉出现,点击左上角的叉删除该图标。
4、再回到AppStore,重新下载即可。

换设备后ssh报错

问题描述:运行ssh报如下错误
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
23:00:20:83:de:02:95:f1:e3:34:be:57:3f:cf:2c:e7.
Please contact your system administrator.
Add correct host key in /home/xahria/.ssh/known_hosts to get rid of this message.
Offending key in /home/xahria/.ssh/known_hosts:8
RSA host key for localhost has changed and you have requested strict checking.
Host key verification failed.

问题分析:估计是RSA key不匹配

问题解决:修改安全配置
打开.ssh/config(或者/etc/ssh/ssh_config)
找到并修改为:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null

brew update报错

问题描述:运行brew update,报错
error: The following untracked working tree files would be overwritten by merge:
Library/Aliases/libtcnative
Library/Aliases/myrepos
Library/Contributions/example-formula.rb
Library/Formula/acme.rb
Library/Formula/activemq-cpp.rb
Library/Formula/ahcpd.rb
Library/Formula/analog.rb
Library/Formula/ansible.rb
Library/Formula/apple-gcc42.rb
Library/Formula/argus-clients.rb
Library/Formula/argus.rb
Library/Formula/babeld.rb
Library/Formula/bacula-fd.rb
Library/Formula/bgpq3.rb
Library/Formula/bitchx.rb
Library/Formula/brag.rb
Library/Formula/cdlabelgen.rb
Library/Formula/charm-tools.rb
Library/Formula/clipper.rb
Library/Formula/clojurescript.rb
Library/Formula/datomic.rb
Library/Formula/dieharder.rb
Library/Formula/dmalloc.rb
Library/Formula/dtrx.rb
Library/Formula/ejdb.rb
Library/Formula/electric-fence.rb
Library/Formula/etcd.rb
Library/Formula/etcdctl.rb
Library/Formula/fdclone.rb
Library/Formula/flowgrind.rb
Library/Formula/fswatch.rb
Library/Formula/gammu.rb
Library/Formula/gcab.rb
Library/Formula/git-cal.rb
Library/Formula/gtkspell3.rb
Library/Formula/hamsterdb.rb
Library/Formula/haxe.rb
Library/Formula/headphones.rb
Library/Formula/htmlcleaner.rb
Library/Formula/irrtoolset.rb
Library/Formula/juju.rb
Library/Formula/kimwitu++.rb
Library/Formula/kstart.rb
Library/Formula/laszip.rb
Library/Formula/libatomic_ops.rb
Library/Formula/libav.rb
Library/Formula/libcello.rb
Library/Formula/libcppa.rb
Library/Formula/libdrawtext.rb
Library/Formula/libftdi0.rb
Library/Formula/libgsm.rb
Library/Formula/libiscsi.rb
Library/Formula/liblacewing.rb
Library/Formula/libnatpmp.rb
Library/Formula/libqxt.rb
Library/Formula/libresample.rb
Library/Formula/lmdb.rb
Library/Formula/mbelib.rb
Library/Formula/mboxgrep.rb
Library/Formula/mecab-unidic.rb
Library/Formula/mergelog.rb
Library/Formula/midicsv.rb
Library/Formula/mitmproxy.rb
Library/Formula/mkvtomp4.rb
Library/Formula/mlt.rb
Library/Formula/mm-common.rb
Library/Formula/moc.rb
Library/Formula/mongo-c.rb
Library/Formula/monkeysphere.rb
Library/Formula/mp3blaster.rb
Library/Formula/msitools.rb
Library/Formula/msktutil.rb
Library/Formula/n.rb
Library/Formula/namebench.rb
Library/Formula/nanomsg.rb
Library/Formula/neko.rb
Library/Formula/ninja-ide.rb
Library/Formula/npth.rb
Library/Formula/ondir.rb
Library/Formula/ori.rb
Library/Formula/osxfuse.rb
Library/Formula/owamp.rb
Library/Formula/pgrouting.rb
Library/Formula/pjsip.rb
Library/Formula/pktanon.rb
Library/Formula/pmccabe.rb
Library/Formula/polygen.rb
Library/Formula/ponysay.rb
Library/Formula/proftpd.rb
Library/Formula/q.rb
Library/Formula/randomize-lines.rb
Library/Formula/rbenv-readline.rb
Library/Formula/re2.rb
Library/Formula/reaver.rb
Library/Formula/sbuild.rb
Library/Formula/sdl2.rb
Library/Formula/sdl2_image.rb
Library/Formula/sdl2_mixer.rb
Library/Formula/sdl2_net.rb
Library/Formula/sdl2_ttf.rb
Library/Formula/shellinabox.rb
Library/Formula/slimerjs.rb
Library/Formula/snzip.rb
Library/Formula/spim.rb
Library/Formula/sslh.rb
Library/Formula/stlviewer.rb
Library/Formula/strongswan.rb
Library/Formula/sysbench.rb
Library/Formula/tcpsplit.rb
Library/Formula/texapp.rb
Library/Formula/tinyxml.rb
Library/Formula/tlassemble.rb
Library/Formula/tmux-mem-cpu-load.rb
Library/Formula/tomcat-native.rb
Library/Formula/tpp.rb
Library/Formula/tractorgen.rb
Library/Formula/typesafe-activator.rb
Library/Formula/uberftp.rb
Library/Formula/v.rb
Library/Formula/viewglob.rb
Library/Formula/voltdb.rb
Library/Formula/vstr.rb
Library/Formula/watchman.rb
Library/Formula/wimlib.rb
Library/Formula/wy60.rb
Library/Formula/xcproj.rb
Library/Formula/xplot.rb
Library/Formula/z80asm.rb
Library/Formula/z80dasm.rb
Library/Formula/zpython.rb
Library/Homebrew/cxxstdlib.rb
Library/Homebrew/install_renamed.rb
Library/Homebrew/os.rb
Library/Homebrew/resource.rb
Library/Homebrew/software_spec.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

问题解决
cd `brew --repository`
git reset --hard HEAD
brew update
不行的话试试如下:
cd `brew --repository`
git reset --hard origin/master
brew update