Xcode在Simulator完全加载并构建成功后崩溃我的笔记本电脑的媒体(spotify等)

时间:2016-03-05 05:48:28

标签: ios xcode macos

如何解决此错误?这很烦人。 正在处理和构建的项目只是一个带有1个ViewController文件的简单应用程序,使用AVPlayerLayer将2个本地视频加载到一个简单的应用程序上并将其添加到UIView。

笔记本电脑规格:

Macbook Pro 15英寸Retina Mid-2014

OSX El Capitan,10.11.3

2.5 GHz i7

16GB DDR3内存

NVIDIA GT 750m

更新

经过进一步调查后,我正在运行的特定程序导致问题。这是项目中目前的代码,有没有人有想法?

import UIKit
import AVKit
import AVFoundation
import CoreGraphics

class ViewController: UIViewController, UIScrollViewDelegate, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate {
    /****************************************
                 Initializers
    ****************************************/

    let screenSize = UIScreen.mainScreen().bounds
    var screenWidth: CGFloat { get{ return screenSize.width } }
    var screenHeight: CGFloat { get{ return screenSize.height } }
    var defaultCGRect: CGRect{ get{ return CGRectMake(0, 0, screenSize.width, screenSize.height) } }

    let profileView = UIView()
    let tableView = UITableView()
    let worldView = UIView()
    let scrollView = UIScrollView()

    /** Table setup **/
    let cellIdentifier = "cell"
    var tableData = [String]()

    /** Scroll setup **/
    var frame: CGRect = CGRectMake(0, 0, 0, 0)
    var pageControl : UIPageControl = UIPageControl(frame: CGRectMake(50, 300, 200, 50))


    /* size of color array determines page count, the lines commented with /!\ are where the number needs to be placed
    to correctly work */
    var colors:[UIColor] = [UIColor.redColor(), UIColor.blueColor(), UIColor.greenColor()]//, UIColor.yellowColor()]

    /****************************************
    ****************************************/

    override func viewDidLoad() {
        super.viewDidLoad()

        /****************************************
               Update Relevant Initializers
        ****************************************/

        profileView.frame = defaultCGRect
        worldView.frame = defaultCGRect

        tableView.frame = defaultCGRect
        for index in 1...12 {
            self.tableData.append("Lesson \(index)")
        }
        self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: self.cellIdentifier)
        tableView.scrollEnabled = false
        tableView.separatorStyle = UITableViewCellSeparatorStyle.None
        tableView.delegate = self
        tableView.dataSource = self

        scrollView.frame = defaultCGRect
        scrollView.delegate = self
        self.view.addSubview(scrollView)

        /***** Resources ****/


        /****************************************
        ****************************************/

        for index in 0..<colors.count {///!\

            frame.origin.x = self.scrollView.frame.size.width * CGFloat(index)
            frame.size = self.scrollView.frame.size
            self.scrollView.pagingEnabled = true

            var subView = UIView(frame: frame)
            if index == 0{
                let parentLayer = CALayer()
                let playerLayer:AVPlayerLayer = getVideoLayer("understand", frame: screenSize)
                let logoLayer = getImageLayer("logo_v5.1.png", center: true, opacity: 0.6)

                parentLayer.addSublayer(playerLayer)
                parentLayer.addSublayer(logoLayer)

                profileView.frame = frame

                profileView.layer.addSublayer(parentLayer)
                subView = profileView
            }else if index == 1{
                var tableFrame = frame
                tableFrame.origin.y = frame.origin.y + 24//change 24 to auto later
                tableView.frame = tableFrame
                subView = tableView
            }else{
                let parentLayer = CALayer()
                let playerLayer:AVPlayerLayer = getVideoLayer("home", frame: screenSize)
                let logoLayer = getImageLayer("logo_v5.1.png", center: true, opacity: 0.6)

                parentLayer.addSublayer(playerLayer)
                parentLayer.addSublayer(logoLayer)

                worldView.frame = frame

                worldView.layer.addSublayer(parentLayer)
                subView = worldView
            }

            self.scrollView.addSubview(subView)
        }

