因为项目里用到的有些第三方库还没有兼容swift3,所以只有先迁移到swift2.3,过程记录如下:
首页 | 归档 | 分类 | 标签 |
因为项目里用到的有些第三方库还没有兼容swift3,所以只有先迁移到swift2.3,过程记录如下:
在公司经历过同时需要添加多个设备并更新profile,幸得有spaceship相助,写了个脚本UpdateProfile.rb:
require "spaceship"
Spaceship.login('APPLE ID', 'password')
#参数传入true表示需要新增设备,例如:ruby UpdateProfile.rb true
if ARGV[0] == "true"
file = File.open("multiple-device-upload-ios.txt") #文本文件里录入的udid和设备名用tab分隔
file.each do |line|
arr = line.strip.split("\t")
device = Spaceship.device.create!(name: arr[1], udid: arr[0])
puts "add device: #{device.name} #{device.udid} #{device.model}"
end
devices = Spaceship.device.all
profiles = Array.new
profiles += Spaceship.provisioning_profile.development.all
profiles += Spaceship.provisioning_profile.ad_hoc.all
profiles.each do |p|
puts "Updating #{p.name}"
p.devices = devices
p.update!
end
end
dic = { "XXXAdHoc" => "773086ad-6b7b-4e57-85b7-08b577308e91.mobileprovision",
"XXXDevelop" => "a7a85aa7-f359-4415-a8ed-3dacc31ea448.mobileprovision" }
downloadProfiles = Array.new
downloadProfiles += Spaceship.provisioning_profile.development.all
downloadProfiles += Spaceship.provisioning_profile.ad_hoc.all
downloadProfiles.each do |p|
puts "Downloading #{p.name}"
fileName = dic[p.name]
File.write("/Users/ray/Library/MobileDevice/Provisioning Profiles/#{fileName}", p.download)
end
看了参考文章写的用swift写服务器,自己跟着做了一遍,踩了不少坑,于是记录成文:
此处有坑,不要下载最新的3.16号的安装包,要下载和vapor使用版本一致的包,可打开vapor里的.swift-version文件查看其使用版本,目前使用的是:
https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a/swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx.pkg
若使用的是Xcode7.3:export TOOLCHAINS=swift
或者使用Xcode7.2:PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:$PATH
添加后执行:swift --version
,确认显示为:Apple Swift version 3.0-dev
再执行:swift build --version
,确认显示为:Apple Swift Package Manager 0.1
若出现以下错误(下载DEVELOPMENT-SNAPSHOT-2016-03-16-a的包会出这个问题,我最初下载的3.16的包,遇到这个问题,一并记录在这儿;下载安装3.1的包不会有该问题):
dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a.xctoolchain/usr/bin/swift-build
Reason: image not found
解决办法,添加环境变量:export DYLD_LIBRARY_PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/macosx:$DYLD_LIBRARY_PATH
译自:http://nshipster.com/new-years-2015/
swift类和结构体的成员函数总是有以下2种等价调用形式:
[1, 2, 3, 4].reverse()
Array.reverse([1, 2, 3, 4])()
ImageScout:下载最少的数据来获取网络图片的尺寸和类型,支持png,gif,jpg。swift实现,兼容ios7+
deliver:命令行一键发布ipa,上传截图,关键字等,还支持持续集成单元测试
先来看个错误示例:
class Foo {
public:
int value() { return 5; }
};
class Bar : public Foo {
public:
int value() { return 10; }
};
Bar *b = new Bar();
Foo *f = (Foo*)b;
printf(“%i”, f->value());// Output = 5
期望输出为10,可是输出5;要想使输出为10,就需要用到虚函数,正确示例如下:
class Foo {
public:
virtual int value() { return 5; }
};
class Bar : public Foo {
public:
virtual int value() { return 10; }
};