2015年1月26日 星期一

UIPopoverController not presenting in iPad iOS 8

測試部門終於把他們的 Device 升級到 iOS8 也測出了新的問題. 這次是在 iPad 版遇到, iPhone 沒問題.

之前實作密碼鎖功能(Passcode) 古早前, 由於資訊不發達, 隨手選了一個那時候還有人在維護的元件, 現在看起來應該選別的, 呵呵呵.

先來看看, 作者的 code:

下面的 code, 請看 "紅字部份" 即可.
============
- (void)bz_presentPopoverInWindow:(UIWindow *)window animated:(BOOL)animated {
    if ([[UIDevice currentDevice].systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedAscending) {
        // 4.3.x or earlier
        UIApplication *UIApp = [UIApplication sharedApplication];
        CGPoint point;
        if (UIInterfaceOrientationIsPortrait(UIApp.statusBarOrientation)) {
            point = window.center;
        } else {
            if ([[UIDevice currentDevice].systemVersion compare:@"4.2" options:NSNumericSearch] == NSOrderedAscending) {
                // 3.2.x
                point = CGPointMake(window.center.y, LANDSCAPE_CENTER_Y);
            } else {
                // 4.2 - 4.3.x
                point = CGPointMake(window.center.y, window.center.x);
            }
        }
        if (!UIApp.statusBarHidden) {
            point.y += (STATUS_BAR_HEIGHT / 2);
        }
        CGRect rect = CGRectMake(point.x, point.y, 0, 0);
        [self presentPopoverFromRect:rect inView:window permittedArrowDirections:0 animated:animated];
    } else {
        // 5.0 or later
        UIApplication *UIApp = [UIApplication sharedApplication];
        CGPoint point;
        point = window.center;
        switch (UIApp.statusBarOrientation) {
        case UIInterfaceOrientationPortrait:
            point.y += (STATUS_BAR_HEIGHT / 2);
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            point.y -= (STATUS_BAR_HEIGHT / 2);
            break;
        case UIInterfaceOrientationLandscapeLeft:
            point.x += (STATUS_BAR_HEIGHT / 2);
            break;
        case UIInterfaceOrientationLandscapeRight:
            point.x -= (STATUS_BAR_HEIGHT / 2);
            break;
        }
        // -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: the rect passed in to this method must have non-zero width and height. This will be an exception in a future release.
        CGRect rect = CGRectMake(point.x, point.y, 1, 1);
        [self presentPopoverFromRect:rect inView:window permittedArrowDirections:0 animated:animated];
    }
}

code 的問題在, 使用了 UIWindow 而不是 UIView, 真是多此一舉, 因為這個 sub 的 parent 就是傳入 self.view.window, 改成傳入 self.view 即可.

然後, 在 presentPopoverFromRect 換成下面的 code, 彈出的視窗就可以出來了.
if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0)
{
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [_pop presentPopoverFromRect:attachBtnFrame inView:_sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
});

}