        self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 3, self.scrollView.frame.size.height)///!\
        pageControl.addTarget(self, action: Selector("changePage:"), forControlEvents: UIControlEvents.ValueChanged)
    }

    // MARK : TO CHANGE WHILE CLICKING ON PAGE CONTROL
    func changePage(sender: AnyObject) -> () {
        let x = CGFloat(pageControl.currentPage) * scrollView.frame.size.width
        scrollView.setContentOffset(CGPointMake(x, 0), animated: true)
    }


    func scrollViewDidEndDecelerating(scrollView: UIScrollView) {

        let pageNumber = round(scrollView.contentOffset.x / scrollView.frame.size.width)
        pageControl.currentPage = Int(pageNumber)
    }


    // UITableViewDataSource methods

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tableData.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier) as UITableViewCell!

        cell.textLabel?.text = self.tableData[indexPath.row]

        return cell
    }

    // UITableViewDelegate methods
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return calculateHeight()
    }

    func calculateHeight() -> CGFloat {
        if UIDevice.currentDevice().userInterfaceIdiom == .Pad
        {
            return CGFloat(100) // iPad
        } else {
            return CGFloat(53) // iPhone
        }
    }

    func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {

        let alert = UIAlertController(title: "Item selected", message: "You selected item \(indexPath.row)", preferredStyle: UIAlertControllerStyle.Alert)

        alert.addAction(UIAlertAction(title: "OK",
            style: UIAlertActionStyle.Default,
            handler: {
                (alert: UIAlertAction!) in print("An alert of type \(alert.style.hashValue) was tapped!")
        }))

        self.presentViewController(alert, animated: true, completion: nil)
    }

    func getImageLayer(image: String, center: Bool, opacity: Float = 1.0) -> CALayer{
        let imageLayer = CALayer()
        var image: UIImage = UIImage(named:image)!
        imageLayer.contents = image.CGImage

        if center{
            var imageWidth: CGFloat { get{ return CGFloat(screenWidth-50) } }
            var imageHeight: CGFloat { get{ return CGFloat((screenHeight/2)-80) } }
            var centerX: CGFloat { get{ return CGFloat(screenWidth/2)-(imageWidth/2) } }
            var centerY: CGFloat { get{ return CGFloat(screenHeight/2)-((imageHeight/1.65)) } }
            imageLayer.frame = CGRectMake(centerX, centerY, imageWidth, imageHeight)
        }

        imageLayer.opacity = opacity

        return imageLayer
    }

    func getVideoLayer(videoName: String, frame: CGRect) -> AVPlayerLayer{
        let videoURL: NSURL = NSBundle.mainBundle().URLForResource(videoName, withExtension: "mp4")!
        let player = AVPlayer(URL: videoURL)
        let playerLayer = AVPlayerLayer(player: player)
        playerLayer.frame = frame
        playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
        player.play()

        return playerLayer
    }
}

Xcode中的调试器窗口显示构建占用了100mb的内存,但没有网络使用的迹象......

更新2:

以下是控制台窗口中引用模拟器的日志。似乎列出了多个错误,但有人可以帮助我理解它们的含义。

Mar  4 23:02:32 Clarkes-MacBook-Pro nanoregistrylaunchd[3088]: Failed to enable path: code = 113: Could not find specified service, /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/NanoLaunchDaemons/com.apple.NPKCompanionAgent.plist
Mar  4 23:02:32 Clarkes-MacBook-Pro nanoregistrylaunchd[3088]: Failed to enable path: code = 113: Could not find specified service, /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/NanoLaunchDaemons/com.apple.pairedunlockd-phone.plist
Mar  4 23:02:32 Clarkes-MacBook-Pro calaccessd[3078]: table drop: 101
Mar  4 23:02:39 Clarkes-MacBook-Pro SpringBoard[3036]: Weekly asset update check did fire (force=NO)
Mar  4 23:02:39 Clarkes-MacBook-Pro SpringBoard[3036]: Beginning check for asset updates (force: 0
Mar  4 23:02:39 Clarkes-MacBook-Pro SpringBoard[3036]: Did not complete check for asset updates (force: 0, isVoiceOverRunning: 0
Mar  4 23:03:01 Clarkes-MacBook-Pro lsd[3056]: LaunchServices: Currently 0 installed placeholders: (
    )
Mar  4 23:03:07 Clarkes-MacBook-Pro assertiond[3040]: assertion failed: 15D21 13C75: assertiond + 12188 [8CF1968D-3466-38B7-B225-3F6F5B64C552]: 0x1
Mar  4 23:03:09 --- last message repeated 1 time ---
Mar  4 23:03:09 Clarkes-MacBook-Pro mstreamd[3025]: (Note ) PS: Media stream daemon stopping.
Mar  4 23:03:09 Clarkes-MacBook-Pro mstreamd[3025]: (Note ) AS: : Shared Streams daemon has shut down.
Mar  4 23:03:09 Clarkes-MacBook-Pro mstreamd[3025]: (Warn ) mstreamd: mstreamd shutting down.
Mar  4 23:03:12 Clarkes-MacBook-Pro assertiond[3040]: assertion failed: 15D21 13C75: assertiond + 12188 [8CF1968D-3466-38B7-B225-3F6F5B64C552]: 0x1

0 个答案:

没有答案