[英]my Xcode Objective-C iOS app crashes when it calls a member in my static lib
My hello world app running on iPad crashes when it calls my static lib.我在 iPad 上运行的 hello world 应用程序在调用我的静态库时崩溃。 App does nothing but call member get_string in static lib.
应用程序除了在静态库中调用成员 get_string 之外什么都不做。
I copied .h & .a to a folder within app's project folder, and added search paths to .h and .a Builds, runs, then crashes.我将 .h 和 .a 复制到应用程序项目文件夹中的一个文件夹,并将搜索路径添加到 .h 和 .a 构建,运行,然后崩溃。
I think the issue is you're calling a class method/ static function on instance.我认为问题是您在实例上调用类方法/静态函数。 It should be called like this NSLog(@"----------------- %@ ------------------------", [[hello_world_lib2 class] get_string] );
它应该像这样调用 NSLog(@"----------------- %@ --------------------- ---", [[hello_world_lib2 类] get_string] );
I got it working.我让它工作了。 (iOS feels like a form of malware....when you have to program it. How programmer indifferent is Xcode compared with Visual Studio. I remember a few years ago when Xcode rated only 2 stars on the Apple Store itself.)
(iOS 感觉就像是一种恶意软件......当你必须对它进行编程时。与 Visual Studio 相比,程序员对 Xcode 的漠不关心。我记得几年前,Xcode 在 Apple Store 上的评分仅为 2 星。)
Anyway, I hope this solution saves others the days of trial-and-error it took me to figure out the magic --- and no Apple dev programming guides or examples for a simple static lib, that I could find.无论如何,我希望这个解决方案可以为其他人节省我花时间找出魔法的反复试验的日子 --- 并且没有我能找到的简单静态库的 Apple 开发编程指南或示例。
Header Search Paths
标题搜索路径
9. Set active scheme to target HW (eg. your iPhone or iPad) 10. Set PROJECT build settings > Basic > Deployment section > iOS Dep Targ = iOS of target HW (eg. 13.6) 11. Verify build ok9. 将活动方案设置为目标硬件(例如您的 iPhone 或 iPad) 10. 设置 PROJECT 构建设置 > 基本 > 部署部分 > iOS Dep Targ = 目标硬件的 iOS(例如 13.6) 11. 验证构建正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.