Change the inView parameter in
[testPopoverController presentPopoverFromRect:rect inView:[UIApplication sharedApplication].keyWindow permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
to
[testPopoverController presentPopoverFromRect:rect inView:"your current View Controller's view" permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
And make sure it is in dispatch block
  dispatch_async(dispatch_get_main_queue(), ^{
});
Also kip changing your rect origin n size values if it is within the bounds


資料來源:


2015年1月12日 星期一

Error uploading ios application to itunesconnect “failed to open ssh session (16)”

就是 Port 沒開好造成.

The session's status is FAILED and the error description is 'failed to open ssh session. (16).'

Error message 1:
沒開 port 44001


Error message 2:
開完, port: 44001 & port 33001 還是有 Error 如下, 結論:
TCP: 443, 33001, 44001 要開.
UDP: 33001-33500 & 44001-44500 也要開.


After having the same issue I've been able to fix this issue.

To solve this issue you need to:

Go to page 6 "System and Network Requirements" from https://itunesconnect.apple.com/docs/UsingApplicationLoader.pdf

verify that all of the ports and IP addresses are accessible.

After opening all of the ports from the table, I'm now able to upload my apps.

Enjoy!

最後, 終於可以 submit app 上 apple store.


2015年1月9日 星期五

UIAltertController -> ActionSheet iPad on iOS8 Crash

由於我開發的device 是 iPhone, 所以沒有測到這個問題,測試人員回報說在 iPad 下會 crash, iPad error message:
Your application has presented a UIAlertController (<UIAlertController: 0x1588b2f0>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.


解法很簡單,加入下面紅字的這2行即可:
UIAlertController * view=   [UIAlertController
                             alertControllerWithTitle:@"My Title"
                             message:@"Select your Choice"
                             preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction* ok = [UIAlertAction
                     actionWithTitle:@"OK"
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         //Do some thing here
                         [view dismissViewControllerAnimated:YES completion:nil];

                     }];
UIAlertAction* cancel = [UIAlertAction
                         actionWithTitle:@"Cancel"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                             [view dismissViewControllerAnimated:YES completion:nil];

                         }];


[view addAction:ok];
[view addAction:cancel];

view.popoverPresentationController.sourceView = self.view;
view.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height / 2.0, 1.0, 1.0);
[self presentViewController: view animated:YES completion:nil];




資料來源:
http://stackoverflow.com/questions/27681887/how-to-fix-run-time-error-using-uialertcontroller

2014年12月25日 星期四

Tabbar disappears after segue to VLC view contorller in iOS8

滿神奇的, 我有一個 File List view push to Preview view, 再 push to VLC view contorller, 從 Apple store 裡下載的 app 版本, 在 iOS7 下 back (pop view controller) 是正常的, 在 iOS8 裡會造成我的 tab bar 消失.

比較神奇的是, 在 dismiss vlc view 後, 連其他的 view 都會被影響到, 而且很怪的是, 其他的 view 都會先顯示2秒的 tab bar 後, 再把自己 hide 起來, 而且 "找不到" 是那一行 xcode 裡的 code 去 hide, code 在執行時 tab bar 都是 show 的狀態.


在試了一大堆的偏方後, 最後是用 unwinding segue 來解決.
http://ios-imaxlive.blogspot.tw/2013/07/unwinding-segues-in-storyboard.html

查到的偏方:

2014年12月23日 星期二

[VLC] celt_pitch_xcorr_neon - Undefined symbols for architecture armv7

我的工作是寫 iOS App, 每天就是在研究怎麼實作APP的新功能,還有幫App debug (除錯), 我的同事們戰鬥力比較強.

最近在 buid vlc for ios:
https://wiki.videolan.org/IOSCompile


build vlc for iOS 遇到 error message:

Undefined symbols for architecture armv7:
  "_celt_pitch_xcorr_neon", referenced from:
      __celt_autocorr in MobileVLCKit(celt_lpc.o)
      _pitch_search in MobileVLCKit(pitch.o)
ld: symbol(s) not found for architecture armv7

clang: error: linker command failed with exit code 1 (use -v to see invocation)



trace vlc source code:
ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ contrib ▸ iPhoneOS-armv7 ▸ opus ▸ celt ▸ pitch.c:

#if defined(OPUS_ARM_ASM) && defined(FIXED_POINT)
# include "arm/pitch_arm.h"
#endif

一開始以為需要 define OPUS_ARM_ASM 還有 FIXED_POINT,
所以需要手動修改,file path:

  • ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ contrib ▸ iPhoneOS-armv7s ▸ opus ▸ config.h
  • ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ contrib ▸ iPhoneOS-armv7s ▸ opus ▸ config.h
  • ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ contrib ▸ iPhoneOS-aarch64 ▸ opus ▸ config.h


設定2個 flag 都為 1:
replace /**/ as 1


#define OPUS_ARM_ASM 1
#define FIXED_POINT 1

發現這個 config.h 似乎是自動產生的,所以改了內容沒什麼用,因為下次build 就又被還原了。


上次2014年9月份 build 時沒有這麼麻煩,要讀一下別人的 code, 追一下流程,改一下別人的code 才能開始 build, 這種感覺真差...,  這就是 Open Source 生態系統的缺點,有人關注的項目就會持續改進,但功能愈加愈多,系統愈來愈大時,在大大的金字塔中間插入某個項目進去,難保所異動項目的上層物件,不會受到影響。

理論上,上面的解法應該要可以在 xcode 裡 build 過,但還是又失敗,決定直接拿掉對 Opus codec  的支援看看:

  • ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ build-ios-OS ▸ arm64 ▸ config.h
  • ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ build-ios-OS ▸ armv7 ▸ config.h
  • ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ build-ios-OS ▸ armv7s ▸ config.h


修改 config.h, --enable-opus 修改為 --disable-opus
改完後發現 source code is different, "OPUS_ARM_ASM" is disappear. "contrib" maybe is automatic generated.

要注意的是,需要多下 -n 給 shell script 不然,會重新到 git 下載官方的版本。


在終於 build vlc framework 過,在 xcode 裡也 build 過後,接著動手修改 https 會彈對話框的問題, file path:
ios ▸ ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ modules ▸ misc ▸ securetransport.c

接下來,還是 build 不過去,挑戰 build  舊的版本,
遇到新問題,舊版的 modplug 用的是 0.8.8.4 版,可以在 sourceforge 下載,
http://sourceforge.net/projects/modplug-xmms/files/libmodplug/

用上面的下載會缺檔案,要改用 shapshot 方式:
http://sourceforge.net/p/modplug-xmms/git/ci/master/tree/libmodplug/


如果要改用新版本的 tar 檔,請修改
$(VLCROOT)/ImportedSources/VLCKit/MobileVLCKit/ImportedSources/vlc/contrib/src/modplug/rules.mak

改用新版的設定值,但改了會造成 git pull 時出錯,會發現版本不符,需要手動註解掉 buildMobileVLCkit.sh 裡的設定值。

解法1:用指令:shasum -a 512 MobileVLCKit/ImportedSources/vlc/contrib/tarballs/modplug-xmms-git-bc8cb8248788c05b77da7d653f4c677354339a21.zip 來取得 check sum 值,再放入 SHA512SUMS 檔案中。

解法2: 刪掉 SHA512SUMS 檔案,在 modplug/rules.mak 修改為:
.sum-modplug: modplug-xmms-git-$(MODPLUG_GIT_HASH).zip
$(warning Not implemented.)
touch $@
說明:第2行和第3行前面的空白,請改用 tab 來取代。

然後遇到 buldMobileVLCKit.sh -s , simulator 裡的 freetype 過不去,不知道為什麼,無解。 改build for device, 可以過 freetype, 但新的 error message:
libavcodec/arm/vp8dsp_armv6.S:2182:11: error: branch target out of range
        b vp8_put_epel_h6_armv6 + 4

針對這個錯誤,官方的回應是:
Wipe your ffmpeg tarball and any ffmpeg folder within MobileVLCKit/ImportedSources/vlc and recompile.

They fixed the issue in the meantime :)

