简体   繁体   English

我的 Xcode Objective-C iOS 应用程序在调用静态库中的成员时崩溃

[英]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 开发编程指南或示例。

  1. Create static lib project创建静态库项目
  2. Add functionality.添加功能。 eg.例如。 a member fn that returns a string返回字符串的成员 fn
  3. Build建造
  4. Create objC app创建 objC 应用程序
  5. Create folder for static lib within app proj folder在 app proj 文件夹中为静态库创建文件夹
  6. Copy (ctrl drag) .h & .a from static lib proj lefthand product pane to staticLib folder within app folder将(ctrl 拖动).h & .a 从 static lib proj 左侧产品窗格复制到 app 文件夹中的 staticLib 文件夹
  7. Import .a & .h: Drag .a and .h from staticLib folder to app's lefthand project window, line beneath proj line导入 .a 和 .h:将 .a 和 .h 从 staticLib 文件夹拖到应用程序的左侧项目窗口,在项目行下方的行
  8. Copy app > TARGETS > target > Build settings > All > Search Paths > Library Search Paths to复制 app > TARGETS > target > Build settings > All > Search Paths > Library Search Paths to

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 ok 9. 将活动方案设置为目标硬件(例如您的 iPhone 或 iPad) 10. 设置 PROJECT 构建设置 > 基本 > 部署部分 > iOS Dep Targ = 目标硬件的 iOS(例如 13.6) 11. 验证构建正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Objective-C中通过我的IOS应用程序进行Whats App语音呼叫 - How to make whats app Voice calls from my IOS Application in Objective-C 在 Xcode 中,如何为应用程序构建 Objective-C 库以在 iOS SIMULATOR 上运行? - In Xcode, how to build an Objective-C lib for an app to run on iOS SIMULATOR? Objective-C / iOS共享文档以上传到我的应用中 - Objective-C / iOS share documents to upload in my app 替换我的UISplitView中的detailViewController会在旋转我的应用程序Objective-C时崩溃 - replacement of my detailViewController in UISplitView crashes on rotating my app Objective-C 未知原因导致CFStringAppend期间Objective-C iOS应用程序崩溃 - Objective-C iOS app crashes during CFStringAppend for unknown reason 将我的应用程序放在Objective-C的前台 - Bring my app to the foreground in Objective-C Objective-C-我的应用程序的页脚 - Objective-C - footer for my app 操作系统,objective-c,我无法确切知道哪行,我的应用程序崩溃时是哪行 - os, objective-c, I am unable to know exactly line, by which line my app crashes 调用静态库会使我的iOS模拟器崩溃 - Making calls to a static library crashes my iOS simulator 在我的 xcode 项目中包含 Objective-C 类的问题 - Issues with including Objective-C class in my xcode project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM