struct class_rw_t { // Be warned that Symbolication knows the layout of this structure. uint32_t flags; uint16_t witness; #if SUPPORT_INDEXED_ISA uint16_t index; #endif
explicit_atomic<uintptr_t> ro_or_rw_ext;
Class firstSubclass; Class nextSiblingClass;
const method_array_t methods() const { auto v = get_ro_or_rwe(); if (v.is<class_rw_ext_t *>()) { return v.get<class_rw_ext_t *>(&ro_or_rw_ext)->methods; } else { return method_array_t{v.get<const class_ro_t *>(&ro_or_rw_ext)->baseMethods()}; } }
const property_array_t properties() const { auto v = get_ro_or_rwe(); if (v.is<class_rw_ext_t *>()) { return v.get<class_rw_ext_t *>(&ro_or_rw_ext)->properties; } else { return property_array_t{v.get<const class_ro_t *>(&ro_or_rw_ext)->baseProperties}; } }
const protocol_array_t protocols() const { auto v = get_ro_or_rwe(); if (v.is<class_rw_ext_t *>()) { return v.get<class_rw_ext_t *>(&ro_or_rw_ext)->protocols; } else { return protocol_array_t{v.get<const class_ro_t *>(&ro_or_rw_ext)->baseProtocols}; } } }
(lldb) p $8.get(0) (property_t) $9 = (name = "name", attributes = "T@\"NSString\",C,N,V_name") (lldb) p $8.get(1) (property_t) $10 = (name = "age", attributes = "Ti,N,V_age") (lldb) (lldb) p $8.get(2) Assertion failed: (i < count), function get, file objc4-818.2/runtime/objc-runtime-new.h, line 624. error: Execution was interrupted, reason: signal SIGABRT. The process has been returned to the state before expression evaluation.
union { const uint8_t * ivarLayout; Class nonMetaclass; };
explicit_atomic<const char *> name; // With ptrauth, this is signed if it points to a small list, but // may be unsigned if it points to a big list. void *baseMethodList; protocol_list_t * baseProtocols; // 这里存放的是ivars const ivar_list_t * ivars;
(lldb) p $40.get(0).big() (method_t::big) $41 = { name = "func3" types = 0x0000000100003f5b "v16@0:8" imp = 0x0000000100003c00 (AL-Objc`+[Person func3]) } (lldb) p $40.get(1).big() (method_t::big) $42 = { name = "func4" types = 0x0000000100003f5b "v16@0:8" imp = 0x0000000100003c30 (AL-Objc`+[Person func4]) } (lldb) p $40.get(2).big() Assertion failed: (i < count), function get, file objc4-818.2/runtime/objc-runtime-new.h, line 624. error: Execution was interrupted, reason: signal SIGABRT. The process has been returned to the state before expression evaluation. (lldb)
typedef struct _malloc_zone_t { /* Only zone implementors should depend on the layout of this structure; Regular callers should use the access functions below */ void *reserved1; /* RESERVED FOR CFAllocator DO NOT USE */ void *reserved2; /* RESERVED FOR CFAllocator DO NOT USE */ size_t (* MALLOC_ZONE_FN_PTR(size))(struct _malloc_zone_t *zone, const void *ptr); void *(* MALLOC_ZONE_FN_PTR(malloc))(struct _malloc_zone_t *zone, size_t size); void *(* MALLOC_ZONE_FN_PTR(calloc))(struct _malloc_zone_t *zone, size_t num_items, size_t size); void *(* MALLOC_ZONE_FN_PTR(valloc))(struct _malloc_zone_t *zone, size_t size); /* same as malloc, but block returned is set to zero and is guaranteed to be page aligned */ void (* MALLOC_ZONE_FN_PTR(free))(struct _malloc_zone_t *zone, void *ptr); void *(* MALLOC_ZONE_FN_PTR(realloc))(struct _malloc_zone_t *zone, void *ptr, size_t size); void (* MALLOC_ZONE_FN_PTR(destroy))(struct _malloc_zone_t *zone); const char *zone_name; ... boolean_t (* MALLOC_ZONE_FN_PTR(claimed_address))(struct _malloc_zone_t *zone, void *ptr); } malloc_zone_t;
if (0 == size) { size = NANO_REGIME_QUANTA_SIZE; // Historical behavior } k = (size + NANO_REGIME_QUANTA_SIZE - 1) >> SHIFT_NANO_QUANTUM; // round up and shift for number of quanta slot_bytes = k << SHIFT_NANO_QUANTUM; // multiply by power of two quanta size *pKey = k - 1; // Zero-based!
// Read class's info bits all at once for performance bool hasCxxCtor = cxxConstruct && cls->hasCxxCtor(); bool hasCxxDtor = cls->hasCxxDtor(); bool fast = cls->canAllocNonpointer(); size_t size;
id obj; if (zone) { obj = (id)malloc_zone_calloc((malloc_zone_t *)zone, 1, size); } else { // 2. 算出来需要多少空间,这里进行开辟 obj = (id)calloc(1, size); } // 极少数情况下,obj会创建失败 if (slowpath(!obj)) { if (construct_flags & OBJECT_CONSTRUCT_CALL_BADALLOC) { return _objc_callBadAllocHandler(cls); } return nil; }
if (!zone && fast) { // 3. 空间有了,这里进行对象关联 obj->initInstanceIsa(cls, hasCxxDtor); } else { // Use raw pointer isa on the assumption that they might be // doing something weird with the zone or RR. obj->initIsa(cls); }
(lldb) x/4gx p 0x600002f86cc0: 0x0000000106e37660 0x0000000106e32040 0x600002f86cd0: 0x0000000106e32060 0x0000000000000000 (lldb) po 0x0000000106e37660 // isa指针,指向class Person (lldb) po 0x0000000106e32040 A (lldb) po 0x0000000106e32060 B
struct NumA getStructA(int a, int b, int c, int d, int e, int f) { struct NumA num; num.a = a; num.b = b; num.c = c; num.d = d; num.e = e; num.f = f; return num; }
- (void)viewDidLoad { [super viewDidLoad]; struct NumA num = getStructA(1,2,3,4,5,6); }
struct NumA getStructA(int a, int b, int c, int d, int e, int f) { struct NumA num; num.a = a; num.b = b; num.c = c; num.d = d; num.e = e; num.f = f; return num; }
struct NumA returnStruct() { struct NumA num = getStructA(1,2,3,4,5,6); return num; }
> openssl req -new -key private.pem -out rsacert.csr ----- > Country Name (2 letter code) []:CN > State or Province Name (full name) []:Beijing > Locality Name (eg, city) []:Chaoyang > Organization Name (eg, company) []:Wangjing > Organizational Unit Name (eg, section) []:alan.com > Common Name (eg, fully qualified host name) []:alan.com > Email Address []:alan@163.com
> Please enter the following 'extra' attributes > to be sent with your certificate request // 这里不使用密码,其他根据要求自己填写。 > A challenge password []:
When a user taps a universal link that you handle, iOS also examines the user’s recent choices to determine whether to open your app or your website. For example, a user who has tapped a universal link to open your app can later choose to open your website in Safari by tapping a breadcrumb button in the status bar. After the user makes this choice, iOS continues to open your website in Safari until the user chooses to open your app by tapping OPEN in the Smart App Banner on the webpage.
# # Be sure to run `pod spec lint PrivateAdd_v2.podspec' to ensure this is a # valid spec and to remove all comments including this before submitting the spec. # # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ #
# 声明 Pod::Spec.new do |s|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # These will help people to find your library, and whilst it # can feel like a chore to fill in it's definitely to your advantage. The # summary should be tweet-length, and the description more in depth. # # 私有库名称 s.name = "PrivateAdd_v2" # 版本号,跟当前版本tag有关 s.version = "0.0.1" # 项目描述 s.summary = "A short description of PrivateAdd_v2."
# This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? # * Try to keep it short, snappy and to the point. # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! s.description = <<-DESC DESC
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Licensing your code is important. See http://choosealicense.com for more info. # CocoaPods will detect a license file if there is a named LICENSE* # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. #
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Specify the authors of the library, with email addresses. Email addresses # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also # accepts just a name if you'd rather not provide an email address. # # Specify a social_media_url where others can refer to, for example a twitter # profile URL. #
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # If this Pod runs only on iOS or OS X, then specify the platform and # the deployment target. You can optionally include the target after the platform. #
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Specify the location from where the source should be retrieved. # Supports git, hg, bzr, svn and HTTP. #
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # CocoaPods is smart about how it includes source code. For source files # giving a folder will include any swift, h, m, mm, c & cpp files. # For header files it will include any header in the folder. # Not including the public_header_files will make all headers public. #
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # A list of resources included with the Pod. These are copied into the # target bundle with a build phase script. Anything else will be cleaned. # You can preserve files from being cleaned, please don't preserve # non-essential files like tests, examples and documentation. #
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Link your library with frameworks, or libraries. Libraries do not include # the lib prefix of their name. #
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # If your library depends on compiler flags you can set them in the xcconfig hash # where they will only apply to your library. If you depend on other Podspecs # you can include multiple dependencies to ensure it works.
pod spec lint,一般情况下私有库都是存在远程git上的,所以基本上只在第一次验证使用本地验证之后,就可以直接使用远端验证了。 但是一般情况下,创建的私有代码库如果是私有的(并不是官方的),这时候,我们在做远端验证时,需要添加代码地址。,不然pod会默认从官方repo查询。
1 2 3 4
pod spec lint --sources=[私有仓库repo地址],[私有库git地址],https://github.com/CocoaPods/Specs.git
// 或者只添加前面两项,最后一项可以忽略 pod spec lint --sources=[私有仓库repo地址],[私有库git地址]
如果出现一些警告,可以直接在命令最后添加--allow-warnings来屏蔽警告。例如:
1 2 3
pod spec lint --sources=https://gitee.com/devAlan/PrivateRepo,https://gitee.com/devAlan/PrivateAdd_v3.git,https://github.com/CocoaPods/Specs.git --allow-warnings
pod spec lint --sources=https://gitee.com/devAlan/PrivateRepo,https://gitee.com/devAlan/PrivateAdd_v3.git --allow-warnings
发布私有库
将podspec文件推送到私有空间repo,在发布时一定要记住,已经做了tag处理。
1 2
pod repo push [私有仓库repo] [私有库podspec文件地址] --allow-warnings pod repo push [私有仓库repo] [私有库podspec文件地址] --sources=[私有仓库repo地址],[私有库地址],https://gitee.com/devAlan/PrivateAdd_v2.git --allow-warnings
由于基本上的所有命令操作都是在该私有库文件夹下,所以不用管podspec的文件位置。
1
pod repo push PrivateRepo PrivateAdd.podspec --allow-warnings
执行该命令时,相当于直接将podspec文件push到repo的Git地址上。
引用私有库
本地路径引用
做好验证之后,如果需要测试,可以直接在podfile中引用私有库的本地路径
1 2
// ../是回到上一级文件目录,是以当前podfile所在文件位置决定 pod 'Private_v2', :path => '../../Private_v2'