from url:
https://forum.videolan.org/viewtopic.php?f=36&t=118040


試了官方的解法,一樣不行,但很清楚是 ffmpeg 造成,把 ffmpeg 改用最新版本,新的 error message:
unsupported; figure out the mach-o section name and add it at /Users/chunyuyao/Documents/iOS/vlc/VLCKit-2.2.0-pre3/MobileVLCKit/ImportedSources/vlc/extras/tools/build/bin/gas-preprocessor.pl line 140, <ASMFILE> line 56.
make[1]: *** [libavcodec/arm/aacpsdsp_neon.o] Error 22
make: *** [.ffmpeg] Error 2

把 /ffmpeg/rules.mak 修改回舊的版本,再註解掉 armv6  的那一段:
ifdef HAVE_ARMV6
#FFMPEGCONF += --cpu=armv6 --disable-neon
endif

測試結果: 無效,一樣編不過。

連到  http://git.libav.org/?p=libav.git 裡,試了幾個 commit 的版本,在 vlc 裡,版本太舊的,會產生出更多新bug, 新版的 VLC 裡的 rules.mak 直接使用 head 版本,造成 Opus 相關的 code 在 Mac + xcode 裡 build會出錯。head 版本寫法:
FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(HASH);sf=tgz


我試了幾個版本,改用 v10.3 是可以build 過的。
#HASH=6d93307f8df81808f0dcdbc064b848054a6e83b3
HASH= 07015d9f913d63bdc4495e75f4603c586553796e
FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(HASH);sf=tgz


新的 error message:
error: invalid argument '-mmacosx-version-min=10.5' not allowed with '-miphoneos-version-min=5.1'

解法: 修改 ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ extras ▸ package ▸ ios ▸ build.sh  
拿掉 -mmacosx-version-min= 或 -miphoneos-version-min=

修改:
▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ contrib ▸ src ▸ main.mak
拿掉 -mmacosx-version-min= 或 -miphoneos-version-min=

發現,都沒有改到,字串還是會跑出來,所以直接在 finder 裡 search, 把找到的都 replace 掉。

要注意的是 /vlc/configure.ac 這個檔案裡的 mmaxosx-version-min 的這一個 block 不用修改:
    if test "${with_macosx_version_min}" != "" ; then
        CPP="${CPP} -mmacosx-version-min=${with_macosx_version_min}"
        CC="${CC} -mmacosx-version-min=${with_macosx_version_min}"
        CXX="${CXX} -mmacosx-version-min=${with_macosx_version_min}"
        OBJC="${OBJC} -mmacosx-version-min=${with_macosx_version_min}"
        LD="${LD} -mmacosx_version_min=${with_macosx_version_min}"



new error:
clang: error: unknown argument: '-fforce-addr'
make[2]: *** [apiwrapper.lo] Error 1
make[1]: *** [install-recursive] Error 1
make: *** [.theora] Error 2



還是無解,回來重新研究 vlc:
https://wiki.videolan.org/VLCKit/

不想要幫別人debug, 所以我想直接用 2.1-stable 來試。

一開始 build, 還是有缺一堆檔案,有些可以在這裡下載到:
http://www.slackware.com/~alien/slackbuilds/vlc/build/

但最後還是跑出新 error:
archive member: .libs/libass.a(blend_bitmaps.o) cputype (16777223) does not match previous archive members cputype (12) (all members must match)

重新 git clone 一次,不切換到 2.1-stable 版,首先缺的是:
libdvbpsi-1.2.0.tar.bz2

than is:
libgsm_1.0.13.tar.gz

next is:
live.2014.07.25.tar.gz

只缺了3個,補完後看到的 error message是
x harfbuzz-0.9.17/configure.ac
x harfbuzz-0.9.17/compile
x harfbuzz-0.9.17/Makefile.in
for dir in /Users/chunyuyao/git/VLCKit-new/VLCKit/MobileVLCKit/ImportedSources/vlc/extras/tools/build/share/automake-1.14       ; do if test -f "${dir}/config.sub" -a -f "${dir}/config.guess"; then cp "${dir}/config.sub" "${dir}/config.guess" harfbuzz-0.9.17; break; fi; done
(cd harfbuzz-0.9.17 && patch -fp1) < ../../contrib/src/harfbuzz/harfbuzz-aarch64.patch
patching file src/hb-atomic-private.hh
(cd harfbuzz-0.9.17 && patch -fp1) < ../../contrib/src/harfbuzz/harfbuzz-clang.patch
patching file configure.ac
(cd harfbuzz-0.9.17 && patch -fp1) < ../../contrib/src/harfbuzz/disable-backends.patch
patching file configure.ac
Hunk #1 succeeded at 113 (offset -4 lines).
Hunk #2 FAILED at 204.
Hunk #3 FAILED at 216.
2 out of 3 hunks FAILED -- saving rejects to file configure.ac.rej
make: *** [harfbuzz] Error 1

這個問題,透過 buildMobileVLCKit。的參數 -n 就可以 build  成功,但相對的,進 xcode 後,還是會出錯,xcode 說:
Undefined symbols for architecture arm64:
  "_av_vorbis_parse_free", referenced from:
      _vorbis_cleanup in MobileVLCKit(oggparsevorbis.o)
  "_av_vorbis_parse_reset", referenced from:

      _vorbis_packet in MobileVLCKit(oggparsevorbis.o)
...
...
有70多個錯。

someone said, set "Build For Active Architectures" to YES:


after set the "Build Active Architechture Only" to Yes, the error count still is 70:



git checkout 2014-10-03 commit version, and out 3 lost tar file into the folder, 現在我 build 的超順手的,VLCKit  的 2.1, 2.2-pre3, 2.2 head version, 和 2.2 裡的某個 version 都 build 過了,但不是所有的framework 都 build 的起來。below shows the 2014-10-03 this version is easy to build successfully.


someone said:
The problem you have is that you haven't built libx264 and libvpx for device (armv7, armv7s, arm64 architectures). Unfortunately I can't tell what is wrong with it since build rules are created automatically depending on your setup. It may be caused by recompiling in the same directory though.
If you have repeatedly run the script in your old location, I would try to pull repo in new directory and try to build there, in order to have a clean build.



再從更前頭的開始研究:
https://wiki.videolan.org/IOSCompile
git clone git://git.videolan.org/vlc-ports/ios.git

