你们中有些人可能知道,Xcode 11.4+ 版本终于支持在模拟器内测试通知。我们可以通过将 .apns 文件拖到模拟器中进行测试,或者运行以下命令:
xcrun simctl push <DEVICE_ID/NAME> ./notification-test.apns
Run Code Online (Sandbox Code Playgroud)
.apns 文件的结构如下:
xcrun simctl push <DEVICE_ID/NAME> ./notification-test.apns
Run Code Online (Sandbox Code Playgroud)
现在我正在测试我的React Native应用程序,它监听来自firebase 消息传递的通知。
我想测试data内部通知消息,但不起作用。
我怎样才能实现模拟 Firebase 消息传递的测试通知,以便messaging().getInitialNotification()其他 Firebase 功能可以捕获?
apple-push-notifications ios-simulator firebase react-native
Network Error我有一个 React Native 应用程序,在尝试与后端 api 通信时抛出一个异常。
我尝试过的故障排除:
await axios(config))配置:
{"data": null, "headers": {"Content-Type": "application/json", "X-JWT": "..."}, "method": "GET", "url": "https://example.com/..."}
Run Code Online (Sandbox Code Playgroud)
错误:
{"message":"Network Error",
"name":"Error",
"stack":"createError@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:156907:26\nhandleError@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:156693:69\ndispatchEvent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:30339:31\nsetReadyState@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:29485:33\n__didCompleteResponse@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:29291:29\nemit@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:2264:42\n__callFunction@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:3086:36\n@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:2810:31\n__guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:3037:15\ncallFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.exampleapp:2809:21\ncallFunctionReturnFlushedQueue@[native code]",
"config":{
"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,
"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","X-JWT":"..."},
"url":"https://example.com/...",
"method":"get",
"data":"null"
},
"status":null}
Run Code Online (Sandbox Code Playgroud)
技术环境:
为了节省我的(M1,2020)MacBook Pro(MYD82LL/A)内部驱动器上宝贵的 256GB 磁盘空间,我在安装 Xcode 后在 macOS 终端中运行了以下命令,以移动所有空间 -将组件占用到我格式化时命名为“Developer”的 2TB 外部驱动器中:
\nsudo mv /Applications/Xcode.app /Volumes/Developer/Applications/Xcode.app && sudo ln -s /Volumes/Developer/Applications/Xcode.app /Applications/Xcode.app\nsudo mv ~/Library/Developer/CoreSimulator /Volumes/Developer/CoreSimulator && ln -s /Volumes/Developer/CoreSimulator ~/Library/Developer/CoreSimulator && sudo chown -R $USER:staff /Volumes/Developer/CoreSimulator\nRun Code Online (Sandbox Code Playgroud)\n尽管绝对确保 CoreSimulator 文件夹具有正确的所有权和权限(因此sudo chown -R $USER:staff /Volumes/Developer/CoreSimulator如上所述),但我在尝试模拟设备时仍然收到此错误(图像缩小,因为 2880x1800 Retina 分辨率会推高屏幕截图的文件大小)过去 2MB):
更奇怪的是,我在 Xcode 中尝试执行此操作,同时还在tail -f ~/Library/Logs/CoreSimulator/CoreSimulator.log单独的终端窗口中运行。鉴于我确信(通过chown)确保我已经对移动的目录具有写访问权,因此生成的实时日志信息似乎违背逻辑:
May 3 13:27:12 realkstrawn93-m1mbp CoreSimulatorService[2890] <Warning>: Device BC4197AA-A5E9-4611-98B3-4C96B2CCD460 encountered in creation state at launch. The device will be …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个支持待机模式的小部件。是否可以在 iOS 模拟器中启用待机模式?
在设备上,“设置”中有一个用于待机模式的菜单。但模拟器设置中不存在该菜单
我迷失了,因为我不知道为什么我被要求创建一个本地开发构建来在 ios 模拟器中运行我的 expo 应用程序,因为我从来不需要构建来运行它。
我只是简单地运行命令npm start,然后按i打开我的 ios 模拟器,而没有遇到任何问题,但由于某种原因,现在我被要求首先在设备上安装开发版本。
这是错误:
Opening on iOS...
CommandError: No development build (com.checka.myappnative) for this project is installed. Please make and install a development build on the device first.
Run Code Online (Sandbox Code Playgroud)
我的问题是为什么我不能像往常一样简单地运行我的 ios 模拟器,发生了什么变化?
我正在尝试打开模拟器,以便模拟 Flutter 应用程序。但是,我的模拟器遇到了问题。当我尝试打开它(我使用它open -a Simulator)时,模拟器永远不会打开。当我尝试在菜单栏中创建新模拟器时,单击“新模拟器”选项卡上的“下一步”不会执行任何操作。另外,我不确定这是否相关,但在“新模拟器”选项卡中,有模拟器名称、设备类型和操作系统版本,我无法选择操作系统版本,它只是空白,没有其他选择。
我尝试过重新启动计算机、更新计算机并重新安装 Xcode。还安装/重新安装了命令行工具。
以下是更多信息:
macOS 版本:macOS 14.0 (23A344)
Xcode 版本:Xcode 15.0 构建版本 15A240d
模拟器版本:版本15.0 (1015.2) SimulatorKit 935.1 CoreSimulator 920.6
有谁知道可能是什么原因导致这个问题?
我正在尝试在Xcode中构建多个目标,以简化创建应用程序的"精简版"和"专业版"的过程.从理论上讲,这很好,我可以传递定义,GCC_PREPROCESSOR_DEFINITIONS以便在我的代码中使用.但是,由于尝试在模拟器中启动第二个目标时出错,我实际上遇到了问题:Failed to launch simulated application: Unknown error.
这是我用来创建额外目标的简单过程:
Project> New Target...,然后选择"Cocoa Touch Application"(名为MyAppPro")GCC_PREPROCESSOR_DEFINITIONS用户定义的设置并将值设置为"MYAPP_PRO"(无引号)Failed to launch simulated application: Unknown error.Failed to launch simulated application: Unknown error.构建完成得很好,但我无法在模拟器中运行.
编辑.xcodeproj目录中的project.pbxproj,我注意到两个目标定义的构建设置之间存在一些关键差异.我尝试手动编辑文件,但一定做错了,因为我之后无法在Xcode中加载它.
原始目标的"调试"构建设置:
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = iphoneos2.2.1;
};
Run Code Online (Sandbox Code Playgroud)
新的MyAppPro目标的"Debug"构建设置:
buildSettings = …Run Code Online (Sandbox Code Playgroud) 我得到这个链接器错误,不会让我编译.它只发生在模拟器上.
要点:
-只发生在模拟器
-以类似这个问题,却发现我的.pbxproj文件中没有FRAMEWORK_SEARCH_PATHS
-虽然我的操作系统是10.6.2,我必须建立目标1.5,以避免其他链接错误
- libxml2.dylib IS必需的,在我的框架组
- 我从未听说过的其他引用的库.
- 尝试在框架下引入其他Libs,没有解决.
Build SpaceTweet of project SpaceTweet with configuration Debug
Ld build/Debug-iphonesimulator/SpaceTweet.app/SpaceTweet normal i386
cd "/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)"
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk "-L/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/Debug-iphonesimulator" -L/Users/Scott/Desktop "-L/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/../../libYAJLIPhone-0" -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/lib -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib "-F/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/Debug-iphonesimulator" -filelist "/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/SpaceTweet.build/Debug-iphonesimulator/SpaceTweet.build/Objects-normal/i386/SpaceTweet.LinkFileList" -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework AVFoundation -framework MessageUI -lYAJLIPhone -lxml2 -o "/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/Debug-iphonesimulator/SpaceTweet.app/SpaceTweet"
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/libxml2.dylib, missing required architecture i386 in file …Run Code Online (Sandbox Code Playgroud) compiler-construction iphone xcode osx-snow-leopard ios-simulator