手動切換到,我很多很多很多個月前 build 成功的版本:
git checkout 8a07a0f2c31fb15dd9e4956ea1e3a5940a7b05dd

HEAD is now at 8a07a0f... allow sharing audio tracks and show episodes in addition to regular files (close #13170)

就在一直 build, 一直 checkout 的過程中,我發現 git 好神奇,切換 commit 的版本時,可以在 local 直接切換,而且 file items 會自動立刻切換到指定的版本!

我開了另一個 terminal, 同時 check out 另一個commit.
滿巧的,這2個版本缺檔案居然一樣,都是這3個:



這個 8a07a0f2c31fb15dd9e4956ea1e3a5940a7b05dd 版本遇到的第1個error message:
/ios/ImportedSources/VLCKit/MobileVLCKit/ImportedSources/vlc/extras/tools/build/share/automake-1.14/am/ltlibrary.am: warning: 'libfribidi.la': linking libtool libraries using a non-POSIX
/Users/chunyuyao/git/ios-6/ios/ImportedSources/VLCKit/MobileVLCKit/ImportedSources/vlc/extras/tools/build/share/automake-1.14/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
lib/Makefile.am:3:   while processing Libtool library 'libfribidi.la'
test/Makefile.am:30: warning: '%'-style pattern rules are a GNU make extension
autoreconf: automake failed with exit status: 1
make: *** [.fribidi] Error 1


git checkout 0506152a9dd2705478808decfc7218558a9313ac
的這一個版本,遇到的 error message:
[VLC] Undefined symbols for architecture arm64: "_OBJC_CLASS_$_NSFetchRequest"

解法:
Add CoreData.framework to your target.

詳細圖文:
http://ios-imaxlive.blogspot.tw/2014/12/vlc-undefined-symbols-for-architecture.html

真的很神奇,之前在 xcode5 + OS X 10.9 環境下,才花1~2天就build 成功了,在現在的 xcode 6 + OS X 10.10 下,花了4天才弄成功,接下來要修改 vlc 關於 https 對話框的議題(不是bug).
http://ios-imaxlive.blogspot.tw/2014/09/ios-vlc-https-live-streaming-tls-client.html


這張圖,顯示2個commit 相近的版本,他們缺的實體檔案的版本還一樣,一個build 的過,一個連 framework 都 build 不過:




結論:可以 build vlc 的環境,一但成功了就很難得,千萬別挑戰去升級 vlc 元件!目前我在 iOS 8.1 SDK + Mac OS X 10.10.2 下, 用 git checkout 0506152a9dd2705478808decfc7218558a9313ac 是可以 build framework的過, 而且 xcopy 可以 buld app 的過.

[VLC] Undefined symbols for architecture arm64: "_OBJC_CLASS_$_NSFetchRequest"

我的工作,是在 iOS App, 每天就是在研究怎麼實作APP的新功能,還有幫App debug (除錯), 我的同事們戰鬧力比較強.

這個error 滿神奇的,我之前用 xcode5 + OSX 10.9 去 build 出來的vlc framework 是可以使用的,但用 xcode6 + OSX 10.10 build 出來的 vlc framework 會出錯。



解法:
Add CoreData.framework to your target.

Choose your target, select Build Phases and add CoreData.framework in Link Binary With Libraries.


2014年12月19日 星期五

Build VLC with many 404 file not found

今天下載了 vls for iOS, 隨手  build 了一下,一直被中斷,因為 vlc server  上的檔案搬家了:


用網頁去連,顯示 404 File not found.

在google 了一堆檔案後,把tar 檔放進目錄裡:
ImportedSources ▸ VLCKit ▸ MobileVLCKit ▸ ImportedSources ▸ vlc ▸ contrib ▸ tarballs


重新 build, 又有新的 error message.

ragel 問題的解法:
http://ios-imaxlive.blogspot.tw/2014/12/how-to-install-ragel-on-mac.html



從官方取得新版的code, 並解決 lost file, 再安裝完 ragel 在 14:45, 開始重  build ,build 了


檔案:Screen Shot 2014-12-19 at 3.50.42 PM
說明:已build 1小時又5分鐘,還沒 build 完。



檔案:Screen Shot 2014-12-19 at 3.52.05 PM
說明:歐耶,build 了1小時又7分鐘. 感動,新版 VLC build 出來了。



Facebook 留言